|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--junit.framework.Assert
|
+--junit.framework.TestCase
|
+--org.chwf.servlet.mock.ReflectingTestCase
|
+--org.chwf.servlet.mock.ServletTestCase
|
+--org.chwf.servlet.mock.ControllerTestCase
A test case for controllers that sets up mock objects for servlets and
initializes and releases data in the ServletData class.
If you define your own setUp() and tearDown()
methods in subclasses of the ControllerTestCase, be sure to invoke the
superclass's methods:
public class MyControllerTest extends ControllerTestCase {
private MyController myController = null;
private InvocationContext context = null;
public MyControllerTest(String name) {
super(name);
}
protected void setUp() {
super.setUp();
this.myController = new MyController();
this.context = myController.initContext();
// Other setup
}
}
You can test the results of redirect operations inside the
controller with the getView() method of the
InvocationContext:
public void testRedirect() throws Exception {
myContext.commandMethod();
String view = context.getView();
assertEquals("expected-page.jsp", view);
}
| Constructor Summary | |
ControllerTestCase(java.lang.String name)
Constructor for ControllerTestCase. |
|
ControllerTestCase(java.lang.String name,
java.lang.Class cls)
Constructor for ControllerTestCase. |
|
| Method Summary | |
protected void |
setUp()
This method must be invoked in the setUp() method of subclasses: super.setUp() |
protected void |
tearDown()
This method must be invoked in the tearDown() method of subclasses: super.tearDown() |
| Methods inherited from class org.chwf.servlet.mock.ServletTestCase |
getApplication, getConfig, getOut, getOutput, getPageContext, getRequest, getResponse |
| Methods inherited from class org.chwf.servlet.mock.ReflectingTestCase |
testWhetherAllMethodsAreTested, testWhetherClassAndTestNameMatches |
| Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString |
| Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ControllerTestCase(java.lang.String name)
name - Test name
public ControllerTestCase(java.lang.String name,
java.lang.Class cls)
name - Test name.cls - Tested class.| Method Detail |
protected void setUp()
throws java.lang.Exception
super.setUp()setUp in class ServletTestCasejava.lang.Exception - for errors.
protected void tearDown()
throws java.lang.Exception
super.tearDown()tearDown in class ServletTestCasejava.lang.Exception - for errors.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||