1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.trinidadbuild.test;
20
21 import java.util.Collection;
22
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.el.ELContext;
28
29 import javax.faces.application.Application;
30 import javax.faces.application.ApplicationWrapper;
31 import javax.faces.context.ExternalContext;
32 import javax.faces.context.FacesContext;
33 import javax.faces.context.PartialResponseWriter;
34 import javax.faces.context.PartialViewContext;
35 import javax.faces.event.PhaseId;
36 import javax.faces.event.SystemEvent;
37 import javax.faces.lifecycle.Lifecycle;
38
39 import org.apache.shale.test.mock.MockFacesContext;
40 import org.apache.shale.test.mock.MockApplication12;
41
42
43 public class MockFacesContext12 extends MockFacesContext
44 {
45 public MockFacesContext12(ExternalContext ec,
46 Lifecycle lifecycle,
47 Application application)
48 {
49 super(ec, lifecycle);
50 elContext = createELContext(application);
51 elContext.putContext(FacesContext.class, this);
52 _app = application;
53 }
54
55 public MockFacesContext12(Application application)
56 {
57 elContext = createELContext(application);
58 elContext.putContext(FacesContext.class, this);
59 _app = application;
60 }
61
62 public PhaseId getCurrentPhaseId()
63 {
64 return _currentPhaseId;
65 }
66
67 public void setCurrentPhaseId(PhaseId phaseId)
68 {
69 this._currentPhaseId = phaseId;
70 }
71
72 public ELContext getELContext()
73 {
74 return elContext;
75 }
76
77 protected MockELContext createELContext(Application application)
78 {
79 return new MockELContext(application);
80 }
81
82 public Map<Object,Object> getAttributes()
83 {
84 return _attrs;
85 }
86
87 public PartialViewContext getPartialViewContext()
88 {
89 return _mockPartialContext;
90 }
91
92 public Application getApplication()
93 {
94 return new ApplicationWrapper()
95 {
96 public Application getWrapped()
97 {
98 return _app;
99 }
100 public void publishEvent(FacesContext context,
101 Class<? extends SystemEvent> systemEventClass,
102 Class<?> sourceBaseType,
103 Object source)
104 {
105
106 }
107
108 public void publishEvent(FacesContext context,
109 Class<? extends SystemEvent> systemEventClass,
110 Object source)
111 {
112
113 }
114 };
115 }
116
117 protected MockELContext elContext;
118
119 private PhaseId _currentPhaseId;
120
121 private final PartialViewContext _mockPartialContext = new MockPartialViewContext();
122 private final Map<Object, Object> _attrs = new HashMap<Object, Object>();
123 private Application _app;
124
125 private static class MockPartialViewContext extends PartialViewContext
126 {
127 public Collection<String> getExecuteIds()
128 {
129 throw new UnsupportedOperationException();
130 }
131
132 public Collection<String> getRenderIds()
133 {
134 throw new UnsupportedOperationException();
135 }
136
137 public PartialResponseWriter getPartialResponseWriter()
138 {
139 throw new UnsupportedOperationException();
140 }
141
142 public boolean isAjaxRequest()
143 {
144 return false;
145 }
146
147 public boolean isPartialRequest()
148 {
149 return false;
150 }
151
152 public boolean isExecuteAll()
153 {
154 throw new UnsupportedOperationException();
155 }
156
157 public boolean isRenderAll()
158 {
159 throw new UnsupportedOperationException();
160 }
161
162 public void setRenderAll(boolean renderAll)
163 {
164 throw new UnsupportedOperationException();
165 }
166
167 public void setPartialRequest(boolean isPartialRequest)
168 {
169 throw new UnsupportedOperationException();
170 }
171
172 public void release()
173 {
174 throw new UnsupportedOperationException();
175 }
176
177 public void processPartial(PhaseId phaseId)
178 {
179 throw new UnsupportedOperationException();
180 }
181 }
182 }