[
https://issues.apache.org/jira/browse/WW-3442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13250674#comment-13250674
]
Lukasz Lenart edited comment on WW-3442 at 4/10/12 2:09 PM:
------------------------------------------------------------
Added additional initSession() method to StrutsTestCase, is it sufficient ?
{code:java}
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(new HashMap<String,
Object>(request.getParameterMap()));
initSession(actionContext);
initPortletContext(actionContext);
applyAdditionalParams(actionContext);
// set the action context to the one used by the proxy
ActionContext.setContext(actionContext);
}
protected void initSession(ActionContext actionContext) {
Map<String, Object> session = actionContext.getSession();
if (session == null) {
actionContext.setSession(new HashMap<String, Object>());
}
}
{code}
was (Author: lukaszlenart):
Added additional initSession() method to StrutsTestCase, is it sufficient ?
{code:java}
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(new HashMap<String,
Object>(request.getParameterMap()));
initSession(actionContext);
initPortletContext(actionContext);
applyAdditionalParams(actionContext);
// set the action context to the one used by the proxy
ActionContext.setContext(actionContext);
}
protected void initSession(ActionContext actionContext) {
Map<String, Object> session = actionContext.getSession();
if (session == null) {
actionContext.setSession(new HashMap<String, Object>());
}
}
{code}
> StrutsTestCase does not initialise session map
> ----------------------------------------------
>
> Key: WW-3442
> URL: https://issues.apache.org/jira/browse/WW-3442
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.1.8.1
> Reporter: Paul Grove
> Assignee: Maurizio Cucchiara
> Fix For: 2.3.3
>
>
> In our unit tests we were setting http session object attributes but these we
> never getting copied into the action session map as it was not being
> initialised correctly in the getActionProxy method.
> By adding the following code at the end of the method test worked correctly
> ActionContext.getContext().setSession(new HashMap<String, Object>());
--
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