Struts 2
  1. Struts 2
  2. WW-3826

Unit Testing A Portlet Action Using StrutsTestCase Causes A NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.3.16
    • Component/s: Plugin - Portlet
    • Labels:
      None
    • Environment:

      JUnit 4.8.2 - Struts version 2.3.4

      Description

      When running a unit test of a Struts portlet Action using StrutsTestCase the test causes an error -

      java.lang.NullPointerException at org.apache.struts2.portlet.interceptor.PortletStateInterceptor.intercept(PortletStateInterceptor.java:52)

      (see below for complete stack trace)

      The same test when run with Struts portlet plugin version 2.2.1 passes.

      You can download an example application here: http://www.brucephillips.name/struts/Struts2CRUDPortletExample_Finish.zip. Unzip the example. In the project's root folder run mvn -e clean test. The test will pass.

      Modify pom.xml in the project to set the version number of Struts to 2.3.4. Remove the dependency on javaassist. Save the pom.xml

      In the project's root folder run mvn -e clean test. The test will error. View the test report in target/surfire-reports.

      -------------------------------------------------------------------------------
      Test set: com.struts2.tutorial.action.ListEmployeeActionTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.185 sec <<< FAILURE!
      testExecute(com.struts2.tutorial.action.ListEmployeeActionTest) Time elapsed: 0.998 sec <<< ERROR!
      java.lang.NullPointerException
      at org.apache.struts2.portlet.interceptor.PortletStateInterceptor.intercept(PortletStateInterceptor.java:52)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at com.struts2.tutorial.action.ListEmployeeActionTest.testExecute(ListEmployeeActionTest.java:24)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at junit.framework.TestCase.runTest(TestCase.java:168)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:243)
      at junit.framework.TestSuite.run(TestSuite.java:238)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
      at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
      at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

        Activity

        Bruce Phillips created issue -
        Lukasz Lenart made changes -
        Field Original Value New Value
        Fix Version/s 2.3.5 [ 12321274 ]
        Lukasz Lenart made changes -
        Assignee Lukasz Lenart [ lukaszlenart ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.6 [ 12323249 ]
        Fix Version/s 2.3.5 [ 12321274 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.7 [ 12323448 ]
        Fix Version/s 2.3.6 [ 12323249 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.8 [ 12323480 ]
        Fix Version/s 2.3.7 [ 12323448 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.9 [ 12323841 ]
        Fix Version/s 2.3.8 [ 12323480 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.10 [ 12323903 ]
        Fix Version/s 2.3.9 [ 12323841 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.12 [ 12324067 ]
        Fix Version/s 2.3.11 [ 12323903 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.13 [ 12324132 ]
        Fix Version/s 2.3.12 [ 12324067 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.14 [ 12324256 ]
        Fix Version/s 2.3.13 [ 12324132 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.15 [ 12324267 ]
        Fix Version/s 2.3.14 [ 12324256 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.16 [ 12324546 ]
        Fix Version/s 2.3.15 [ 12324267 ]
        Bruce Phillips made changes -
        Assignee Lukasz Lenart [ lukaszlenart ] Bruce Phillips [ bphillips ]
        Bruce Phillips made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Lukasz Lenart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Bruce Phillips
            Reporter:
            Bruce Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development