001: /*
002: * Danet GmbH
003: * Beratung und Software-Entwicklung
004: * Geschäftstelle AN
005: *
006: * $Id: MyActs.java,v 1.2 2007/03/27 21:59:42 mlipp Exp $
007: *
008: * $Log: MyActs.java,v $
009: * Revision 1.2 2007/03/27 21:59:42 mlipp
010: * Fixed lots of checkstyle warnings.
011: *
012: * Revision 1.1.1.1 2003/06/30 20:07:00 drmlipp
013: * Initial import
014: *
015: * Revision 1.1 2001/11/19 15:07:07 schlue
016: * Unit tests for web actions added
017: *
018: *
019: *
020: */
021: package util;
022:
023: import javax.servlet.http.HttpServletRequest;
024: import java.lang.reflect.InvocationTargetException;
025:
026: import de.danet.an.util.web.action.WebActionHandler;
027: import de.danet.an.util.web.action.WebActionDispatcher;
028:
029: /**
030: * Test class for web action handlers
031: */
032: public class MyActs extends WebActionHandler {
033: public MyActs(String method) {
034: super (method);
035: }
036:
037: public static WebActionDispatcher suite()
038: throws IllegalAccessException, InvocationTargetException {
039: WebActionDispatcher suite = new WebActionDispatcher();
040: // Test method name that has not been defined
041: try {
042: suite.addHandler(new MyActs("notDefined"));
043: throw new IllegalArgumentException(
044: "Illegal action method not detected");
045: } catch (IllegalArgumentException exc) {
046: }
047:
048: // Test method name that has been defined twice
049: try {
050: suite.addHandler(new MyActs("twiceDefined"));
051: throw new IllegalArgumentException(
052: "Illegal action method not detected");
053: } catch (IllegalArgumentException exc) {
054: }
055:
056: // Test method with illegal return value
057: try {
058: suite.addHandler(new MyActs("illegalReturnValue"));
059: throw new IllegalArgumentException(
060: "Illegal action method not detected");
061: } catch (IllegalArgumentException exc) {
062: }
063:
064: // Test method with illegal parameters
065: try {
066: suite.addHandler(new MyActs("illegalFirstParameter"));
067: throw new IllegalArgumentException(
068: "Illegal action method not detected");
069: } catch (IllegalArgumentException exc) {
070: }
071: try {
072: suite.addHandler(new MyActs("illegalSecondParameter"));
073: throw new IllegalArgumentException(
074: "Illegal action method not detected");
075: } catch (IllegalArgumentException exc) {
076: }
077:
078: // Now some valid action methods
079: suite.addHandler(new MyActs("validMethod1Param1"));
080: suite.addHandler(new MyActs("validMethod1Param2"));
081: suite.addHandler(new MyActs("validMethod2Params1"));
082: suite.addHandler(new MyActs("validMethod2Params2"));
083:
084: return suite;
085: }
086:
087: public void twiceDefined(String arg1) {
088: }
089:
090: public void twiceDefined(HttpServletRequest arg1) {
091: }
092:
093: public int illegalReturnValue(HttpServletRequest arg1, Object arg2) {
094: return 0;
095: }
096:
097: public void illegalFirstParameter(int arg1, String arg2) {
098: }
099:
100: public void illegalSecondParameter(HttpServletRequest arg1,
101: HttpServletRequest arg2) {
102: }
103:
104: public void validMethod1Param1(HttpServletRequest arg1) {
105: }
106:
107: public void validMethod1Param2(String arg1) {
108: }
109:
110: public void validMethod2Params1(HttpServletRequest arg1, String arg2) {
111: }
112:
113: public void validMethod2Params2(String arg1, String arg2) {
114: }
115: }
|