001: package com.mockrunner.struts;
002:
003: import java.util.Locale;
004:
005: import javax.sql.DataSource;
006:
007: import org.apache.commons.validator.ValidatorResources;
008: import org.apache.struts.action.Action;
009: import org.apache.struts.action.ActionForm;
010: import org.apache.struts.action.ActionForward;
011: import org.apache.struts.action.ActionMapping;
012: import org.apache.struts.action.ActionMessage;
013: import org.apache.struts.action.ActionMessages;
014: import org.apache.struts.action.DynaActionForm;
015: import org.apache.struts.config.FormBeanConfig;
016: import org.apache.struts.util.MessageResources;
017:
018: import com.mockrunner.base.BasicHTMLOutputTestCase;
019: import com.mockrunner.base.HTMLOutputModule;
020: import com.mockrunner.mock.web.ActionMockObjectFactory;
021: import com.mockrunner.mock.web.MockActionForward;
022: import com.mockrunner.mock.web.MockActionMapping;
023: import com.mockrunner.mock.web.MockPageContext;
024: import com.mockrunner.mock.web.WebMockObjectFactory;
025:
026: /**
027: * Delegator for {@link com.mockrunner.struts.ActionTestModule}. You can
028: * subclass this adapter or use {@link com.mockrunner.struts.ActionTestModule}
029: * directly (so your test case can use another base class).
030: * This basic adapter can be used if you don't need any other modules. It
031: * does not extend {@link com.mockrunner.base.BaseTestCase}. If you want
032: * to use several modules in conjunction, consider subclassing
033: * {@link com.mockrunner.struts.ActionTestCaseAdapter}.
034: * <b>This class is generated from the {@link com.mockrunner.struts.ActionTestModule}
035: * and should not be edited directly</b>.
036: */
037: public abstract class BasicActionTestCaseAdapter extends
038: BasicHTMLOutputTestCase {
039: private ActionTestModule actionTestModule;
040: private ActionMockObjectFactory actionMockObjectFactory;
041:
042: public BasicActionTestCaseAdapter() {
043:
044: }
045:
046: public BasicActionTestCaseAdapter(String name) {
047: super (name);
048: }
049:
050: protected void tearDown() throws Exception {
051: super .tearDown();
052: actionTestModule = null;
053: actionMockObjectFactory = null;
054: }
055:
056: /**
057: * Creates the {@link com.mockrunner.struts.ActionTestModule}. If you
058: * overwrite this method, you must call <code>super.setUp()</code>.
059: */
060: protected void setUp() throws Exception {
061: super .setUp();
062: actionTestModule = createActionTestModule(getActionMockObjectFactory());
063: }
064:
065: /**
066: * Creates a {@link com.mockrunner.mock.web.ActionMockObjectFactory}.
067: * @return the created {@link com.mockrunner.mock.web.ActionMockObjectFactory}
068: */
069: protected ActionMockObjectFactory createActionMockObjectFactory() {
070: return new ActionMockObjectFactory();
071: }
072:
073: /**
074: * Same as <code>createActionMockObjectFactory(otherFactory, true)</code>.
075: */
076: protected ActionMockObjectFactory createActionMockObjectFactory(
077: WebMockObjectFactory otherFactory) {
078: return new ActionMockObjectFactory(otherFactory);
079: }
080:
081: /**
082: * Creates a {@link com.mockrunner.mock.web.ActionMockObjectFactory} based on another
083: * {@link com.mockrunner.mock.web.WebMockObjectFactory}.
084: * The created {@link com.mockrunner.mock.web.ActionMockObjectFactory} will have its own
085: * request and response objects. If you set <i>createNewSession</i>
086: * to <code>true</code> it will also have its own session object.
087: * The two factories will share one <code>ServletContext</code>.
088: * Especially important for multithreading tests.
089: * If you set <i>createNewSession</i> to false, the two factories
090: * will share one session. This setting simulates multiple requests
091: * from the same client.
092: * @param otherFactory the other factory
093: * @param createNewSession create a new session for the new factory
094: * @return the created {@link com.mockrunner.mock.web.ActionMockObjectFactory}
095: */
096: protected ActionMockObjectFactory createActionMockObjectFactory(
097: WebMockObjectFactory otherFactory, boolean createNewSession) {
098: return new ActionMockObjectFactory(otherFactory,
099: createNewSession);
100: }
101:
102: /**
103: * Gets the {@link com.mockrunner.mock.web.ActionMockObjectFactory}.
104: * @return the {@link com.mockrunner.mock.web.ActionMockObjectFactory}
105: */
106: protected ActionMockObjectFactory getActionMockObjectFactory() {
107: synchronized (ActionMockObjectFactory.class) {
108: if (actionMockObjectFactory == null) {
109: actionMockObjectFactory = createActionMockObjectFactory();
110: }
111: }
112: return actionMockObjectFactory;
113: }
114:
115: /**
116: * Sets the {@link com.mockrunner.mock.web.ActionMockObjectFactory}.
117: * @param actionMockObjectFactory the {@link com.mockrunner.mock.web.ActionMockObjectFactory}
118: */
119: protected void setActionMockObjectFactory(
120: ActionMockObjectFactory actionMockObjectFactory) {
121: this .actionMockObjectFactory = actionMockObjectFactory;
122: }
123:
124: /**
125: * Creates a {@link com.mockrunner.struts.ActionTestModule} based on the current
126: * {@link com.mockrunner.mock.web.ActionMockObjectFactory}.
127: * Same as <code>createActionTestModule(getActionMockObjectFactory())</code>.
128: * @return the created {@link com.mockrunner.struts.ActionTestModule}
129: */
130: protected ActionTestModule createActionTestModule() {
131: return new ActionTestModule(getActionMockObjectFactory());
132: }
133:
134: /**
135: * Creates a {@link com.mockrunner.struts.ActionTestModule} with the specified
136: * {@link com.mockrunner.mock.web.ActionMockObjectFactory}.
137: * @return the created {@link com.mockrunner.struts.ActionTestModule}
138: */
139: protected ActionTestModule createActionTestModule(
140: ActionMockObjectFactory mockFactory) {
141: return new ActionTestModule(mockFactory);
142: }
143:
144: /**
145: * Returns the {@link com.mockrunner.struts.ActionTestModule} as
146: * {@link com.mockrunner.base.HTMLOutputModule}.
147: * @return the {@link com.mockrunner.base.HTMLOutputModule}
148: */
149: protected HTMLOutputModule getHTMLOutputModule() {
150: return actionTestModule;
151: }
152:
153: /**
154: * Gets the {@link com.mockrunner.struts.ActionTestModule}.
155: * @return the {@link com.mockrunner.struts.ActionTestModule}
156: */
157: protected ActionTestModule getActionTestModule() {
158: return actionTestModule;
159: }
160:
161: /**
162: * Sets the {@link com.mockrunner.struts.ActionTestModule}.
163: * @param actionTestModule the {@link com.mockrunner.struts.ActionTestModule}
164: */
165: protected void setActionTestModule(ActionTestModule actionTestModule) {
166: this .actionTestModule = actionTestModule;
167: }
168:
169: /**
170: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setReset(boolean)}
171: */
172: protected void setReset(boolean reset) {
173: actionTestModule.setReset(reset);
174: }
175:
176: /**
177: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setDoPopulate(boolean)}
178: */
179: protected void setDoPopulate(boolean doPopulate) {
180: actionTestModule.setDoPopulate(doPopulate);
181: }
182:
183: /**
184: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setRecognizeMessagesInSession(boolean)}
185: */
186: protected void setRecognizeMessagesInSession(
187: boolean recognizeInSession) {
188: actionTestModule
189: .setRecognizeMessagesInSession(recognizeInSession);
190: }
191:
192: /**
193: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setMessageAttributeKey(String)}
194: */
195: protected void setMessageAttributeKey(String messageAttributeKey) {
196: actionTestModule.setMessageAttributeKey(messageAttributeKey);
197: }
198:
199: /**
200: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setErrorAttributeKey(String)}
201: */
202: protected void setErrorAttributeKey(String errorAttributeKey) {
203: actionTestModule.setErrorAttributeKey(errorAttributeKey);
204: }
205:
206: /**
207: * Delegates to {@link com.mockrunner.struts.ActionTestModule#addMappedPropertyRequestPrefix(String)}
208: */
209: protected String addMappedPropertyRequestPrefix(String property) {
210: return actionTestModule
211: .addMappedPropertyRequestPrefix(property);
212: }
213:
214: /**
215: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionMapping}
216: */
217: protected ActionMapping getActionMapping() {
218: return actionTestModule.getActionMapping();
219: }
220:
221: /**
222: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setValidate(boolean)}
223: */
224: protected void setValidate(boolean validate) {
225: actionTestModule.setValidate(validate);
226: }
227:
228: /**
229: * Delegates to {@link com.mockrunner.struts.ActionTestModule#addExceptionHandler(ExceptionHandlerConfig)}
230: */
231: protected void addExceptionHandler(ExceptionHandlerConfig handler) {
232: actionTestModule.addExceptionHandler(handler);
233: }
234:
235: /**
236: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setResources(MessageResources)}
237: */
238: protected void setResources(MessageResources resources) {
239: actionTestModule.setResources(resources);
240: }
241:
242: /**
243: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setResources(String, MessageResources)}
244: */
245: protected void setResources(String key, MessageResources resources) {
246: actionTestModule.setResources(key, resources);
247: }
248:
249: /**
250: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setDataSource(DataSource)}
251: */
252: protected void setDataSource(DataSource dataSource) {
253: actionTestModule.setDataSource(dataSource);
254: }
255:
256: /**
257: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setDataSource(String, DataSource)}
258: */
259: protected void setDataSource(String key, DataSource dataSource) {
260: actionTestModule.setDataSource(key, dataSource);
261: }
262:
263: /**
264: * Delegates to {@link com.mockrunner.struts.ActionTestModule#createValidatorResources(String[])}
265: */
266: protected ValidatorResources createValidatorResources(
267: String[] resourcesFiles) {
268: return actionTestModule
269: .createValidatorResources(resourcesFiles);
270: }
271:
272: /**
273: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setValidatorResources(ValidatorResources)}
274: */
275: protected void setValidatorResources(
276: ValidatorResources validatorResources) {
277: actionTestModule.setValidatorResources(validatorResources);
278: }
279:
280: /**
281: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyForward(String)}
282: */
283: protected void verifyForward(String path) {
284: actionTestModule.verifyForward(path);
285: }
286:
287: /**
288: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionForward}
289: */
290: protected MockActionForward getActionForward() {
291: return actionTestModule.getActionForward();
292: }
293:
294: /**
295: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyForwardName(String)}
296: */
297: protected void verifyForwardName(String name) {
298: actionTestModule.verifyForwardName(name);
299: }
300:
301: /**
302: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyRedirect(boolean)}
303: */
304: protected void verifyRedirect(boolean redirect) {
305: actionTestModule.verifyRedirect(redirect);
306: }
307:
308: /**
309: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyNoActionErrors}
310: */
311: protected void verifyNoActionErrors() {
312: actionTestModule.verifyNoActionErrors();
313: }
314:
315: /**
316: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionErrors}
317: */
318: protected ActionMessages getActionErrors() {
319: return actionTestModule.getActionErrors();
320: }
321:
322: /**
323: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyNoActionMessages}
324: */
325: protected void verifyNoActionMessages() {
326: actionTestModule.verifyNoActionMessages();
327: }
328:
329: /**
330: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionMessages}
331: */
332: protected ActionMessages getActionMessages() {
333: return actionTestModule.getActionMessages();
334: }
335:
336: /**
337: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyHasActionErrors}
338: */
339: protected void verifyHasActionErrors() {
340: actionTestModule.verifyHasActionErrors();
341: }
342:
343: /**
344: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyHasActionMessages}
345: */
346: protected void verifyHasActionMessages() {
347: actionTestModule.verifyHasActionMessages();
348: }
349:
350: /**
351: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrorPresent(String)}
352: */
353: protected void verifyActionErrorPresent(String errorKey) {
354: actionTestModule.verifyActionErrorPresent(errorKey);
355: }
356:
357: /**
358: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessagePresent(String)}
359: */
360: protected void verifyActionMessagePresent(String messageKey) {
361: actionTestModule.verifyActionMessagePresent(messageKey);
362: }
363:
364: /**
365: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrorNotPresent(String)}
366: */
367: protected void verifyActionErrorNotPresent(String errorKey) {
368: actionTestModule.verifyActionErrorNotPresent(errorKey);
369: }
370:
371: /**
372: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessageNotPresent(String)}
373: */
374: protected void verifyActionMessageNotPresent(String messageKey) {
375: actionTestModule.verifyActionMessageNotPresent(messageKey);
376: }
377:
378: /**
379: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrors(String[])}
380: */
381: protected void verifyActionErrors(String[] errorKeys) {
382: actionTestModule.verifyActionErrors(errorKeys);
383: }
384:
385: /**
386: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessages(String[])}
387: */
388: protected void verifyActionMessages(String[] messageKeys) {
389: actionTestModule.verifyActionMessages(messageKeys);
390: }
391:
392: /**
393: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrorValues(String, Object[])}
394: */
395: protected void verifyActionErrorValues(String errorKey,
396: Object[] values) {
397: actionTestModule.verifyActionErrorValues(errorKey, values);
398: }
399:
400: /**
401: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionErrorByKey(String)}
402: */
403: protected ActionMessage getActionErrorByKey(String errorKey) {
404: return actionTestModule.getActionErrorByKey(errorKey);
405: }
406:
407: /**
408: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessageValues(String, Object[])}
409: */
410: protected void verifyActionMessageValues(String messageKey,
411: Object[] values) {
412: actionTestModule.verifyActionMessageValues(messageKey, values);
413: }
414:
415: /**
416: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionMessageByKey(String)}
417: */
418: protected ActionMessage getActionMessageByKey(String messageKey) {
419: return actionTestModule.getActionMessageByKey(messageKey);
420: }
421:
422: /**
423: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrorValue(String, Object)}
424: */
425: protected void verifyActionErrorValue(String errorKey, Object value) {
426: actionTestModule.verifyActionErrorValue(errorKey, value);
427: }
428:
429: /**
430: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessageValue(String, Object)}
431: */
432: protected void verifyActionMessageValue(String messageKey,
433: Object value) {
434: actionTestModule.verifyActionMessageValue(messageKey, value);
435: }
436:
437: /**
438: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionErrorProperty(String, String)}
439: */
440: protected void verifyActionErrorProperty(String errorKey,
441: String property) {
442: actionTestModule.verifyActionErrorProperty(errorKey, property);
443: }
444:
445: /**
446: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyActionMessageProperty(String, String)}
447: */
448: protected void verifyActionMessageProperty(String messageKey,
449: String property) {
450: actionTestModule.verifyActionMessageProperty(messageKey,
451: property);
452: }
453:
454: /**
455: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyNumberActionErrors(int)}
456: */
457: protected void verifyNumberActionErrors(int number) {
458: actionTestModule.verifyNumberActionErrors(number);
459: }
460:
461: /**
462: * Delegates to {@link com.mockrunner.struts.ActionTestModule#verifyNumberActionMessages(int)}
463: */
464: protected void verifyNumberActionMessages(int number) {
465: actionTestModule.verifyNumberActionMessages(number);
466: }
467:
468: /**
469: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setActionMessages(ActionMessages)}
470: */
471: protected void setActionMessages(ActionMessages messages) {
472: actionTestModule.setActionMessages(messages);
473: }
474:
475: /**
476: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setActionMessagesToSession(ActionMessages)}
477: */
478: protected void setActionMessagesToSession(ActionMessages messages) {
479: actionTestModule.setActionMessagesToSession(messages);
480: }
481:
482: /**
483: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionMessagesFromRequest}
484: */
485: protected ActionMessages getActionMessagesFromRequest() {
486: return actionTestModule.getActionMessagesFromRequest();
487: }
488:
489: /**
490: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionMessagesFromSession}
491: */
492: protected ActionMessages getActionMessagesFromSession() {
493: return actionTestModule.getActionMessagesFromSession();
494: }
495:
496: /**
497: * Delegates to {@link com.mockrunner.struts.ActionTestModule#hasActionMessages}
498: */
499: protected boolean hasActionMessages() {
500: return actionTestModule.hasActionMessages();
501: }
502:
503: /**
504: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setActionErrors(ActionMessages)}
505: */
506: protected void setActionErrors(ActionMessages errors) {
507: actionTestModule.setActionErrors(errors);
508: }
509:
510: /**
511: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setActionErrorsToSession(ActionMessages)}
512: */
513: protected void setActionErrorsToSession(ActionMessages errors) {
514: actionTestModule.setActionErrorsToSession(errors);
515: }
516:
517: /**
518: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionErrorsFromRequest}
519: */
520: protected ActionMessages getActionErrorsFromRequest() {
521: return actionTestModule.getActionErrorsFromRequest();
522: }
523:
524: /**
525: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionErrorsFromSession}
526: */
527: protected ActionMessages getActionErrorsFromSession() {
528: return actionTestModule.getActionErrorsFromSession();
529: }
530:
531: /**
532: * Delegates to {@link com.mockrunner.struts.ActionTestModule#hasActionErrors}
533: */
534: protected boolean hasActionErrors() {
535: return actionTestModule.hasActionErrors();
536: }
537:
538: /**
539: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getMockActionMapping}
540: */
541: protected MockActionMapping getMockActionMapping() {
542: return actionTestModule.getMockActionMapping();
543: }
544:
545: /**
546: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getMockPageContext}
547: */
548: protected MockPageContext getMockPageContext() {
549: return actionTestModule.getMockPageContext();
550: }
551:
552: /**
553: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getLastAction}
554: */
555: protected Action getLastAction() {
556: return actionTestModule.getLastAction();
557: }
558:
559: /**
560: * Delegates to {@link com.mockrunner.struts.ActionTestModule#generateValidToken}
561: */
562: protected void generateValidToken() {
563: actionTestModule.generateValidToken();
564: }
565:
566: /**
567: * Delegates to {@link com.mockrunner.struts.ActionTestModule#getActionForm}
568: */
569: protected ActionForm getActionForm() {
570: return actionTestModule.getActionForm();
571: }
572:
573: /**
574: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setActionForm(ActionForm)}
575: */
576: protected void setActionForm(ActionForm formObj) {
577: actionTestModule.setActionForm(formObj);
578: }
579:
580: /**
581: * Delegates to {@link com.mockrunner.struts.ActionTestModule#createActionForm(Class)}
582: */
583: protected ActionForm createActionForm(Class form) {
584: return actionTestModule.createActionForm(form);
585: }
586:
587: /**
588: * Delegates to {@link com.mockrunner.struts.ActionTestModule#createDynaActionForm(FormBeanConfig)}
589: */
590: protected DynaActionForm createDynaActionForm(
591: FormBeanConfig formConfig) {
592: return actionTestModule.createDynaActionForm(formConfig);
593: }
594:
595: /**
596: * Delegates to {@link com.mockrunner.struts.ActionTestModule#populateRequestToForm}
597: */
598: protected void populateRequestToForm() {
599: actionTestModule.populateRequestToForm();
600: }
601:
602: /**
603: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Class, Class)}
604: */
605: protected ActionForward actionPerform(Class action, Class form) {
606: return actionTestModule.actionPerform(action, form);
607: }
608:
609: /**
610: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Class)}
611: */
612: protected ActionForward actionPerform(Class action) {
613: return actionTestModule.actionPerform(action);
614: }
615:
616: /**
617: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Action)}
618: */
619: protected ActionForward actionPerform(Action action) {
620: return actionTestModule.actionPerform(action);
621: }
622:
623: /**
624: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Action, ActionForm)}
625: */
626: protected ActionForward actionPerform(Action action, ActionForm form) {
627: return actionTestModule.actionPerform(action, form);
628: }
629:
630: /**
631: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Action, Class)}
632: */
633: protected ActionForward actionPerform(Action action, Class form) {
634: return actionTestModule.actionPerform(action, form);
635: }
636:
637: /**
638: * Delegates to {@link com.mockrunner.struts.ActionTestModule#actionPerform(Class, ActionForm)}
639: */
640: protected ActionForward actionPerform(Class action, ActionForm form) {
641: return actionTestModule.actionPerform(action, form);
642: }
643:
644: /**
645: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setLocale(Locale)}
646: */
647: protected void setLocale(Locale locale) {
648: actionTestModule.setLocale(locale);
649: }
650:
651: /**
652: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setInput(String)}
653: */
654: protected void setInput(String input) {
655: actionTestModule.setInput(input);
656: }
657:
658: /**
659: * Delegates to {@link com.mockrunner.struts.ActionTestModule#setParameter(String)}
660: */
661: protected void setParameter(String parameter) {
662: actionTestModule.setParameter(parameter);
663: }
664: }
|