2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.test.el;
19
20 import java.util.HashMap;
21 import java.util.Locale;
22 import java.util.Map;
23 import javax.el.ELContext;
24 import javax.el.ELResolver;
25 import javax.el.FunctionMapper;
26 import javax.el.VariableMapper;
27 import javax.faces.context.FacesContext;
28
29 /***
30 * <p>Mock implementation of <code>ELContext</code>.</p>
31 *
32 * @since 1.0.4
33 */
34
35 public class MockELContext extends ELContext {
36
37
38
39
40
41 /*** Creates a new instance of MockELContext */
42 public MockELContext() {
43 }
44
45
46
47
48
49 private Map contexts = new HashMap();
50 private FunctionMapper functionMapper = new MockFunctionMapper();
51 private Locale locale = Locale.getDefault();
52 private boolean propertyResolved;
53 private VariableMapper variableMapper = new MockVariableMapper();
54
55
56
57
58
59
60
61
62
63 /*** {@inheritDoc} */
64 public Object getContext(Class key) {
65 if (key == null) {
66 throw new NullPointerException();
67 }
68 return contexts.get(key);
69 }
70
71
72 /*** {@inheritDoc} */
73 public ELResolver getELResolver() {
74 FacesContext context = FacesContext.getCurrentInstance();
75 return context.getApplication().getELResolver();
76 }
77
78
79 /*** {@inheritDoc} */
80 public FunctionMapper getFunctionMapper() {
81 return this.functionMapper;
82 }
83
84
85 /*** {@inheritDoc} */
86 public Locale getLocale() {
87 return this.locale;
88 }
89
90
91 /*** {@inheritDoc} */
92 public boolean isPropertyResolved() {
93 return this.propertyResolved;
94 }
95
96
97 /*** {@inheritDoc} */
98 public void putContext(Class key, Object value) {
99 if ((key == null) || (value == null)) {
100 throw new NullPointerException();
101 }
102 contexts.put(key, value);
103 }
104
105
106 /*** {@inheritDoc} */
107 public void setPropertyResolved(boolean propertyResolved) {
108 this.propertyResolved = propertyResolved;
109 }
110
111
112 /*** {@inheritDoc} */
113 public VariableMapper getVariableMapper() {
114 return this.variableMapper;
115 }
116
117
118 /*** {@inheritDoc} */
119 public void setLocale(Locale locale) {
120 this.locale = locale;
121 }
122
123
124 }