You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2013/01/27 19:45:12 UTC

[jira] [Updated] (WW-3724) HttpSession Map not set on invocation ActionContext in StrutsTestCase during getActionProxy

     [ https://issues.apache.org/jira/browse/WW-3724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3724:
------------------------------

    Description: 
I expected that when I set attributes on the MockHttpSession from MockHttpRequest in StrutsTestCase they would be available in the invocation ActionContext.

Instead, getActionProxy does not set a SessionMap on the invocation ActionContext. This affects testing of Actions that use SessionAware and other ServletConfigInterceptor Interfaces.

Workaround:
{code:java}
public void testSomething() throws Exception {     
  ActionProxy proxy = getActionProxy("/something");
  proxy.getInvocation().getInvocationContext().setSession(new SessionMap(request));
}
{code}

Tiny patch to fix it:
{noformat}
struts-2.2.3.1/src/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
39a40
> import org.apache.struts2.dispatcher.SessionMap;
141a143
>         invocationContext.setSession(new SessionMap(request));
{noformat}

  was:
I expected that when I set attributes on the MockHttpSession from MockHttpRequest in StrutsTestCase they would be available in the invocation ActionContext.

Instead, getActionProxy does not set a SessionMap on the invocation ActionContext. This affects testing of Actions that use SessionAware and other ServletConfigInterceptor Interfaces.

Workaround:
public void testSomething() throws Exception {     
  ActionProxy proxy = getActionProxy("/something");
  proxy.getInvocation().getInvocationContext().setSession(new SessionMap(request));
}

Tiny patch to fix it:
struts-2.2.3.1/src/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
39a40
> import org.apache.struts2.dispatcher.SessionMap;
141a143
>         invocationContext.setSession(new SessionMap(request));

    
> HttpSession Map not set on invocation ActionContext in StrutsTestCase during getActionProxy
> -------------------------------------------------------------------------------------------
>
>                 Key: WW-3724
>                 URL: https://issues.apache.org/jira/browse/WW-3724
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Unit Tests
>    Affects Versions: 2.2.3.1
>            Reporter: Donald Abrams
>            Priority: Minor
>              Labels: junit
>             Fix For: 2.3.9
>
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> I expected that when I set attributes on the MockHttpSession from MockHttpRequest in StrutsTestCase they would be available in the invocation ActionContext.
> Instead, getActionProxy does not set a SessionMap on the invocation ActionContext. This affects testing of Actions that use SessionAware and other ServletConfigInterceptor Interfaces.
> Workaround:
> {code:java}
> public void testSomething() throws Exception {     
>   ActionProxy proxy = getActionProxy("/something");
>   proxy.getInvocation().getInvocationContext().setSession(new SessionMap(request));
> }
> {code}
> Tiny patch to fix it:
> {noformat}
> struts-2.2.3.1/src/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
> 39a40
> > import org.apache.struts2.dispatcher.SessionMap;
> 141a143
> >         invocationContext.setSession(new SessionMap(request));
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira