All of our tests throw a NullPointerException when calling verifyForward after actionPerform():
There was 1 error:
1) testNotLoggedIn(test.com.galileo.fares.llpf.struts.TestEditUserAction)
java.lang.NullPointerException
at servletunit.struts.MockStrutsTestCase.getActualForward(MockStrutsTestCase.java:418)
at servletunit.struts.MockStrutsTestCase.verifyForward(MockStrutsTestCase.java:434)
at test.com.galileo.fares.llpf.struts.TestEditUserAction.testNotLoggedIn(TestEditUserAction.java:40)
at test.com.galileo.fares.llpf.struts.TestEditUserAction.main(TestEditUserAction.java:23)
The problem seems to be that the RequestDispatcher in the ServletContextSimulator has not been initialized. Any suggestions?
-Brandon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After further research, the problem seems to occur only for actions defined with scope="session".
This test generates the error:
public void testNotLoggedIn() {
setRequestPathInfo("/editUser");
actionPerform();
verifyForward("login");
verifyNoActionErrors();
}
This is the action mapping in struts-config:
<action path="/editUser" type="com.galileo.fares.llpf.struts.EditUserAction"
name="editUserForm"
scope="session"
validate="false">
</action>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All of our tests throw a NullPointerException when calling verifyForward after actionPerform():
There was 1 error:
1) testNotLoggedIn(test.com.galileo.fares.llpf.struts.TestEditUserAction)
java.lang.NullPointerException
at servletunit.struts.MockStrutsTestCase.getActualForward(MockStrutsTestCase.java:418)
at servletunit.struts.MockStrutsTestCase.verifyForward(MockStrutsTestCase.java:434)
at test.com.galileo.fares.llpf.struts.TestEditUserAction.testNotLoggedIn(TestEditUserAction.java:40)
at test.com.galileo.fares.llpf.struts.TestEditUserAction.main(TestEditUserAction.java:23)
The problem seems to be that the RequestDispatcher in the ServletContextSimulator has not been initialized. Any suggestions?
-Brandon
Could you give more details, e.g. code, mapping, using Tiles or not?
Qingxian
After further research, the problem seems to occur only for actions defined with scope="session".
This test generates the error:
public void testNotLoggedIn() {
setRequestPathInfo("/editUser");
actionPerform();
verifyForward("login");
verifyNoActionErrors();
}
This is the action mapping in struts-config:
<action path="/editUser" type="com.galileo.fares.llpf.struts.EditUserAction"
name="editUserForm"
scope="session"
validate="false">
</action>
You haven't defined "<forward>" in your "<action>" tag, e.g.
<forward name="Success" path="/details.jsp"/>