Menu

NullPointerException in verifyForward()

2002-09-11
2002-09-13
  • Brandon Stewart

    Brandon Stewart - 2002-09-11

    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

     
    • Qingxian Wang

      Qingxian Wang - 2002-09-12

      Could you give more details, e.g. code, mapping, using Tiles or not?

      Qingxian

       
    • Brandon Stewart

      Brandon Stewart - 2002-09-12

      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>

       
      • Qingxian Wang

        Qingxian Wang - 2002-09-13

        You haven't defined "<forward>" in your "<action>" tag, e.g.

        <forward name="Success" path="/details.jsp"/>

         

Log in to post a comment.