Package util

Source Code of util.MyActs

/*
* Danet GmbH
* Beratung und Software-Entwicklung
* Gesch�ftstelle AN
*
* $Id: MyActs.java 2326 2007-03-27 21:59:44Z mlipp $
*
* $Log$
* Revision 1.1.1.1  2003/06/30 20:07:00  drmlipp
* Initial import
*
* Revision 1.1  2001/11/19 15:07:07  schlue
* Unit tests for web actions added
*
*
*
*/
package util;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;

import de.danet.an.util.web.action.WebActionHandler;
import de.danet.an.util.web.action.WebActionDispatcher;

/**
* Test class for web action handlers
*/
public class MyActs extends WebActionHandler {
    public MyActs (String method) {
      super(method);
  }
 
    public static WebActionDispatcher suite()
    throws IllegalAccessException, InvocationTargetException {
  WebActionDispatcher suite = new WebActionDispatcher();
  // Test method name that has not been defined
  try {
      suite.addHandler (new MyActs("notDefined"));
      throw new IllegalArgumentException("Illegal action method not detected");
  } catch (IllegalArgumentException exc ) {
  }
 
  // Test method name that has been defined twice
  try {
      suite.addHandler (new MyActs("twiceDefined"));
      throw new IllegalArgumentException("Illegal action method not detected");
  } catch (IllegalArgumentException exc ) {
  }

  // Test method with illegal return value
  try {
      suite.addHandler (new MyActs("illegalReturnValue"));
      throw new IllegalArgumentException("Illegal action method not detected");
  } catch (IllegalArgumentException exc ) {
  }

  // Test method with illegal parameters
  try {
      suite.addHandler (new MyActs("illegalFirstParameter"));
      throw new IllegalArgumentException("Illegal action method not detected");
  } catch (IllegalArgumentException exc ) {
  }
  try {
      suite.addHandler (new MyActs("illegalSecondParameter"));
      throw new IllegalArgumentException("Illegal action method not detected");
  } catch (IllegalArgumentException exc ) {
  }

  // Now some valid action methods
  suite.addHandler (new MyActs("validMethod1Param1"));
  suite.addHandler (new MyActs("validMethod1Param2"));
  suite.addHandler (new MyActs("validMethod2Params1"));
  suite.addHandler (new MyActs("validMethod2Params2"));
 
  return suite;
    }
   
    public void twiceDefined(String arg1) {
    }
    public void twiceDefined(HttpServletRequest arg1) {
    }
    public int illegalReturnValue(HttpServletRequest arg1, Object arg2) {
  return 0;
    }
    public void illegalFirstParameter(int arg1, String arg2) {
    }
    public void illegalSecondParameter(HttpServletRequest arg1, HttpServletRequest arg2) {
    }
    public void validMethod1Param1(HttpServletRequest arg1) {
    }
    public void validMethod1Param2(String arg1) {
    }
    public void validMethod2Params1(HttpServletRequest arg1, String arg2) {
    }
    public void validMethod2Params2(String arg1, String arg2) {
    }
}
TOP

Related Classes of util.MyActs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.