[ 
https://issues.apache.org/jira/browse/WW-5095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17235934#comment-17235934
 ] 

ASF subversion and git services commented on WW-5095:
-----------------------------------------------------

Commit 5186d348d5710971bf4edc59e353e17158ca5e4a in struts's branch 
refs/heads/master from Lukasz Lenart
[ https://gitbox.apache.org/repos/asf?p=struts.git;h=5186d34 ]

Merge pull request #447 from apache/WW-5095-cherry-pick

[WW-5095] Cherry picks changes from 2-5-x branch

> Junit plugin does not push ACTION_MAPPING into the context resulting in NPE
> ---------------------------------------------------------------------------
>
>                 Key: WW-5095
>                 URL: https://issues.apache.org/jira/browse/WW-5095
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JUnit
>    Affects Versions: 2.5.25
>            Reporter: Paul Zepernick
>            Priority: Major
>             Fix For: 2.5.26, 2.6
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> org.apache.struts2.StrutsJUnit4TestCase is not pushing the ACTION_MAPPING 
> into the context which results in the following NPE when testing a Struts 
> action and using the struts-rest plugin.
> {noformat}
>  java.lang.NullPointerException
>       at 
> org.apache.struts2.rest.RestWorkflowInterceptor.doIntercept(RestWorkflowInterceptor.java:205){noformat}
> The issue can be replicated with this sample github project
> [https://github.com/zepernick/struts25-rest-junit]
> The current work around is to override the 
> org.apache.struts2.StrutsJUnit4TestCase#getActionProxy and add
> {code:java}
>         ActionMapping mapping = getActionMapping(request);
>         
> ServletActionContext.getContext().put(ServletActionContext.ACTION_MAPPING, 
> mapping);
> {code}
> Also see this discussion on the struts mailing list
> http://struts.1045723.n5.nabble.com/NPE-when-running-unit-test-with-struts-rest-plugin-tp5724974p5724986.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to