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