WW-5304 Drops deprecated methods and fields in ActionContext

This commit is contained in:
Lukasz Lenart
2023-04-09 16:00:03 +02:00
parent 7f3c1c2944
commit f0f9e42fa9
82 changed files with 417 additions and 562 deletions
@@ -89,7 +89,7 @@ public class PackageBasedActionConfigBuilderTest extends TestCase {
@Override
public void setUp() throws Exception {
super.setUp();
ActionContext.of(new HashMap<>())
ActionContext.of()
.withContainer(new DummyContainer())
.bind();
}
@@ -359,7 +359,7 @@ public class EmbeddedJSPResultTest extends TestCase {
EasyMock.replay(container);
ActionContext.of(new HashMap<>())
ActionContext.of()
.withParameters(HttpParameters.create(params).build())
.withServletRequest(request)
.withServletResponse(response)
@@ -50,8 +50,9 @@ public class TokenTest extends AbstractTest {
super.setUp();
this.tag = new Token(stack, request, response);
ActionContext actionContext = ActionContext.of(new HashMap<>()).bind();
actionContext.setSession(new HashMap<>());
ActionContext.of()
.withSession(new HashMap<>())
.bind();
}
@Override
@@ -136,7 +136,7 @@ public abstract class StrutsJUnit4TestCase<T> extends XWorkJUnit4TestCase {
}
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build());
actionContext.withParameters(HttpParameters.create(request.getParameterMap()).build());
initSession(actionContext);
// set the action context to the one used by the proxy
ActionContext.bind(actionContext);
@@ -121,7 +121,7 @@ public class StrutsRestTestCase<T> extends StrutsJUnit4TestCase<T> {
ActionContext invocationContext = proxy.getInvocation().getInvocationContext();
invocationContext.getContextMap().put(ServletActionContext.ACTION_MAPPING, mapping);
invocationContext.setParameters(HttpParameters.create(request.getParameterMap()).build());
invocationContext.withParameters(HttpParameters.create(request.getParameterMap()).build());
// set the action context to the one used by the proxy
ActionContext.bind(invocationContext);
@@ -119,7 +119,7 @@ public abstract class StrutsTestCase extends XWorkTestCase {
}
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build());
actionContext.withParameters(HttpParameters.create(request.getParameterMap()).build());
initSession(actionContext);
applyAdditionalParams(actionContext);
// set the action context to the one used by the proxy
@@ -136,11 +136,9 @@ public class OsgiConfigurationProvider implements PackageProvider, BundleListene
/**
* Creates a new empty ActionContext instance and binds it to the current thread.
*
* @return
*/
protected ActionContext createActionContext() {
return ActionContext.of(new HashMap<>()).bind();
return ActionContext.of().bind();
}
/**
@@ -45,7 +45,7 @@ import org.springframework.mock.web.MockServletContext;
* Changes: This is a copy of org.apache.struts2.StrutsTestCase from the Struts 2 junit-plugin, kept in
* in the same package org.apache.struts2 and renamed. Removed some unused imports, made
* imports alphabetical and made some whitespace changes and modified a comment.
* The StrutsTestCasePortletTests is needed in order to break a dependency-cycle between the
* The StrutsTestCasePortletTests is needed in order to break a dependency-cycle between the
* portlet-plugin and junit-plugin with respect to StrutsTestCase.
*
* Note: If the junit-plugin StrutsTestCase is updated/modified, it may be appropriate to update
@@ -130,7 +130,7 @@ public abstract class StrutsTestCasePortletTests extends XWorkTestCase {
}
protected void initActionContext(ActionContext actionContext) {
actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build());
actionContext.withParameters(HttpParameters.create(request.getParameterMap()).build());
initSession(actionContext);
applyAdditionalParams(actionContext);
// set the action context to the one used by the proxy
@@ -139,7 +139,7 @@ public abstract class StrutsTestCasePortletTests extends XWorkTestCase {
protected void initSession(ActionContext actionContext) {
if (actionContext.getSession() == null) {
actionContext.setSession(new HashMap<>());
actionContext.withSession(new HashMap<>());
request.setSession(new MockHttpSession(servletContext));
}
}
@@ -65,9 +65,10 @@ public class PortletResultTest extends MockObjectTestCase implements StrutsStati
Map<String, Object> sessionMap = new HashMap<>();
ActionContext actionContext = ActionContext.of(new HashMap<>()).bind();
actionContext.setSession(sessionMap);
actionContext.setParameters(HttpParameters.create().build());
ActionContext actionContext = ActionContext.of()
.withSession(sessionMap)
.withParameters(HttpParameters.create().build())
.bind();
actionContext.put(STRUTS_PORTLET_CONTEXT, mockCtx.proxy());
mockProxy.stubs().method("getNamespace").will(returnValue("/test"));
@@ -160,7 +161,7 @@ public class PortletResultTest extends MockObjectTestCase implements StrutsStati
ActionContext ctx = ActionContext.getContext();
Map<String, Object> session = new HashMap<>();
ctx.setSession(session);
ctx.withSession(session);
ctx.put(REQUEST, mockRequest.proxy());
ctx.put(RESPONSE, mockResponse.proxy());
@@ -69,7 +69,7 @@ public class PortletUrlHelperTest extends TestCase {
modeNamespaceMap.put("edit", "/edit");
modeNamespaceMap.put("help", "/help");
ActionContext actionContext = ActionContext.of(new HashMap<>()).bind();
ActionContext actionContext = ActionContext.of().bind();
actionContext.put(REQUEST, renderRequest);
actionContext.put(RESPONSE, renderResponse);
actionContext.put(PHASE, PortletPhase.RENDER_PHASE);
@@ -58,7 +58,7 @@ public class ContentTypeHandlerManagerTest extends TestCase {
mockResponse = new MockHttpServletResponse();
mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("GET");
ActionContext actionContext = ActionContext.of(new HashMap<>()).bind();
ActionContext actionContext = ActionContext.of().bind();
actionContext.withServletRequest(mockRequest);
actionContext.withServletResponse(mockResponse);
@@ -135,7 +135,7 @@ public class ContentTypeHandlerManagerTest extends TestCase {
C.eq(ContentTypeHandlerManager.STRUTS_REST_HANDLER_OVERRIDE_PREFIX+"xml")), "xmlOverride");
mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class),
C.eq(ContentTypeHandlerManager.STRUTS_REST_HANDLER_OVERRIDE_PREFIX+"json")), null);
DefaultContentTypeHandlerManager mgr = new DefaultContentTypeHandlerManager();
mgr.setContainer((Container) mockContainer.proxy());
@@ -51,7 +51,7 @@ public class RestWorkflowInterceptorTest extends TestCase {
}, null);
wf.setContentTypeHandlerManager((ContentTypeHandlerManager) mockContentTypeHandlerManager.proxy());
ActionContext.of(new HashMap<>())
ActionContext.of()
.withActionMapping(new ActionMapping())
.bind();
@@ -51,7 +51,7 @@ public class JuneauXmlHandlerTest extends XWorkTestCase {
"</object>";
handler = new JuneauXmlHandler();
ai = new MockActionInvocation();
ActionContext context = ActionContext.of(new HashMap<>()).withLocale(Locale.US);
ActionContext context = ActionContext.of().withLocale(Locale.US);
((MockActionInvocation) ai).setInvocationContext(context);
}
@@ -95,4 +95,4 @@ public class JuneauXmlHandlerTest extends XWorkTestCase {
.containsExactly("Adam", "Ewa");
}
}
}
@@ -56,7 +56,7 @@ public class XStreamHandlerTest extends XWorkTestCase {
handler = new XStreamHandler();
ai = new MockActionInvocation();
ActionSupport action = new ActionSupport();
ActionContext context = ActionContext.of(new HashMap<>()).withLocale(Locale.US);
ActionContext context = ActionContext.of().withLocale(Locale.US);
ai.setInvocationContext(context);
ai.setAction(action);
}
@@ -135,11 +135,10 @@ public class ActionsFromSpringTest extends XWorkTestCase {
params.put("exposeProxy", "true");
params.put("issueId", "S2-047");
HashMap<String, Object> extraContext = new HashMap<>();
extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build());
ActionContext extraContext = ActionContext.of().withParameters(HttpParameters.create(params).build());
ActionProxy proxy = actionProxyFactory.createActionProxy(null,
"chaintoAOPedTestSubBeanAction", null, extraContext);
"chaintoAOPedTestSubBeanAction", null, extraContext.getContextMap());
// when
proxy.execute();
@@ -110,7 +110,7 @@ public class ActionAutowiringInterceptorTest extends XWorkTestCase {
}
public void testIfApplicationContextIsNullThenBeanWillNotBeWiredUp() throws Exception {
ActionContext.of(new HashMap<>())
ActionContext.of()
.withApplication(new HashMap<>())
.bind();
@@ -76,7 +76,7 @@ import org.apache.tiles.request.servlet.ServletUtil;
*
*
* <!-- START SNIPPET: tilesconfig -->
* You have to configure tiles itself. Therefore you can add <code>tiles.xml</code> either
* You have to configure tiles itself. Therefore you can add <code>tiles.xml</code> either
* to resources or WEB-INF. You may also use annotations like {@link TilesDefinition}.
*
* <!-- END SNIPPET: tilesconfig -->
@@ -109,7 +109,7 @@ public class TilesResult extends ServletDispatcherResult {
StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
TilesDefinition tilesDefinition = null;
Object action = invocation.getAction();
String actionName = invocation.getInvocationContext().getName();
String actionName = invocation.getInvocationContext().getActionName();
if (StringUtils.isEmpty(location)) {
LOG.trace("location not set -> action must have one @TilesDefinition");