This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch action-context-boost in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/action-context-boost by this push: new 273776e WW-4789 WW-3788 Introduces helper methods to allow build fluent API 273776e is described below commit 273776e13b86ac5f208bdebcec3696370e75a1ab Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Tue Apr 7 07:59:11 2020 +0200 WW-4789 WW-3788 Introduces helper methods to allow build fluent API --- .../com/opensymphony/xwork2/ActionContext.java | 113 +++++++++++---------- .../xwork2/DefaultActionInvocation.java | 2 +- .../apache/struts2/components/ActionComponent.java | 2 +- .../struts2/util/InvocationSessionStore.java | 2 +- .../com/opensymphony/xwork2/LocaleAwareTest.java | 2 +- .../DefaultWorkflowInterceptorTest.java | 5 +- .../interceptor/ValidationErrorAwareTest.java | 5 +- ...ationInterceptorPrefixMethodInvocationTest.java | 5 +- .../util/StrutsLocalizedTextProviderTest.java | 18 ++-- .../AnnotationActionValidatorManagerTest.java | 2 +- .../xwork2/validator/ExpressionValidatorTest.java | 2 +- ...teConversionErrorFieldValidatorSupportTest.java | 2 +- .../xwork2/validator/StringValidatorTest.java | 2 +- .../validator/VisitorFieldValidatorModelTest.java | 3 +- .../validator/VisitorFieldValidatorTest.java | 2 +- .../org/apache/struts2/components/FormTest.java | 2 +- .../apache/struts2/dispatcher/DispatcherTest.java | 2 +- .../AnnotationValidationInterceptorTest.java | 2 +- .../apache/struts2/views/jsp/ActionTagTest.java | 4 +- .../org/apache/struts2/views/jsp/URLTagTest.java | 2 +- .../apache/struts2/views/jsp/ui/FormTagTest.java | 2 +- .../PackageBasedActionConfigBuilderTest.java | 5 +- .../json/JSONValidationInterceptorTest.java | 2 +- .../sitemesh/OldDecorator2NewStrutsDecorator.java | 2 +- 24 files changed, 99 insertions(+), 91 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java index 6647356..1c5739a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java @@ -21,7 +21,6 @@ package com.opensymphony.xwork2; import com.opensymphony.xwork2.conversion.impl.ConversionData; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.ValueStack; -import com.sun.org.apache.bcel.internal.generic.ACONST_NULL; import org.apache.struts2.StrutsException; import org.apache.struts2.StrutsStatics; import org.apache.struts2.dispatcher.HttpParameters; @@ -182,11 +181,18 @@ public class ActionContext implements Serializable { * Sets the action invocation (the execution state). * * @param actionInvocation the action execution state. + * @deprecated use {@link #withActionInvocation(ActionInvocation)} instead */ + @Deprecated public void setActionInvocation(ActionInvocation actionInvocation) { put(ACTION_INVOCATION, actionInvocation); } + public ActionContext withActionInvocation(ActionInvocation actionInvocation) { + put(ACTION_INVOCATION, actionInvocation); + return this; + } + /** * Gets the action invocation (the execution state). * @@ -207,6 +213,11 @@ public class ActionContext implements Serializable { put(APPLICATION, application); } + public ActionContext withApplication(Map<String, Object> application) { + put(APPLICATION, application); + return this; + } + /** * Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise. * @@ -236,6 +247,11 @@ public class ActionContext implements Serializable { put(CONVERSION_ERRORS, conversionErrors); } + public ActionContext withConversionErrors(Map<String, ConversionData> conversionErrors) { + put(CONVERSION_ERRORS, conversionErrors); + return this; + } + /** * Gets the map of conversion errors which occurred when executing the action. * @@ -289,6 +305,11 @@ public class ActionContext implements Serializable { put(ACTION_NAME, name); } + public ActionContext withActionName(String actionName) { + put(ACTION_NAME, actionName); + return this; + } + /** * Gets the name of the current Action. * @@ -316,6 +337,11 @@ public class ActionContext implements Serializable { put(PARAMETERS, parameters); } + public ActionContext withParameters(HttpParameters parameters) { + put(PARAMETERS, parameters); + return this; + } + /** * Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of * parameters otherwise. @@ -338,6 +364,11 @@ public class ActionContext implements Serializable { put(SESSION, session); } + public ActionContext withSession(Map<String, Object> session) { + put(SESSION, session); + return this; + } + /** * Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise. * @@ -358,6 +389,11 @@ public class ActionContext implements Serializable { put(VALUE_STACK, stack); } + public ActionContext withValueStack(ValueStack valueStack) { + put(VALUE_STACK, valueStack); + return this; + } + /** * Gets the OGNL value stack. * @@ -371,11 +407,18 @@ public class ActionContext implements Serializable { * Gets the container for this request * * @param cont The container + * @deprecated use {@link #withContainer(Container)} instead */ + @Deprecated public void setContainer(Container cont) { put(CONTAINER, cont); } + public ActionContext withContainer(Container container) { + put(CONTAINER, container); + return this; + } + /** * Sets the container for this request * @@ -418,24 +461,24 @@ public class ActionContext implements Serializable { return (ServletContext) get(StrutsStatics.SERVLET_CONTEXT); } - public HttpServletRequest getServletRequest() { - return (HttpServletRequest) get(StrutsStatics.HTTP_REQUEST); - } - - public HttpServletResponse getServletResponse() { - return (HttpServletResponse) get(StrutsStatics.HTTP_RESPONSE); - } - public ActionContext withServletContext(ServletContext servletContext) { put(StrutsStatics.SERVLET_CONTEXT, servletContext); return this; } + public HttpServletRequest getServletRequest() { + return (HttpServletRequest) get(StrutsStatics.HTTP_REQUEST); + } + public ActionContext withServletRequest(HttpServletRequest request) { put(StrutsStatics.HTTP_REQUEST, request); return this; } + public HttpServletResponse getServletResponse() { + return (HttpServletResponse) get(StrutsStatics.HTTP_RESPONSE); + } + public ActionContext withServletResponse(HttpServletResponse response) { put(StrutsStatics.HTTP_RESPONSE, response); return this; @@ -445,6 +488,11 @@ public class ActionContext implements Serializable { return (PageContext) get(StrutsStatics.PAGE_CONTEXT); } + public ActionContext withPageContext(PageContext pageContext) { + put(StrutsStatics.PAGE_CONTEXT, pageContext); + return this; + } + public ActionMapping getActionMapping() { return (ActionMapping) get(StrutsStatics.ACTION_MAPPING); } @@ -454,37 +502,7 @@ public class ActionContext implements Serializable { return this; } - public ActionContext withApplication(Map<String, Object> application) { - put(APPLICATION, application); - return this; - } - - public ActionContext withSession(Map<String, Object> session) { - put(SESSION, session); - return this; - } - - public ActionContext withParameters(HttpParameters parameters) { - put(PARAMETERS, parameters); - return this; - } - - public ActionContext withActionName(String actionName) { - put(ACTION_NAME, actionName); - return this; - } - - public ActionContext withValueStack(ValueStack valueStack) { - put(VALUE_STACK, valueStack); - return this; - } - - public ActionContext withPageContext(PageContext pageContext) { - put(StrutsStatics.PAGE_CONTEXT, pageContext); - return this; - } - - public ActionContext withPageContextOrClear(ActionContext actionContext) { + public ActionContext usePageContextOrClear(ActionContext actionContext) { if (actionContext == null) { put(StrutsStatics.PAGE_CONTEXT, null); } else { @@ -493,19 +511,4 @@ public class ActionContext implements Serializable { return this; } - public ActionContext withConversionErrors(Map<String, ConversionData> conversionErrors) { - put(CONVERSION_ERRORS, conversionErrors); - return this; - } - - public ActionContext withContainer(Container container) { - put(CONTAINER, container); - return this; - } - - public ActionContext withActionInvocation(ActionInvocation actionInvocation) { - put(ACTION_INVOCATION, actionInvocation); - return this; - } - } diff --git a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java index c256ad5..215d568 100644 --- a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java +++ b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java @@ -385,7 +385,7 @@ public class DefaultActionInvocation implements ActionInvocation { ActionContext actionContext = ActionContext.getContext(); if (actionContext != null) { - actionContext.setActionInvocation(this); + actionContext.withActionInvocation(this); } createAction(contextMap); diff --git a/core/src/main/java/org/apache/struts2/components/ActionComponent.java b/core/src/main/java/org/apache/struts2/components/ActionComponent.java index 3862366..727a216 100644 --- a/core/src/main/java/org/apache/struts2/components/ActionComponent.java +++ b/core/src/main/java/org/apache/struts2/components/ActionComponent.java @@ -293,7 +293,7 @@ public class ActionComponent extends ContextBean { // set the old stack back on the request req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); if (inv != null) { - ActionContext.getContext().setActionInvocation(inv); + ActionContext.getContext().withActionInvocation(inv); } } diff --git a/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java b/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java index 795022c..93a5ca1 100644 --- a/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java +++ b/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java @@ -64,7 +64,7 @@ public class InvocationSessionStore { savedInvocation .getInvocationContext() - .withPageContextOrClear(previousActionContext) + .usePageContextOrClear(previousActionContext) .withValueStack(savedInvocation.getStack()) .bind(); } diff --git a/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java b/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java index f1d44ad..c43bd6e 100644 --- a/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java @@ -68,7 +68,7 @@ public class LocaleAwareTest extends XWorkTestCase { loadConfigurationProviders(configurationProvider, new MockConfigurationProvider()); ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack(); - stack.getActionContext().setContainer(container); + stack.getActionContext().withContainer(container); ActionContext.of(stack.getContext()).bind(); } } diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java index 6ac2129..d2a0f83 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java @@ -183,8 +183,9 @@ public class DefaultWorkflowInterceptorTest extends XWorkTestCase { EasyMock.replay(action); EasyMock.replay(proxy); - ActionContext actionContext = ActionContext.of(new HashMap<>()).bind(); - actionContext.setActionInvocation(invocation); + ActionContext.of(new HashMap<>()) + .withActionInvocation(invocation) + .bind(); } @Override diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationErrorAwareTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationErrorAwareTest.java index 06586eb..79a126b 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationErrorAwareTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationErrorAwareTest.java @@ -87,8 +87,9 @@ public class ValidationErrorAwareTest extends XWorkTestCase { EasyMock.replay(action); EasyMock.replay(proxy); - ActionContext context = ActionContext.of(new HashMap<>()).bind(); - context.setActionInvocation(invocation); + ActionContext.of(new HashMap<>()) + .withActionInvocation(invocation) + .bind(); } @Override diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java index f2dfe59..7e39be0 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java @@ -101,7 +101,8 @@ public class ValidationInterceptorPrefixMethodInvocationTest extends XWorkTestCa EasyMock.replay(action); EasyMock.replay(proxy); - ActionContext context = ActionContext.of(new HashMap<>()).bind(); - context.setActionInvocation(invocation); + ActionContext.of(new HashMap<>()) + .withActionInvocation(invocation) + .bind(); } } diff --git a/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java b/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java index 7429082..7efb8fd 100644 --- a/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java @@ -63,8 +63,9 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); - ActionContext.getContext().getValueStack().push(action); + ActionContext.getContext() + .withActionInvocation((ActionInvocation) mockActionInvocation.proxy()) + .getValueStack().push(action); String message = action.getText("barObj.title"); assertEquals("Title:", message); @@ -92,7 +93,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()); ActionContext.getContext().getValueStack().push(action); ActionContext.getContext().getValueStack().push(action.getModel()); @@ -112,8 +113,9 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); - ActionContext.getContext().getValueStack().push(action); + ActionContext.getContext() + .withActionInvocation((ActionInvocation) mockActionInvocation.proxy()) + .getValueStack().push(action); String message = action.getText("bean.name"); String foundBean2 = action.getText("bean2.name"); @@ -163,7 +165,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("hashCode", 0); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()); ActionContext.getContext().getValueStack().push(action); ActionContext.getContext().getValueStack().push(action.getModel()); @@ -175,7 +177,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Action action = new ModelDrivenAction2(); Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()); String message = localizedTextProvider.findText(ModelDrivenAction2.class, "test.foo", Locale.getDefault()); assertEquals("Foo!", message); @@ -186,7 +188,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()); String message = localizedTextProvider.findText(ModelDrivenAction2.class, "package.properties", Locale.getDefault()); assertEquals("It works!", message); diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java index 62a5e1e..e915de0 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java @@ -82,7 +82,7 @@ public class AnnotationActionValidatorManagerTest extends XWorkTestCase { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); tpf = container.getInstance(TextProviderFactory.class); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/ExpressionValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/ExpressionValidatorTest.java index ac4ed2a..500824c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/ExpressionValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/ExpressionValidatorTest.java @@ -140,7 +140,7 @@ public class ExpressionValidatorTest extends XWorkTestCase { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); tpf = container.getInstance(TextProviderFactory.class); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/RepopulateConversionErrorFieldValidatorSupportTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/RepopulateConversionErrorFieldValidatorSupportTest.java index 5b5075a..bcb0281 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/RepopulateConversionErrorFieldValidatorSupportTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/RepopulateConversionErrorFieldValidatorSupportTest.java @@ -88,7 +88,7 @@ public class RepopulateConversionErrorFieldValidatorSupportTest extends XWorkTes ValueStack stack = ActionContext.getContext().getValueStack(); MockActionInvocation invocation = new MockActionInvocation(); invocation.setStack(stack); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); String[] conversionErrorValue = new String[] { "some value" }; Map<String, ConversionData> conversionErrors = ActionContext.getContext().getConversionErrors(); diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/StringValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/StringValidatorTest.java index 27f695a..0aa41cd 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/StringValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/StringValidatorTest.java @@ -218,7 +218,7 @@ public class StringValidatorTest extends XWorkTestCase { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); tpf = container.getInstance(TextProviderFactory.class); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java index f33569e..d88fa27 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java @@ -61,8 +61,7 @@ public class VisitorFieldValidatorModelTest extends XWorkTestCase { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); - + ActionContext.getContext().withActionInvocation(invocation); } public void testModelFieldErrorsAddedWithoutFieldPrefix() throws Exception { diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java index fd1d3a0..69e4180 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java @@ -69,7 +69,7 @@ public class VisitorFieldValidatorTest extends XWorkTestCase { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); } public void testArrayValidation() throws Exception { diff --git a/core/src/test/java/org/apache/struts2/components/FormTest.java b/core/src/test/java/org/apache/struts2/components/FormTest.java index 1442f96..649747a 100644 --- a/core/src/test/java/org/apache/struts2/components/FormTest.java +++ b/core/src/test/java/org/apache/struts2/components/FormTest.java @@ -110,6 +110,6 @@ public class FormTest extends AbstractUITagTest { ((DefaultActionMapper) container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true"); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); } } diff --git a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java index 1669fc6..c336fc6 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java @@ -368,7 +368,7 @@ public class DispatcherTest extends StrutsInternalTestCase { Dispatcher du = initDispatcher(Collections.<String, String>emptyMap()); MockActionInvocation mai = new MockActionInvocation(); - ActionContext.getContext().setActionInvocation(mai); + ActionContext.getContext().withActionInvocation(mai); MockActionProxy actionProxy = new MockActionProxy(); actionProxy.setInvocation(mai); diff --git a/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java index fc82253..ba70d88 100644 --- a/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java +++ b/core/src/test/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptorTest.java @@ -45,7 +45,7 @@ public class AnnotationValidationInterceptorTest extends StrutsInternalTestCase mockActionInvocation.matchAndReturn("getAction", test); mockActionInvocation.expect("invoke"); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()); } public void testShouldNotSkip() throws Exception { diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java index 627f0a5..74765bf 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java @@ -188,7 +188,7 @@ public class ActionTagTest extends AbstractTagTest { tag.setNamespace(""); tag.setName("testActionTagAction"); tag.setExecuteResult(true); - ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInv.proxy()); + ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInv.proxy()); ActionInvocation oldInvocation = ActionContext.getContext().getActionInvocation(); assertNotNull(oldInvocation); @@ -199,7 +199,7 @@ public class ActionTagTest extends AbstractTagTest { ActionComponent component = (ActionComponent) tag.getComponent(); tag.doEndTag(); - assertTrue(oldInvocation == ActionContext.getContext().getActionInvocation()); + assertSame(oldInvocation, ActionContext.getContext().getActionInvocation()); } public void testIngoreContextParamsFalse() throws Exception { diff --git a/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java index 50f7811..c1b9c8e 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java @@ -563,7 +563,7 @@ public class URLTagTest extends AbstractUITagTest { .bind(); // Make sure we have an action invocation available - ActionContext.getContext().setActionInvocation(new DefaultActionInvocation(null, true)); + ActionContext.getContext().withActionInvocation(new DefaultActionInvocation(null, true)); DefaultActionProxyFactory apFactory = new DefaultActionProxyFactory(); apFactory.setContainer(container); ActionProxy ap = apFactory.createActionProxy("/", "hello", null, null); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java index 4ff5b1f..535e42f 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java @@ -354,7 +354,7 @@ public class FormTagTest extends AbstractUITagTest { EasyMock.replay(invocation); EasyMock.replay(proxy); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); } /** diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java index 2d647b3..6d0abd4 100644 --- a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java +++ b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java @@ -89,8 +89,9 @@ public class PackageBasedActionConfigBuilderTest extends TestCase { @Override public void setUp() throws Exception { super.setUp(); - ActionContext context = ActionContext.of(new HashMap<>()).bind(); - context.setContainer(new DummyContainer()); + ActionContext.of(new HashMap<>()) + .withContainer(new DummyContainer()) + .bind(); } public void testActionPackages() throws MalformedURLException { diff --git a/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java b/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java index a4fd58d..753ff11 100644 --- a/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java +++ b/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java @@ -197,7 +197,7 @@ public class JSONValidationInterceptorTest extends StrutsTestCase { context.put(StrutsStatics.SERVLET_CONTEXT, servletContext); invocation = new MockActionInvocation(); - ActionContext.getContext().setActionInvocation(invocation); + ActionContext.getContext().withActionInvocation(invocation); invocation.setAction(action); invocation.setInvocationContext(context); MockActionProxy proxy = new MockActionProxy(); diff --git a/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java b/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java index 9cdc9fc..f5a0cd1 100644 --- a/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java +++ b/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java @@ -100,7 +100,7 @@ public abstract class OldDecorator2NewStrutsDecorator extends BaseWebAppDecorato // put in a dummy ActionSupport so basic functionality still works ActionSupport action = new ActionSupport(); vs.push(action); - ctx.setActionInvocation(new DummyActionInvocation(action)); + ctx.withActionInvocation(new DummyActionInvocation(action)); } }