001 package com.mockrunner.tag;
002
003 import java.util.Map;
004
005 import javax.servlet.jsp.tagext.JspTag;
006 import javax.servlet.jsp.tagext.TagSupport;
007
008 import com.mockrunner.base.BasicHTMLOutputTestCase;
009 import com.mockrunner.base.HTMLOutputModule;
010 import com.mockrunner.mock.web.MockPageContext;
011 import com.mockrunner.mock.web.WebMockObjectFactory;
012
013 /**
014 * Delegator for {@link com.mockrunner.tag.TagTestModule}. You can
015 * subclass this adapter or use {@link com.mockrunner.tag.TagTestModule}
016 * directly (so your test case can use another base class).
017 * This basic adapter can be used if you don't need any other modules. It
018 * does not extend {@link com.mockrunner.base.BaseTestCase}. If you want
019 * to use several modules in conjunction, consider subclassing
020 * {@link com.mockrunner.tag.TagTestCaseAdapter}.
021 * <b>This class is generated from the {@link com.mockrunner.tag.TagTestModule}
022 * and should not be edited directly</b>.
023 */
024 public abstract class BasicTagTestCaseAdapter extends BasicHTMLOutputTestCase
025 {
026 private TagTestModule tagTestModule;
027 private WebMockObjectFactory webMockObjectFactory;
028
029 public BasicTagTestCaseAdapter()
030 {
031
032 }
033
034 public BasicTagTestCaseAdapter(String name)
035 {
036 super(name);
037 }
038
039 protected void tearDown() throws Exception
040 {
041 super.tearDown();
042 tagTestModule = null;
043 webMockObjectFactory = null;
044 }
045
046 /**
047 * Creates the {@link com.mockrunner.tag.TagTestModule}. If you
048 * overwrite this method, you must call <code>super.setUp()</code>.
049 */
050 protected void setUp() throws Exception
051 {
052 super.setUp();
053 tagTestModule = createTagTestModule(getWebMockObjectFactory());
054 }
055
056 /**
057 * Creates a {@link com.mockrunner.mock.web.WebMockObjectFactory}.
058 * @return the created {@link com.mockrunner.mock.web.WebMockObjectFactory}
059 */
060 protected WebMockObjectFactory createWebMockObjectFactory()
061 {
062 return new WebMockObjectFactory();
063 }
064
065 /**
066 * Same as <code>createWebMockObjectFactory(otherFactory, true)</code>.
067 */
068 protected WebMockObjectFactory createWebMockObjectFactory(WebMockObjectFactory otherFactory)
069 {
070 return new WebMockObjectFactory(otherFactory);
071 }
072
073 /**
074 * Creates a {@link com.mockrunner.mock.web.WebMockObjectFactory} based on another
075 * {@link com.mockrunner.mock.web.WebMockObjectFactory}.
076 * The created {@link com.mockrunner.mock.web.WebMockObjectFactory} will have its own
077 * request and response objects. If you set <i>createNewSession</i>
078 * to <code>true</code> it will also have its own session object.
079 * The two factories will share one <code>ServletContext</code>.
080 * Especially important for multithreading tests.
081 * If you set <i>createNewSession</i> to false, the two factories
082 * will share one session. This setting simulates multiple requests
083 * from the same client.
084 * @param otherFactory the other factory
085 * @param createNewSession create a new session for the new factory
086 * @return the created {@link com.mockrunner.mock.web.WebMockObjectFactory}
087 */
088 protected WebMockObjectFactory createWebMockObjectFactory(WebMockObjectFactory otherFactory, boolean createNewSession)
089 {
090 return new WebMockObjectFactory(otherFactory, createNewSession);
091 }
092
093 /**
094 * Gets the {@link com.mockrunner.mock.web.WebMockObjectFactory}.
095 * @return the {@link com.mockrunner.mock.web.WebMockObjectFactory}
096 */
097 protected WebMockObjectFactory getWebMockObjectFactory()
098 {
099 synchronized(WebMockObjectFactory.class)
100 {
101 if(webMockObjectFactory == null)
102 {
103 webMockObjectFactory = createWebMockObjectFactory();
104 }
105 }
106 return webMockObjectFactory;
107 }
108
109 /**
110 * Sets the {@link com.mockrunner.mock.web.WebMockObjectFactory}.
111 * @param webMockObjectFactory the {@link com.mockrunner.mock.web.WebMockObjectFactory}
112 */
113 protected void setWebMockObjectFactory(WebMockObjectFactory webMockObjectFactory)
114 {
115 this.webMockObjectFactory = webMockObjectFactory;
116 }
117
118 /**
119 * Creates a {@link com.mockrunner.tag.TagTestModule} based on the current
120 * {@link com.mockrunner.mock.web.WebMockObjectFactory}.
121 * Same as <code>createTagTestModule(getWebMockObjectFactory())</code>.
122 * @return the created {@link com.mockrunner.tag.TagTestModule}
123 */
124 protected TagTestModule createTagTestModule()
125 {
126 return new TagTestModule(getWebMockObjectFactory());
127 }
128
129 /**
130 * Creates a {@link com.mockrunner.tag.TagTestModule} with the specified
131 * {@link com.mockrunner.mock.web.WebMockObjectFactory}.
132 * @return the created {@link com.mockrunner.tag.TagTestModule}
133 */
134 protected TagTestModule createTagTestModule(WebMockObjectFactory mockFactory)
135 {
136 return new TagTestModule(mockFactory);
137 }
138
139 /**
140 * Returns the {@link com.mockrunner.tag.TagTestModule} as
141 * {@link com.mockrunner.base.HTMLOutputModule}.
142 * @return the {@link com.mockrunner.base.HTMLOutputModule}
143 */
144 protected HTMLOutputModule getHTMLOutputModule()
145 {
146 return tagTestModule;
147 }
148
149 /**
150 * Gets the {@link com.mockrunner.tag.TagTestModule}.
151 * @return the {@link com.mockrunner.tag.TagTestModule}
152 */
153 protected TagTestModule getTagTestModule()
154 {
155 return tagTestModule;
156 }
157
158 /**
159 * Sets the {@link com.mockrunner.tag.TagTestModule}.
160 * @param tagTestModule the {@link com.mockrunner.tag.TagTestModule}
161 */
162 protected void setTagTestModule(TagTestModule tagTestModule)
163 {
164 this.tagTestModule = tagTestModule;
165 }
166
167 /**
168 * Delegates to {@link com.mockrunner.tag.TagTestModule#getMockPageContext}
169 */
170 protected MockPageContext getMockPageContext()
171 {
172 return tagTestModule.getMockPageContext();
173 }
174
175 /**
176 * Delegates to {@link com.mockrunner.tag.TagTestModule#clearOutput}
177 */
178 protected void clearOutput()
179 {
180 tagTestModule.clearOutput();
181 }
182
183 /**
184 * Delegates to {@link com.mockrunner.tag.TagTestModule#createNestedTag(Class, Map)}
185 */
186 protected NestedTag createNestedTag(Class tagClass, Map attributes)
187 {
188 return tagTestModule.createNestedTag(tagClass, attributes);
189 }
190
191 /**
192 * Delegates to {@link com.mockrunner.tag.TagTestModule#createNestedTag(Class)}
193 */
194 protected NestedTag createNestedTag(Class tagClass)
195 {
196 return tagTestModule.createNestedTag(tagClass);
197 }
198
199 /**
200 * Delegates to {@link com.mockrunner.tag.TagTestModule#createWrappedTag(Class)}
201 */
202 protected JspTag createWrappedTag(Class tagClass)
203 {
204 return tagTestModule.createWrappedTag(tagClass);
205 }
206
207 /**
208 * Delegates to {@link com.mockrunner.tag.TagTestModule#createWrappedTag(Class, Map)}
209 */
210 protected JspTag createWrappedTag(Class tagClass, Map attributes)
211 {
212 return tagTestModule.createWrappedTag(tagClass, attributes);
213 }
214
215 /**
216 * Delegates to {@link com.mockrunner.tag.TagTestModule#getWrappedTag}
217 */
218 protected JspTag getWrappedTag()
219 {
220 return tagTestModule.getWrappedTag();
221 }
222
223 /**
224 * Delegates to {@link com.mockrunner.tag.TagTestModule#setTag(JspTag)}
225 */
226 protected NestedTag setTag(JspTag tag)
227 {
228 return tagTestModule.setTag(tag);
229 }
230
231 /**
232 * Delegates to {@link com.mockrunner.tag.TagTestModule#setTag(JspTag, Map)}
233 */
234 protected NestedTag setTag(JspTag tag, Map attributes)
235 {
236 return tagTestModule.setTag(tag, attributes);
237 }
238
239 /**
240 * Delegates to {@link com.mockrunner.tag.TagTestModule#setTag(TagSupport, Map)}
241 */
242 protected NestedTag setTag(TagSupport tag, Map attributes)
243 {
244 return tagTestModule.setTag(tag, attributes);
245 }
246
247 /**
248 * Delegates to {@link com.mockrunner.tag.TagTestModule#setTag(TagSupport)}
249 */
250 protected NestedTag setTag(TagSupport tag)
251 {
252 return tagTestModule.setTag(tag);
253 }
254
255 /**
256 * Delegates to {@link com.mockrunner.tag.TagTestModule#setDoRelease(boolean)}
257 */
258 protected void setDoRelease(boolean doRelease)
259 {
260 tagTestModule.setDoRelease(doRelease);
261 }
262
263 /**
264 * Delegates to {@link com.mockrunner.tag.TagTestModule#setDoReleaseRecursive(boolean)}
265 */
266 protected void setDoReleaseRecursive(boolean doRelease)
267 {
268 tagTestModule.setDoReleaseRecursive(doRelease);
269 }
270
271 /**
272 * Delegates to {@link com.mockrunner.tag.TagTestModule#populateAttributes}
273 */
274 protected void populateAttributes()
275 {
276 tagTestModule.populateAttributes();
277 }
278
279 /**
280 * Delegates to {@link com.mockrunner.tag.TagTestModule#setBody(String)}
281 */
282 protected void setBody(String body)
283 {
284 tagTestModule.setBody(body);
285 }
286
287 /**
288 * Delegates to {@link com.mockrunner.tag.TagTestModule#getNestedTag}
289 */
290 protected NestedTag getNestedTag()
291 {
292 return tagTestModule.getNestedTag();
293 }
294
295 /**
296 * Delegates to {@link com.mockrunner.tag.TagTestModule#doTag}
297 */
298 protected void doTag()
299 {
300 tagTestModule.doTag();
301 }
302
303 /**
304 * Delegates to {@link com.mockrunner.tag.TagTestModule#doStartTag}
305 */
306 protected int doStartTag()
307 {
308 return tagTestModule.doStartTag();
309 }
310
311 /**
312 * Delegates to {@link com.mockrunner.tag.TagTestModule#doEndTag}
313 */
314 protected int doEndTag()
315 {
316 return tagTestModule.doEndTag();
317 }
318
319 /**
320 * Delegates to {@link com.mockrunner.tag.TagTestModule#doInitBody}
321 */
322 protected void doInitBody()
323 {
324 tagTestModule.doInitBody();
325 }
326
327 /**
328 * Delegates to {@link com.mockrunner.tag.TagTestModule#doAfterBody}
329 */
330 protected int doAfterBody()
331 {
332 return tagTestModule.doAfterBody();
333 }
334
335 /**
336 * Delegates to {@link com.mockrunner.tag.TagTestModule#processTagLifecycle}
337 */
338 protected int processTagLifecycle()
339 {
340 return tagTestModule.processTagLifecycle();
341 }
342
343 /**
344 * Delegates to {@link com.mockrunner.tag.TagTestModule#release}
345 */
346 protected void release()
347 {
348 tagTestModule.release();
349 }
350
351 /**
352 * Delegates to {@link com.mockrunner.tag.TagTestModule#createTag(Class)}
353 */
354 protected TagSupport createTag(Class tagClass)
355 {
356 return tagTestModule.createTag(tagClass);
357 }
358
359 /**
360 * Delegates to {@link com.mockrunner.tag.TagTestModule#createTag(Class, Map)}
361 */
362 protected TagSupport createTag(Class tagClass, Map attributes)
363 {
364 return tagTestModule.createTag(tagClass, attributes);
365 }
366
367 /**
368 * Delegates to {@link com.mockrunner.tag.TagTestModule#getTag}
369 */
370 protected TagSupport getTag()
371 {
372 return tagTestModule.getTag();
373 }
374 }