View Javadoc

1   /* LICENSE */
2   package net.smartlab.web.test;
3   
4   import java.io.File;
5   import java.lang.reflect.Method;
6   
7   import org.apache.struts.action.ActionServlet;
8   
9   import net.sf.cglib.proxy.Callback;
10  import net.sf.cglib.proxy.Enhancer;
11  import net.sf.cglib.proxy.MethodInterceptor;
12  import net.sf.cglib.proxy.MethodProxy;
13  import net.smartlab.web.Domain;
14  import servletunit.struts.MockStrutsTestCase;
15  
16  /**
17   * TODO documentation
18   * 
19   * @author rlogiacco
20   */
21  public abstract class ActionTestCase extends MockStrutsTestCase {
22  
23  	/**
24  	 * @see junit.framework.TestCase#setUp()
25  	 */
26  	protected void setUp() throws Exception {
27  		super.setUp();
28  		super.setContextDirectory(new File(this.getContextDirectory()));
29  		super.setConfigFile("/WEB-INF/" + this.getStrutsConfigFilename());
30  		super.setServletConfigFile("/WEB-INF/web.xml");
31  	}
32  
33  	protected String getContextDirectory() {
34  		return "res/test";
35  	}
36  
37  	protected String getStrutsConfigFilename() {
38  		return "struts.xml";
39  	}
40  
41  //	public static Domain getDomainMock(String domain) throws InstantiationException, IllegalAccessException {
42  //		System.out.println(" >>>>>>>>>>" + domain);
43  //		
44  //		Enhancer enhancer = new Enhancer();
45  //		enhancer.setSuperclass(domain);
46  //		enhancer.setCallback(new Interceptor());
47  //		return (Domain)enhancer.create();
48  //	}
49  //
50  //
51  //	private static class Interceptor implements MethodInterceptor {
52  //
53  //		/**
54  //		 * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object,
55  //		 *      java.lang.reflect.Method, java.lang.Object[],
56  //		 *      net.sf.cglib.proxy.MethodProxy)
57  //		 */
58  //		public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
59  //			Class type = method.getReturnType();
60  //			return type.newInstance();
61  //		}
62  //	}
63  }