WW-3442 adds Session initialisation method to solve problem with missing session and allow to initialise session on its own in test cases

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1311951 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2012-04-10 19:33:51 +00:00
parent ecc0e56440
commit 5c15306366
@@ -149,17 +149,23 @@ public abstract class StrutsTestCase extends XWorkTestCase {
return proxy;
}
private void initActionContext(ActionContext actionContext) {
actionContext.setParameters(new HashMap(request.getParameterMap()));
initMockPortletContext(actionContext);
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);
}
private void initMockPortletContext(ActionContext actionContext) {
protected void initSession(ActionContext actionContext) {
Map<String, Object> session = actionContext.getSession();
if (session == null) {
actionContext.setSession(new HashMap<String, Object>());
}
}
protected void initPortletContext(ActionContext actionContext) {
try {
ClassLoaderUtil.loadClass("javax.portlet.PortletContext", getClass());
Class mockClazz = ClassLoaderUtil.loadClass("org.springframework.mock.web.portlet.MockPortletContext", getClass());