mirror of
https://github.com/apache/struts.git
synced 2026-08-06 23:27:07 +00:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user