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