[
https://issues.apache.org/jira/browse/WW-3733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13178197#comment-13178197
]
Hudson commented on WW-3733:
----------------------------
Integrated in Struts2 #399 (See [https://builds.apache.org/job/Struts2/399/])
WW-3733 - adds missing PortletContext to ActionContext to avoid NPE during
PortletResult initialisation
lukaszlenart :
Files :
* /struts/struts2/trunk/plugins/junit/pom.xml
*
/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
*
/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/StrutsTestCaseTest.java
* /struts/struts2/trunk/plugins/portlet/pom.xml
* /struts/struts2/trunk/pom.xml
> Problem With Struts 2.3.1 and Testing Struts Portlet
> ----------------------------------------------------
>
> Key: WW-3733
> URL: https://issues.apache.org/jira/browse/WW-3733
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Portlet
> Affects Versions: 2.3.1
> Reporter: Bruce Phillips
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 2.3.2
>
>
> I'm upgrading a Struts 2 portlet application from 2.2.3.1 to 2.3.1. A test
> of my Action class that extends StrutsSpringTestCase that passed when using
> 2.2.3.1 now fails when using version 2.3.1.
> I've created a simple Struts 2 portlet example application to demonstrate the
> issue. You can download the zipped example here:
> http://www.brucephillips.name/struts/struts2helloworldportlet.zip
> Unzip the download.
> In a terminal window navigate to the project's root folder.
> run mvn clean test
> The test will pass.
> Open the pom.xml and change the struts.version property to 2.3.1 and save
> your change
> run mvn clean test
> The test will now fail.
> Here is part of the error message in the test report:
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.314 sec <<<
> FAILURE!
> testExecute(com.struts2.tutorial.action.DefaultActionTest) Time elapsed:
> 1.252 sec <<< ERROR!
> Error creating bean with name
> 'org.apache.struts2.portlet.result.PortletResult': Instantiation of bean
> failed; nested exception is
> org.springframework.beans.BeanInstantiationException: Could not instantiate
> bean class [org.apache.struts2.portlet.result.PortletResult]: Constructor
> threw exception; nested exception is java.lang.NullPointerException - action
> -
> file:/Users/bphillips/eclipse_workspaces/kucard/Struts2HelloWorldPortlet/target/classes/struts.xml:11:74
>
> at
> com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:224)
>
> I get the same error if the project is using the Struts Spring plugin or not.
> I think the error is in the Struts unit testing framework as I can still run
> the project successfully. For example after updating the struts.version in
> pom.xml enter this command in the terminal window:
> mvn jetty:run
> When you see the message [INFO] Started Jetty Server go to this URL in your
> web browser: http://localhost:8080/struts2helloworldportlet/pluto/index.jsp
> and you should see the example portlet.
> _____________________________________
> Could you register an issue ?
> Looks like the problem is with PortletContext which it is not defined.
> To solve your problem override the method as below in the
> DefaultActionTest class:
> {code}
> @Override
> protected ActionProxy getActionProxy(String uri) {
> ActionProxy actionProxy = super.getActionProxy(uri);
> ActionContext.getContext().put(StrutsStatics.STRUTS_PORTLET_CONTEXT,
> new MockPortletContext());
> return actionProxy;
> }
> {code}
> Thanks in advance
> --
> Ćukasz
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira