From b4bc5dcf75240cb01bf6ac8fb17bbd14b2679216 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 8 Jul 2020 08:49:05 +0200 Subject: [PATCH 1/3] WW-5078 Removes support for DTDs --- .../xwork2/config/ConfigurationManager.java | 4 +- .../providers/XmlConfigurationProvider.java | 35 +--- .../StrutsXmlConfigurationProvider.java | 9 + core/src/main/resources/xwork-default.xml | 11 +- .../xwork2/ActionInvocationTest.java | 52 +++--- .../opensymphony/xwork2/ChainResultTest.java | 15 +- .../xwork2/DefaultActionInvocationTest.java | 22 +-- .../xwork2/DefaultActionProxyTest.java | 4 +- .../xwork2/DefaultClasstTest.java | 13 +- .../opensymphony/xwork2/LocaleAwareTest.java | 5 +- .../xwork2/ProxyInvocationTest.java | 13 +- .../xwork2/WildCardResultTest.java | 3 +- .../xwork2/config/ConfigurationTest.java | 66 +++---- .../providers/ConfigurationTestBase.java | 7 +- ...roviderInterceptorParamOverridingTest.java | 4 +- ...erInterceptorStackParamOverridingTest.java | 92 +++++----- ...ConfigurationProviderInterceptorsTest.java | 33 ++-- .../XmlConfigurationProviderTest.java | 161 +++++++++--------- .../interceptor/AliasInterceptorTest.java | 25 ++- .../ChainingInterceptorWithConfigTest.java | 44 +++-- .../ParametersInterceptorTest.java | 69 +++++--- .../AnnotationWorkflowInterceptorTest.java | 37 ++-- .../ognl/SecurityMemberAccessProxyTest.java | 15 +- .../xwork2/spring/ActionsFromSpringTest.java | 38 +++-- .../xwork2/spring/SpringProxyUtilTest.java | 27 +-- .../ActionAutowiringInterceptorTest.java | 11 +- .../xwork2/util/MyBeanActionTest.java | 4 +- .../util/StrutsLocalizedTextProviderTest.java | 125 +++++++------- .../DoubleRangeFieldValidatorTest.java | 4 +- .../validator/IntRangeValidatorTest.java | 5 +- .../validator/LongRangeValidatorTest.java | 5 +- .../validator/ModelDrivenValidationTest.java | 11 +- .../validator/ShortRangeValidatorTest.java | 5 +- .../validator/SimpleActionValidationTest.java | 17 +- .../validator/ValidatorAnnotationTest.java | 7 +- .../PrefixBasedActionProxyFactoryTest.java | 68 ++++---- .../loadorder1/xwork-test-load-order.xml | 11 +- .../loadorder2/xwork-test-load-order.xml | 11 +- .../loadorder3/xwork-test-load-order.xml | 11 +- .../xwork2/config/providers/xwork- test.xml | 22 ++- .../xwork-include-after-package-2.xml | 12 +- .../providers/xwork-include-after-package.xml | 12 +- .../xwork-include-before-package-2.xml | 12 +- .../xwork-include-before-package.xml | 12 +- .../config/providers/xwork-include-parent.xml | 12 +- .../providers/xwork-test-action-invalid.xml | 12 +- ...rk-test-actions-packagedefaultclassref.xml | 12 +- .../config/providers/xwork-test-actions.xml | 22 ++- .../providers/xwork-test-allowed-methods.xml | 12 +- .../providers/xwork-test-bad-inheritance.xml | 12 +- .../providers/xwork-test-basic-packages.xml | 20 +-- .../providers/xwork-test-default-package.xml | 12 +- .../xwork-test-defaultclassref-package.xml | 14 +- .../xwork-test-envs-substitution.xml | 12 +- .../xwork-test-exception-mappings.xml | 12 +- .../xwork-test-global-result-inheritence.xml | 86 +++++----- .../providers/xwork-test-include-wildcard.xml | 12 +- .../xwork-test-interceptor-defaultref.xml | 12 +- .../xwork-test-interceptor-inheritance.xml | 14 +- ...work-test-interceptor-param-overriding.xml | 11 +- .../xwork-test-interceptor-params.xml | 12 +- ...est-interceptor-stack-param-overriding.xml | 88 +++++----- .../xwork-test-interceptors-basic.xml | 12 +- .../xwork-test-interceptors-spring.xml | 14 +- .../providers/xwork-test-multilevel.xml | 12 +- .../xwork-test-package-inheritance.xml | 12 +- .../config/providers/xwork-test-reload.xml | 12 +- .../xwork-test-result-inheritance.xml | 12 +- .../providers/xwork-test-result-names.xml | 12 +- .../providers/xwork-test-result-types.xml | 103 ++++++----- .../config/providers/xwork-test-results.xml | 12 +- .../providers/xwork-test-wildcard-1.xml | 12 +- .../providers/xwork-test-wildcard-2.xml | 12 +- .../providers/xwork-test-wildcard-include.xml | 12 +- .../xwork-unknownhandler-stack-empty.xml | 12 +- .../providers/xwork-unknownhandler-stack.xml | 12 +- .../xwork2/spring/actionContext-xwork.xml | 8 +- .../xwork2/spring/xwork-autowire.xml | 24 ++- core/src/test/resources/includeTest.xml | 12 +- core/src/test/resources/xwork - jar.jar | Bin 2538 -> 2063 bytes core/src/test/resources/xwork - zip.zip | Bin 2509 -> 2572 bytes .../test/resources/xwork-class-param-test.xml | 11 +- core/src/test/resources/xwork-jar.jar | Bin 2501 -> 2059 bytes core/src/test/resources/xwork-param-test.xml | 11 +- core/src/test/resources/xwork-proxyinvoke.xml | 11 +- core/src/test/resources/xwork-sample.xml | 13 +- core/src/test/resources/xwork-test-beans.xml | 11 +- .../src/test/resources/xwork-test-default.xml | 12 +- .../test/resources/xwork-test-validation.xml | 12 +- core/src/test/resources/xwork-zip.zip | Bin 2500 -> 2564 bytes .../BeanValidationInterceptorTest.java | 3 +- .../test/resources/bean-validation-test.xml | 12 +- .../OValValidationInterceptorTest.java | 59 +++---- plugins/oval/src/test/resources/oval-test.xml | 27 +-- 94 files changed, 1033 insertions(+), 1010 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java index 067a1f995..c5dcae192 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java @@ -20,7 +20,6 @@ package com.opensymphony.xwork2.config; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; -import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.StrutsConstants; @@ -102,7 +101,6 @@ public class ConfigurationManager { try { if (containerProviders.size() == 0) { containerProviders.add(new XWorkConfigurationProvider()); - containerProviders.add(new XmlConfigurationProvider("xwork.xml", false)); } return containerProviders; @@ -160,7 +158,7 @@ public class ConfigurationManager { */ public synchronized void destroyConfiguration() { clearContainerProviders(); // let's destroy the ConfigurationProvider first - containerProviders = new CopyOnWriteArrayList(); + containerProviders = new CopyOnWriteArrayList<>(); if (configuration != null) configuration.destroy(); // let's destroy it first, before nulling it. configuration = null; diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java index ce1587de5..d2da19768 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java @@ -85,21 +85,22 @@ import java.util.Vector; * @author Neo * @version $Revision$ */ -public class XmlConfigurationProvider implements ConfigurationProvider { +public abstract class XmlConfigurationProvider implements ConfigurationProvider { private static final Logger LOG = LogManager.getLogger(XmlConfigurationProvider.class); + private final String configFileName; + private final Set loadedFileUrls = new HashSet<>(); + private final Map declaredPackages = new HashMap<>(); + private List documents; private Set includedFileNames; - private String configFileName; private ObjectFactory objectFactory; - private final Set loadedFileUrls = new HashSet<>(); - private boolean errorIfMissing; - private Map dtdMappings; + private Map dtdMappings = new HashMap<>(); private Configuration configuration; + private boolean throwExceptionOnDuplicateBeans = true; - private final Map declaredPackages = new HashMap<>(); private FileManager fileManager; private ValueSubstitutor valueSubstitutor; @@ -112,21 +113,8 @@ public class XmlConfigurationProvider implements ConfigurationProvider { this(filename, true); } - public XmlConfigurationProvider(String filename, boolean errorIfMissing) { + public XmlConfigurationProvider(String filename, @Deprecated boolean notUsed) { this.configFileName = filename; - this.errorIfMissing = errorIfMissing; - - Map mappings = new HashMap<>(); - mappings.put("-//Apache Struts//XWork 2.6//EN", "xwork-2.6.dtd"); - mappings.put("-//Apache Struts//XWork 2.5//EN", "xwork-2.5.dtd"); - mappings.put("-//Apache Struts//XWork 2.3//EN", "xwork-2.3.dtd"); - mappings.put("-//Apache Struts//XWork 2.1.3//EN", "xwork-2.1.3.dtd"); - mappings.put("-//Apache Struts//XWork 2.1//EN", "xwork-2.1.dtd"); - mappings.put("-//Apache Struts//XWork 2.0//EN", "xwork-2.0.dtd"); - mappings.put("-//Apache Struts//XWork 1.1.1//EN", "xwork-1.1.1.dtd"); - mappings.put("-//Apache Struts//XWork 1.1//EN", "xwork-1.1.dtd"); - mappings.put("-//Apache Struts//XWork 1.0//EN", "xwork-1.0.dtd"); - setDtdMappings(mappings); } public void setThrowExceptionOnDuplicateBeans(boolean val) { @@ -1078,12 +1066,7 @@ public class XmlConfigurationProvider implements ConfigurationProvider { } if (urls == null || !urls.hasNext()) { - if (errorIfMissing) { - throw new ConfigurationException("Could not open files of the name " + fileName, ioException); - } else { - LOG.trace("Unable to locate configuration files of the name {}, skipping", fileName); - return docs; - } + throw new ConfigurationException("Could not open file: " + fileName, ioException); } URL url = null; diff --git a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java index 5f4bf9e9a..3461c7545 100644 --- a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java +++ b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java @@ -55,6 +55,15 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider { this("struts.xml", errorIfMissing, null); } + /** + * Constructs the configuration provider based on the provided config file + * + * @param filename file with Struts configuration + */ + public StrutsXmlConfigurationProvider(String filename) { + this(filename, false, null); + } + /** * Constructs the configuration provider * diff --git a/core/src/main/resources/xwork-default.xml b/core/src/main/resources/xwork-default.xml index 9e7f68dec..fcdcb5f43 100644 --- a/core/src/main/resources/xwork-default.xml +++ b/core/src/main/resources/xwork-default.xml @@ -19,11 +19,10 @@ * under the License. */ --> - - - + + @@ -84,4 +83,4 @@ - + diff --git a/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java index ce93c3f45..e0f13c42a 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java @@ -20,9 +20,10 @@ package com.opensymphony.xwork2; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; -import org.apache.struts2.StrutsException; -import org.apache.struts2.dispatcher.HttpParameters; import com.opensymphony.xwork2.mock.MockResult; +import org.apache.struts2.StrutsException; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; +import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -34,38 +35,40 @@ public class ActionInvocationTest extends XWorkTestCase { public void testCommandInvocation() throws Exception { ActionProxy baseActionProxy = actionProxyFactory.createActionProxy( - "baz", "commandTest", null, null); + "baz", "commandTest", null, null); assertEquals("success", baseActionProxy.execute()); ActionProxy commandActionProxy = actionProxyFactory.createActionProxy( - "baz", "myCommand", null, null); + "baz", "myCommand", null, null); assertEquals(SimpleAction.COMMAND_RETURN_CODE, commandActionProxy.execute()); } public void testCommandInvocationDoMethod() throws Exception { ActionProxy baseActionProxy = actionProxyFactory.createActionProxy( - "baz", "doMethodTest", null, null); + "baz", "doMethodTest", null, null); assertEquals("input", baseActionProxy.execute()); } public void testCommandInvocationUnknownHandler() throws Exception { UnknownHandler unknownHandler = new UnknownHandler() { - public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException { + public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException { return new ActionConfig.Builder("test", actionName, ActionSupport.class.getName()) - .addAllowedMethod("unknownmethod") - .build(); + .addAllowedMethod("unknownmethod") + .build(); + } + + public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException { + return new MockResult(); + } + + public Object handleUnknownActionMethod(Object action, String methodName) { + if (methodName.equals("unknownmethod")) { + return "found"; + } else { + return null; + } } - public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException { - return new MockResult(); - } - public Object handleUnknownActionMethod(Object action, String methodName) { - if (methodName.equals("unknownmethod")) { - return "found"; - } else { - return null; - } - } }; UnknownHandlerManagerMock uhm = new UnknownHandlerManagerMock(); @@ -74,16 +77,16 @@ public class ActionInvocationTest extends XWorkTestCase { loadButAdd(UnknownHandlerManager.class, uhm); DefaultActionProxy baseActionProxy = (DefaultActionProxy) actionProxyFactory.createActionProxy( - "baz", "unknownMethodTest", "unknownmethod", null); + "baz", "unknownMethodTest", "unknownmethod", null); - ((DefaultActionInvocation)baseActionProxy.getInvocation()).setUnknownHandlerManager(uhm); + ((DefaultActionInvocation) baseActionProxy.getInvocation()).setUnknownHandlerManager(uhm); assertEquals("found", baseActionProxy.execute()); } public void testResultReturnInvocationAndWired() throws Exception { ActionProxy baseActionProxy = actionProxyFactory.createActionProxy( - "baz", "resultAction", null, null); + "baz", "resultAction", null, null); assertNull(baseActionProxy.execute()); assertTrue(SimpleAction.resultCalled); } @@ -96,7 +99,7 @@ public class ActionInvocationTest extends XWorkTestCase { extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build()); try { - ActionProxy proxy = actionProxyFactory.createActionProxy( "", "Foo", null, extraContext); + ActionProxy proxy = actionProxyFactory.createActionProxy("", "Foo", null, extraContext); proxy.execute(); assertEquals("this is blah", proxy.getInvocation().getStack().findValue("[1].blah")); } catch (Exception e) { @@ -105,11 +108,12 @@ public class ActionInvocationTest extends XWorkTestCase { } } - @Override protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } diff --git a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java index f806cafdb..84fa0afa1 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java @@ -23,6 +23,7 @@ import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.util.ValueStack; import junit.framework.TestCase; import org.apache.struts2.StrutsException; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.HashMap; import java.util.Map; @@ -38,7 +39,7 @@ public class ChainResultTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } @@ -124,9 +125,9 @@ public class ChainResultTest extends XWorkTestCase { } private class NamespaceActionNameTestActionProxyFactory implements ActionProxyFactory { - private ActionProxy returnVal; - private String expectedActionName; - private String expectedNamespace; + private final ActionProxy returnVal; + private final String expectedActionName; + private final String expectedNamespace; NamespaceActionNameTestActionProxyFactory(String expectedNamespace, String expectedActionName, ActionProxy returnVal) { this.expectedNamespace = expectedNamespace; @@ -156,14 +157,14 @@ public class ChainResultTest extends XWorkTestCase { } public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map extraContext, boolean executeResult, boolean cleanupContext) { - TestCase.assertEquals(expectedNamespace, namespace); + TestCase.assertEquals(expectedNamespace, namespace); TestCase.assertEquals(expectedActionName, actionName); return returnVal; } public ActionProxy createActionProxy(ActionInvocation actionInvocation, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) { - TestCase.assertEquals(expectedNamespace, namespace); + TestCase.assertEquals(expectedNamespace, namespace); TestCase.assertEquals(expectedActionName, actionName); return returnVal; @@ -177,7 +178,7 @@ public class ChainResultTest extends XWorkTestCase { } public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, - Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception { + Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception { return null; } } diff --git a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java index fc5e2c2a9..a0d53c9b6 100644 --- a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java @@ -29,6 +29,7 @@ import com.opensymphony.xwork2.mock.MockResult; import com.opensymphony.xwork2.ognl.OgnlUtil; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.ValueStackFactory; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.ArrayList; @@ -304,7 +305,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { DefaultActionInvocation defaultActionInvocation = new DefaultActionInvocation(extraContext, true); container.inject(defaultActionInvocation); - ActionProxy actionProxy = actionProxyFactory.createActionProxy( "", "LazyFoo", null, extraContext); + ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "LazyFoo", null, extraContext); defaultActionInvocation.init(actionProxy); defaultActionInvocation.invoke(); @@ -322,6 +323,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { lock.acquire(); dai.setAsyncManager(new AsyncManager() { Object asyncActionResult; + @Override public boolean hasAsyncActionResult() { return asyncActionResult != null; @@ -384,7 +386,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { assertFalse("invocation should not be executed", dai.executed); assertNull("a null result should be passed to upper and wait for the async result", dai.resultCode); - if(lock.tryAcquire(1500L, TimeUnit.MILLISECONDS)) { + if (lock.tryAcquire(1500L, TimeUnit.MILLISECONDS)) { try { dai.invoke(); assertTrue("preResultListener should be executed", preResultExecuted[0]); @@ -402,7 +404,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { public void testActionEventListener() throws Exception { ActionProxy actionProxy = actionProxyFactory.createActionProxy("", - "ExceptionFoo", "exceptionMethod", new HashMap()); + "ExceptionFoo", "exceptionMethod", new HashMap()); DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation(); SimpleActionEventListener actionEventListener = new SimpleActionEventListener("prepared", "exceptionHandled"); @@ -428,7 +430,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { public void testActionChainResult() throws Exception { ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "Foo", null, - new HashMap()); + new HashMap()); DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation(); defaultActionInvocation.init(actionProxy); @@ -446,7 +448,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { public void testNoResultDefined() throws Exception { ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "Foo", null, - new HashMap()); + new HashMap()); DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation(); defaultActionInvocation.init(actionProxy); @@ -459,7 +461,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { public void testNullResultPossible() throws Exception { ActionProxy actionProxy = actionProxyFactory.createActionProxy("", - "NullFoo", "nullMethod", new HashMap()); + "NullFoo", "nullMethod", new HashMap()); DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation(); defaultActionInvocation.init(actionProxy); @@ -473,7 +475,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } @@ -481,8 +483,8 @@ public class DefaultActionInvocationTest extends XWorkTestCase { private class SimpleActionEventListener implements ActionEventListener { - private String name; - private String result; + private final String name; + private final String result; SimpleActionEventListener(String name, String result) { @@ -492,7 +494,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase { @Override public Object prepare(Object action, ValueStack stack) { - ((SimpleAction)action).setName(name); + ((SimpleAction) action).setName(name); return action; } diff --git a/core/src/test/java/com/opensymphony/xwork2/DefaultActionProxyTest.java b/core/src/test/java/com/opensymphony/xwork2/DefaultActionProxyTest.java index c305997fb..125c5b4bd 100644 --- a/core/src/test/java/com/opensymphony/xwork2/DefaultActionProxyTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/DefaultActionProxyTest.java @@ -18,9 +18,9 @@ */ package com.opensymphony.xwork2; -import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.mock.MockActionInvocation; import org.apache.struts2.StrutsInternalTestCase; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.junit.Test; public class DefaultActionProxyTest extends StrutsInternalTestCase { @@ -28,7 +28,7 @@ public class DefaultActionProxyTest extends StrutsInternalTestCase { @Test public void testThorwExceptionOnNotAllowedMethod() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml"; - loadConfigurationProviders(new XmlConfigurationProvider(filename)); + loadConfigurationProviders(new StrutsXmlConfigurationProvider(filename)); DefaultActionProxy dap = new DefaultActionProxy(new MockActionInvocation(), "strict", "Default", "notAllowed", true, true); container.inject(dap); diff --git a/core/src/test/java/com/opensymphony/xwork2/DefaultClasstTest.java b/core/src/test/java/com/opensymphony/xwork2/DefaultClasstTest.java index 1472fff29..a8d6e7324 100644 --- a/core/src/test/java/com/opensymphony/xwork2/DefaultClasstTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/DefaultClasstTest.java @@ -19,6 +19,7 @@ package com.opensymphony.xwork2; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; /** * WildCardResultTest @@ -33,7 +34,7 @@ public class DefaultClasstTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } @@ -41,20 +42,20 @@ public class DefaultClasstTest extends XWorkTestCase { public void testWildCardEvaluation() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy("Abstract-crud", "edit", null, null); assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName()); - + proxy = actionProxyFactory.createActionProxy("/example", "edit", null, null); assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName()); - + proxy = actionProxyFactory.createActionProxy("/example2", "override", null, null); assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName()); - + proxy = actionProxyFactory.createActionProxy("/example2/subItem", "save", null, null); assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName()); - + proxy = actionProxyFactory.createActionProxy("/example2", "list", null, null); assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName()); - + proxy = actionProxyFactory.createActionProxy("/example3", "list", null, null); assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java b/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java index f7c950664..bb77cab23 100644 --- a/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/LocaleAwareTest.java @@ -22,6 +22,7 @@ import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.ValueStackFactory; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.Locale; @@ -30,7 +31,7 @@ import java.util.Locale; * LocaleAwareTest * * @author Jason Carreira - * Created Feb 10, 2003 6:13:13 PM + * Created Feb 10, 2003 6:13:13 PM */ public class LocaleAwareTest extends XWorkTestCase { @@ -63,7 +64,7 @@ public class LocaleAwareTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider, new MockConfigurationProvider()); diff --git a/core/src/test/java/com/opensymphony/xwork2/ProxyInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/ProxyInvocationTest.java index 794e1cdba..3c962a47a 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ProxyInvocationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ProxyInvocationTest.java @@ -19,6 +19,7 @@ package com.opensymphony.xwork2; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.HashMap; import java.util.Map; @@ -31,22 +32,22 @@ public class ProxyInvocationTest extends XWorkTestCase { /** * Sets a ProxyObjectFactory as ObjectFactory (so the FooAction will always be retrieved * as a FooProxy), and it tries to call invokeAction on the TestActionInvocation. - * - * It should fail, because the Method got from the action (actually a FooProxy) - * will be executed on the InvocationHandler of the action (so, in the action itself). + *

+ * It should fail, because the Method got from the action (actually a FooProxy) + * will be executed on the InvocationHandler of the action (so, in the action itself). */ public void testProxyInvocation() throws Exception { ActionProxy proxy = actionProxyFactory .createActionProxy("", "ProxyInvocation", null, createDummyContext()); ActionInvocation invocation = proxy.getInvocation(); - + String result = invocation.invokeActionOnly(); assertEquals("proxyResult", result); } - /** + /** * Needed for the creation of the action proxy */ private Map createDummyContext() { @@ -62,7 +63,7 @@ public class ProxyInvocationTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-proxyinvoke.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-proxyinvoke.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } diff --git a/core/src/test/java/com/opensymphony/xwork2/WildCardResultTest.java b/core/src/test/java/com/opensymphony/xwork2/WildCardResultTest.java index 08b4c39d1..008b5cc8c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/WildCardResultTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/WildCardResultTest.java @@ -20,6 +20,7 @@ package com.opensymphony.xwork2; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.mock.MockResult; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; /** * WildCardResultTest @@ -34,7 +35,7 @@ public class WildCardResultTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); } diff --git a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java index ee2e39461..7d46932d7 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java @@ -31,6 +31,7 @@ import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.mock.MockInterceptor; import com.opensymphony.xwork2.test.StubConfigurationProvider; import com.opensymphony.xwork2.util.location.LocatableProperties; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -86,20 +87,20 @@ public class ConfigurationTest extends XWorkTestCase { // check inheritance from Default assertNotNull(configuration.getActionConfig("includeTest", "Foo")); } - + public void testWildcardName() { RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration(); ActionConfig config = configuration.getActionConfig("", "WildCard/Simple/input"); - + assertNotNull(config); - assertTrue("Wrong class name, "+config.getClassName(), - "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName())); + assertTrue("Wrong class name, " + config.getClassName(), + "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName())); assertTrue("Wrong method name", "input".equals(config.getMethodName())); - + Map p = config.getParams(); - assertTrue("Wrong parameter, "+p.get("foo"), "Simple".equals(p.get("foo"))); - assertTrue("Wrong parameter, "+p.get("bar"), "input".equals(p.get("bar"))); + assertTrue("Wrong parameter, " + p.get("foo"), "Simple".equals(p.get("foo"))); + assertTrue("Wrong parameter, " + p.get("bar"), "input".equals(p.get("bar"))); } public void testWildcardNamespace() { @@ -108,12 +109,12 @@ public class ConfigurationTest extends XWorkTestCase { ActionConfig config = configuration.getActionConfig("/animals/dog", "commandTest"); assertNotNull(config); - assertTrue("Wrong class name, "+config.getClassName(), - "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName())); + assertTrue("Wrong class name, " + config.getClassName(), + "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName())); Map p = config.getParams(); - assertTrue("Wrong parameter, "+p.get("0"), "/animals/dog".equals(p.get("0"))); - assertTrue("Wrong parameter, "+p.get("1"), "dog".equals(p.get("1"))); + assertTrue("Wrong parameter, " + p.get("0"), "/animals/dog".equals(p.get("0"))); + assertTrue("Wrong parameter, " + p.get("1"), "dog".equals(p.get("1"))); } public void testGlobalResults() { @@ -204,11 +205,11 @@ public class ConfigurationTest extends XWorkTestCase { // check that it has configuration from MockConfigurationProvider assertNotNull(configuration.getActionConfig("", MockConfigurationProvider.FOO_ACTION_NAME)); } - + public void testMultipleContainerProviders() throws Exception { // to start from scratch configurationManager.destroyConfiguration(); - // to build basic configuration + // to build basic configuration configurationManager.getConfiguration(); Mock mockContainerProvider = new Mock(ContainerProvider.class); @@ -220,7 +221,7 @@ public class ConfigurationTest extends XWorkTestCase { mockContainerProvider.expectAndReturn("needsReload", true); // the order of providers must be changed as just first is checked if reload is needed configurationManager.addContainerProvider((ContainerProvider) mockContainerProvider.proxy()); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); configurationManager.addContainerProvider(provider); @@ -231,7 +232,7 @@ public class ConfigurationTest extends XWorkTestCase { e.printStackTrace(); fail(); } - + RuntimeConfiguration configuration = config.getRuntimeConfiguration(); // check that it has configuration from xml @@ -239,24 +240,25 @@ public class ConfigurationTest extends XWorkTestCase { mockContainerProvider.verify(); } - + public void testInitForPackageProviders() { - + loadConfigurationProviders(new StubConfigurationProvider() { @Override public void register(ContainerBuilder builder, - LocatableProperties props) throws ConfigurationException { + LocatableProperties props) throws ConfigurationException { builder.factory(PackageProvider.class, "foo", MyPackageProvider.class); } }); - + assertEquals(configuration, MyPackageProvider.getConfiguration()); } - + public void testInitOnceForConfigurationProviders() { - + loadConfigurationProviders(new StubConfigurationProvider() { boolean called = false; + @Override public void init(Configuration config) { if (called) { @@ -264,7 +266,7 @@ public class ConfigurationTest extends XWorkTestCase { } called = true; } - + @Override public void loadPackages() { if (!called) { @@ -300,30 +302,36 @@ public class ConfigurationTest extends XWorkTestCase { fail(); } } - + @Override protected void setUp() throws Exception { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); } public static class MyPackageProvider implements PackageProvider { static Configuration config; - public void loadPackages() throws ConfigurationException {} - public boolean needsReload() { return config != null; } - + + public void loadPackages() throws ConfigurationException { + } + + public boolean needsReload() { + return config != null; + } + public static Configuration getConfiguration() { return config; } + public void init(Configuration configuration) - throws ConfigurationException { + throws ConfigurationException { config = configuration; } - + } } diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationTestBase.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationTestBase.java index a344a42b0..c07307193 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationTestBase.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationTestBase.java @@ -21,21 +21,22 @@ package com.opensymphony.xwork2.config.providers; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.ConfigurationProvider; import com.opensymphony.xwork2.config.impl.MockConfiguration; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; /** * ConfigurationTestBase * * @author Jason Carreira - * Created Jun 9, 2003 7:42:12 AM + * Created Jun 9, 2003 7:42:12 AM */ public abstract class ConfigurationTestBase extends XWorkTestCase { protected ConfigurationProvider buildConfigurationProvider(final String filename) { configuration = new MockConfiguration(); - ((MockConfiguration)configuration).selfRegister(); + ((MockConfiguration) configuration).selfRegister(); container = configuration.getContainer(); - XmlConfigurationProvider prov = new XmlConfigurationProvider(filename, true); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider(filename); container.inject(prov); prov.init(configuration); prov.loadPackages(); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java index 9ba307d42..6b6057b12 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java @@ -19,7 +19,6 @@ package com.opensymphony.xwork2.config.providers; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.config.ConfigurationProvider; import com.opensymphony.xwork2.config.ContainerProvider; import com.opensymphony.xwork2.config.RuntimeConfiguration; import com.opensymphony.xwork2.config.entities.ActionConfig; @@ -27,6 +26,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; import com.opensymphony.xwork2.util.fs.DefaultFileManager; import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public class XmlConfigurationProviderInterceptorParamOverridingTest extends XWor public void testInterceptorParamOveriding() throws Exception { DefaultConfiguration conf = new DefaultConfiguration(); - final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml"); + final XmlConfigurationProvider p = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml"); DefaultFileManagerFactory factory = new DefaultFileManagerFactory(); factory.setContainer(container); factory.setFileManager(new DefaultFileManager()); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java index d75d1909b..401c66f16 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java @@ -19,7 +19,6 @@ package com.opensymphony.xwork2.config.providers; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.config.ConfigurationProvider; import com.opensymphony.xwork2.config.ContainerProvider; import com.opensymphony.xwork2.config.RuntimeConfiguration; import com.opensymphony.xwork2.config.entities.ActionConfig; @@ -27,6 +26,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; import com.opensymphony.xwork2.util.fs.DefaultFileManager; import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.ArrayList; import java.util.List; @@ -38,71 +38,71 @@ import java.util.List; * @version $Id$ */ public class XmlConfigurationProviderInterceptorStackParamOverridingTest extends XWorkTestCase { - + public void testInterceptorStackParamOveriding() throws Exception { - DefaultConfiguration conf = new DefaultConfiguration(); - final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml"); + DefaultConfiguration conf = new DefaultConfiguration(); + final XmlConfigurationProvider p = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml"); DefaultFileManagerFactory factory = new DefaultFileManagerFactory(); factory.setContainer(container); factory.setFileManager(new DefaultFileManager()); p.setFileManagerFactory(factory); - configurationManager.addContainerProvider(p); + configurationManager.addContainerProvider(p); conf.reloadContainer(new ArrayList() { - { - add(new XWorkConfigurationProvider()); - add(p); - } - }); + { + add(new XWorkConfigurationProvider()); + add(p); + } + }); - RuntimeConfiguration rtConf = conf.getRuntimeConfiguration(); + RuntimeConfiguration rtConf = conf.getRuntimeConfiguration(); - ActionConfig actionOne = rtConf.getActionConfig("", "actionOne"); - ActionConfig actionTwo = rtConf.getActionConfig("", "actionTwo"); + ActionConfig actionOne = rtConf.getActionConfig("", "actionOne"); + ActionConfig actionTwo = rtConf.getActionConfig("", "actionTwo"); - List actionOneInterceptors = actionOne.getInterceptors(); - List actionTwoInterceptors = actionTwo.getInterceptors(); + List actionOneInterceptors = actionOne.getInterceptors(); + List actionTwoInterceptors = actionTwo.getInterceptors(); - assertNotNull(actionOne); - assertNotNull(actionTwo); - assertNotNull(actionOneInterceptors); - assertNotNull(actionTwoInterceptors); - assertEquals(actionOneInterceptors.size(), 3); - assertEquals(actionTwoInterceptors.size(), 3); + assertNotNull(actionOne); + assertNotNull(actionTwo); + assertNotNull(actionOneInterceptors); + assertNotNull(actionTwoInterceptors); + assertEquals(actionOneInterceptors.size(), 3); + assertEquals(actionTwoInterceptors.size(), 3); - InterceptorMapping actionOneInterceptorMapping1 = (InterceptorMapping) actionOneInterceptors.get(0); - InterceptorMapping actionOneInterceptorMapping2 = (InterceptorMapping) actionOneInterceptors.get(1); - InterceptorMapping actionOneInterceptorMapping3 = (InterceptorMapping) actionOneInterceptors.get(2); - InterceptorMapping actionTwoInterceptorMapping1 = (InterceptorMapping) actionTwoInterceptors.get(0); - InterceptorMapping actionTwoInterceptorMapping2 = (InterceptorMapping) actionTwoInterceptors.get(1); - InterceptorMapping actionTwoInterceptorMapping3 = (InterceptorMapping) actionTwoInterceptors.get(2); + InterceptorMapping actionOneInterceptorMapping1 = (InterceptorMapping) actionOneInterceptors.get(0); + InterceptorMapping actionOneInterceptorMapping2 = (InterceptorMapping) actionOneInterceptors.get(1); + InterceptorMapping actionOneInterceptorMapping3 = (InterceptorMapping) actionOneInterceptors.get(2); + InterceptorMapping actionTwoInterceptorMapping1 = (InterceptorMapping) actionTwoInterceptors.get(0); + InterceptorMapping actionTwoInterceptorMapping2 = (InterceptorMapping) actionTwoInterceptors.get(1); + InterceptorMapping actionTwoInterceptorMapping3 = (InterceptorMapping) actionTwoInterceptors.get(2); - assertNotNull(actionOneInterceptorMapping1); - assertNotNull(actionOneInterceptorMapping2); - assertNotNull(actionOneInterceptorMapping3); - assertNotNull(actionTwoInterceptorMapping1); - assertNotNull(actionTwoInterceptorMapping2); - assertNotNull(actionTwoInterceptorMapping3); + assertNotNull(actionOneInterceptorMapping1); + assertNotNull(actionOneInterceptorMapping2); + assertNotNull(actionOneInterceptorMapping3); + assertNotNull(actionTwoInterceptorMapping1); + assertNotNull(actionTwoInterceptorMapping2); + assertNotNull(actionTwoInterceptorMapping3); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamOne(), "i1p1"); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamTwo(), "i1p2"); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamOne(), "i2p1"); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamTwo(), null); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamOne(), null); - assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamTwo(), null); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping1.getInterceptor()).getParamOne(), "i1p1"); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping1.getInterceptor()).getParamTwo(), "i1p2"); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping2.getInterceptor()).getParamOne(), "i2p1"); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping2.getInterceptor()).getParamTwo(), null); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping3.getInterceptor()).getParamOne(), null); + assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping3.getInterceptor()).getParamTwo(), null); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamOne(), null); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamTwo(), null); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamOne(), null); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamTwo(), "i2p2"); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamOne(), "i3p1"); - assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamTwo(), "i3p2"); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping1.getInterceptor()).getParamOne(), null); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping1.getInterceptor()).getParamTwo(), null); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping2.getInterceptor()).getParamOne(), null); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping2.getInterceptor()).getParamTwo(), "i2p2"); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping3.getInterceptor()).getParamOne(), "i3p1"); + assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping3.getInterceptor()).getParamTwo(), "i3p2"); } @Override protected void tearDown() throws Exception { - configurationManager.clearContainerProviders(); + configurationManager.clearContainerProviders(); } } diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorsTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorsTest.java index 70bfe23f3..fd52d2fb2 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorsTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorsTest.java @@ -23,9 +23,14 @@ import com.opensymphony.xwork2.SimpleAction; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; import com.opensymphony.xwork2.config.RuntimeConfiguration; -import com.opensymphony.xwork2.config.entities.*; +import com.opensymphony.xwork2.config.entities.ActionConfig; +import com.opensymphony.xwork2.config.entities.InterceptorConfig; +import com.opensymphony.xwork2.config.entities.InterceptorMapping; +import com.opensymphony.xwork2.config.entities.InterceptorStackConfig; +import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.interceptor.LoggingInterceptor; import com.opensymphony.xwork2.mock.MockInterceptor; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.interceptor.NoOpInterceptor; import java.util.ArrayList; @@ -46,7 +51,7 @@ public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestB InterceptorConfig mockInterceptor = new InterceptorConfig.Builder("mock", MockInterceptor.class.getName()).build(); InterceptorConfig noopInterceptor = new InterceptorConfig.Builder("noop", NoOpInterceptor.class.getName()).build(); ObjectFactory objectFactory; - + @Override public void setUp() throws Exception { super.setUp(); @@ -68,16 +73,16 @@ public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestB // the default interceptor stack InterceptorStackConfig defaultStack = new InterceptorStackConfig.Builder("defaultStack") - .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) - .addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))) - .build(); + .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) + .addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))) + .build(); // the derivative interceptor stack InterceptorStackConfig derivativeStack = new InterceptorStackConfig.Builder("derivativeStack") - .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) - .addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))) - .addInterceptor(new InterceptorMapping("logging", objectFactory.buildInterceptor(loggingInterceptor, new HashMap()))) - .build(); + .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) + .addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))) + .addInterceptor(new InterceptorMapping("logging", objectFactory.buildInterceptor(loggingInterceptor, new HashMap()))) + .build(); // execute the configuration provider.init(configuration); @@ -100,7 +105,7 @@ public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestB } public void testInterceptorDefaultRefs() throws ConfigurationException { - XmlConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml"); container.inject(provider); loadConfigurationProviders(provider); @@ -141,7 +146,7 @@ public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestB } public void testInterceptorInheritance() throws ConfigurationException { - + // expectations - the inherited interceptor stack InterceptorStackConfig inheritedStack = new InterceptorStackConfig.Builder("subDefaultStack") .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) @@ -160,9 +165,9 @@ public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestB // expectations - the inherited interceptor stack inheritedStack = new InterceptorStackConfig.Builder("subSubDefaultStack") - .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) - .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) - .build(); + .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) + .addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap()))) + .build(); PackageConfig subSubPkg = configuration.getPackageConfig("subSubPackage"); assertEquals(1, subSubPkg.getInterceptorConfigs().size()); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java index 5c56e3aca..3a8fbb37c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java @@ -18,6 +18,7 @@ */ package com.opensymphony.xwork2.config.providers; +import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.config.ConfigurationProvider; @@ -27,7 +28,17 @@ import com.opensymphony.xwork2.config.entities.ResultConfig; import com.opensymphony.xwork2.config.entities.ResultTypeConfig; import com.opensymphony.xwork2.config.impl.MockConfiguration; import com.opensymphony.xwork2.util.ClassLoaderUtil; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; +import org.apache.struts2.result.ServletDispatcherResult; +import org.w3c.dom.Attr; +import org.w3c.dom.DOMException; import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.TypeInfo; +import org.w3c.dom.UserDataHandler; import java.io.File; import java.io.IOException; @@ -42,15 +53,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.struts2.result.ServletDispatcherResult; -import org.w3c.dom.Attr; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.TypeInfo; -import org.w3c.dom.UserDataHandler; public class XmlConfigurationProviderTest extends ConfigurationTestBase { @@ -60,7 +62,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { ((MockConfiguration) configuration).selfRegister(); container = configuration.getContainer(); - XmlConfigurationProvider prov = new XmlConfigurationProvider("xwork-test-load-order.xml", true) { + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("xwork-test-load-order.xml") { @Override protected Iterator getConfigurationUrls(String fileName) throws IOException { List urls = new ArrayList<>(); @@ -83,7 +85,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { public static final long FILE_TS_WAIT_IN_MS = 3600000; - private static void changeFileTime(File f) throws Exception { + private static void changeFileTime(String filename, File f) throws Exception { final long orig = f.lastModified(); final long maxwait = orig + FILE_TS_WAIT_IN_MS; long curr; @@ -91,11 +93,12 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { Thread.sleep(500); assertTrue("Waited more than " + FILE_TS_WAIT_IN_MS + " ms to update timestamp on file: " + f, maxwait > curr); } + ActionContext.getContext().with("configurationReload-" + filename, null); } public void testNeedsReload() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml"; - ConfigurationProvider provider = new XmlConfigurationProvider(filename, true); + ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename); container.inject(provider); provider.init(configuration); provider.loadPackages(); @@ -105,14 +108,14 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { File file = new File(getClass().getResource("/" + filename).toURI()); assertTrue("not exists: " + file.toString(), file.exists()); - changeFileTime(file); + changeFileTime(filename, file); assertTrue(provider.needsReload()); } public void testReload() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-reload.xml"; - ConfigurationProvider provider = new XmlConfigurationProvider(filename, true); + ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename); loadConfigurationProviders(provider); assertFalse(provider.needsReload()); // Revision exists and timestamp didn't change @@ -123,7 +126,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { Path configPath = Paths.get(file.getAbsolutePath()); String content = new String(Files.readAllBytes(configPath)); content = content.replaceAll("", - ""); + ""); Files.write(configPath, content.getBytes()); // user demand: stop reloading configs try { @@ -131,11 +134,11 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { configurationManager.reload(); - changeFileTime(file); + changeFileTime(filename, file); assertFalse(provider.needsReload()); // user already has stopped reloading configs } finally { content = content.replaceAll("", - ""); + ""); Files.write(configPath, content.getBytes()); } } @@ -143,7 +146,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { public void testNeedsReloadNotReloadingConfigs() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml"; buildConfigurationProvider(filename); - ConfigurationProvider provider = new XmlConfigurationProvider(filename, true); + ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename); container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs(false); container.inject(provider); provider.init(configuration); @@ -153,7 +156,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { File file = new File(getClass().getResource("/" + filename).toURI()); assertTrue("not exists: " + file.toString(), file.exists()); - changeFileTime(file); + changeFileTime(filename, file); assertFalse(provider.needsReload()); } @@ -210,7 +213,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { } public void testGuessResultType() { - XmlConfigurationProvider prov = new XmlConfigurationProvider(); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("xwork.xml"); assertEquals(null, prov.guessResultType(null)); assertEquals("foo", prov.guessResultType("foo")); @@ -221,7 +224,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { public void testEmptySpaces() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork- test.xml"; - ConfigurationProvider provider = new XmlConfigurationProvider(filename, true); + ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename); container.inject(provider); provider.init(configuration); provider.loadPackages(); @@ -234,7 +237,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { File file = new File(uri); assertTrue(file.exists()); - changeFileTime(file); + changeFileTime(filename, file); assertTrue(provider.needsReload()); } @@ -242,7 +245,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { public void testEmptySpacesNotReloadingConfigs() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork- test.xml"; buildConfigurationProvider(filename); - ConfigurationProvider provider = new XmlConfigurationProvider(filename, true); + ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename); container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs(false); container.inject(provider); provider.init(configuration); @@ -255,7 +258,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { File file = new File(uri); assertTrue(file.exists()); - changeFileTime(file); + changeFileTime(filename, file); assertFalse(provider.needsReload()); } @@ -287,7 +290,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { File file = new File(jar); assertTrue("File [" + file + "] doesn't exist!", file.exists()); - changeFileTime(file); + changeFileTime(jar, file); assertFalse(provider.needsReload()); } @@ -311,8 +314,8 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * Test buildAllowedMethods() to ensure consistent results for processing * in XML configuration elements. - * - * @throws Exception + * + * @throws Exception */ public void testBuildAllowedMethods() throws Exception { // Test introduced with WW-5029 fix. @@ -335,20 +338,20 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { NodeList mockNodeListSingleChild = new MockNodeList(singleStringList); NodeList mockNodeListMultipleChild = new MockNodeList(multipleStringList); Element mockSingleChildAllowedMethodsElement = new MockElement("allowed-methods", fakeBodyString, - "allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); + "allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); Element mockMultipleChildAllowedMethodsElement = new MockElement("allowed-methods", fakeBodyString, - "allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); + "allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); MockNodeList mockActionElementChildrenSingle = new MockNodeList(); mockActionElementChildrenSingle.addToNodeList(mockSingleChildAllowedMethodsElement); MockNodeList mockActionElementChildrenMultiple = new MockNodeList(); mockActionElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement); Element mockActionElementSingle = new MockElement("action", "fakeBody", "action", "fakeValue", - Node.TEXT_NODE, mockActionElementChildrenSingle, null); + Node.TEXT_NODE, mockActionElementChildrenSingle, null); Element mockActionElementMultiple = new MockElement("action", "fakeBody", "action", "fakeValue", - Node.TEXT_NODE, mockActionElementChildrenMultiple, null); + Node.TEXT_NODE, mockActionElementChildrenMultiple, null); // Attempt the method using both types of Elements (single child and multiple child) and confirm // the result is the same for both. Also confirm the results are as expected. - XmlConfigurationProvider prov = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml", false); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml"); Set singleChildResult = prov.buildAllowedMethods(mockActionElementSingle, testPackageConfigBuilder); Set multipleChildResult = prov.buildAllowedMethods(mockActionElementMultiple, testPackageConfigBuilder); assertNotNull("singleChildResult is null ?", singleChildResult); @@ -365,8 +368,8 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * Test loadGlobalAllowedMethods() to ensure consistent results for processing * in XML configuration elements. - * - * @throws Exception + * + * @throws Exception */ public void testLoadGlobalAllowedMethods() throws Exception { // Test introduced with WW-5029 fix. @@ -389,19 +392,19 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { NodeList mockNodeListSingleChild = new MockNodeList(singleStringList); NodeList mockNodeListMultipleChild = new MockNodeList(multipleStringList); Element mockSingleChildAllowedMethodsElement = new MockElement("global-allowed-methods", fakeBodyString, - "global-allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); + "global-allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); Element mockMultipleChildAllowedMethodsElement = new MockElement("global-allowed-methods", fakeBodyString, - "global-allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); + "global-allowed-methods", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); MockNodeList mockPackageElementChildrenSingle = new MockNodeList(); mockPackageElementChildrenSingle.addToNodeList(mockSingleChildAllowedMethodsElement); MockNodeList mockPackageElementChildrenMultiple = new MockNodeList(); mockPackageElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement); Element mockPackageElementSingle = new MockElement("package", "fakeBody", "package", "fakeValue", - Node.TEXT_NODE, mockPackageElementChildrenSingle, null); + Node.TEXT_NODE, mockPackageElementChildrenSingle, null); Element mockPackageElementMultiple = new MockElement("package", "fakeBody", "package", "fakeValue", - Node.TEXT_NODE, mockPackageElementChildrenMultiple, null); + Node.TEXT_NODE, mockPackageElementChildrenMultiple, null); // Attempt the method using the single child Element and confirm the result is as expected. - XmlConfigurationProvider prov = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml", false); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml"); prov.loadGlobalAllowedMethods(testPackageConfigBuilder, mockPackageElementSingle); Set currentGlobalResult = testPackageConfigBuilder.getGlobalAllowedMethods(); assertNotNull("currentGlobalResult is null ?", currentGlobalResult); @@ -428,8 +431,8 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * Test buildResults() to ensure consistent results for processing * in XML configuration elements. - * - * @throws Exception + * + * @throws Exception */ public void testBuildResults() throws Exception { // Set up test using two mock DOM Elements: @@ -443,7 +446,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { final String fakeBodyString2 = "/SomePath2/SomePath2/SomePath2/SomeJSP2.jsp"; final String resultParam = "nonNullDefaultParam"; PackageConfig.Builder testPackageConfigBuilder = new PackageConfig.Builder("resultsPackage"); - ResultTypeConfig.Builder resultTypeConfigBuilder = new ResultTypeConfig.Builder("dispatcher", (String) ServletDispatcherResult.class.getName()); + ResultTypeConfig.Builder resultTypeConfigBuilder = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()); resultTypeConfigBuilder.defaultResultParam(resultParam); ResultTypeConfig resultTypeConfig = resultTypeConfigBuilder.build(); testPackageConfigBuilder.addResultTypeConfig(resultTypeConfig); @@ -466,19 +469,19 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { NodeList mockNodeListMultipleChild = new MockNodeList(multipleStringList); NodeList mockNodeListMultipleChild2 = new MockNodeList(multipleStringList2); Element mockSingleChildResultElement = new MockElement("result", fakeBodyString, - "result", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); + "result", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); mockSingleChildResultElement.setAttribute("name", "input"); mockSingleChildResultElement.setAttribute("type", "dispatcher"); Element mockSingleChildResultElement2 = new MockElement("result", fakeBodyString2, - "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListSingleChild2, null); + "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListSingleChild2, null); mockSingleChildResultElement2.setAttribute("name", "success"); mockSingleChildResultElement2.setAttribute("type", "dispatcher"); Element mockMultipleChildAllowedMethodsElement = new MockElement("result", fakeBodyString, - "result", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); + "result", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); mockMultipleChildAllowedMethodsElement.setAttribute("name", "input"); mockMultipleChildAllowedMethodsElement.setAttribute("type", "dispatcher"); Element mockMultipleChildAllowedMethodsElement2 = new MockElement("result", fakeBodyString2, - "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListMultipleChild2, null); + "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListMultipleChild2, null); mockMultipleChildAllowedMethodsElement2.setAttribute("name", "success"); mockMultipleChildAllowedMethodsElement2.setAttribute("type", "dispatcher"); MockNodeList mockActionElementChildrenSingle = new MockNodeList(); @@ -488,12 +491,12 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { mockActionElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement); mockActionElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement2); Element mockActionElementSingle = new MockElement("action", "fakeBody", "action", "fakeValue", - Node.TEXT_NODE, mockActionElementChildrenSingle, null); + Node.TEXT_NODE, mockActionElementChildrenSingle, null); Element mockActionElementMultiple = new MockElement("action", "fakeBody", "action", "fakeValue", - Node.TEXT_NODE, mockActionElementChildrenMultiple, null); + Node.TEXT_NODE, mockActionElementChildrenMultiple, null); // Attempt the method using both types of Elements (single child and multiple child) and confirm // the result is the same for both. Also confirm the results are as expected. - XmlConfigurationProvider prov = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml", false); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml"); Map singleChildResult = prov.buildResults(mockActionElementSingle, testPackageConfigBuilder); Map multipleChildResult = prov.buildResults(mockActionElementMultiple, testPackageConfigBuilder); assertNotNull("singleChildResult is null ?", singleChildResult); @@ -511,16 +514,16 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { assertNotNull("inputResultParams (multipleChildResult) is null ?", inputResultParams); assertNotNull("successResultParams (multipleChildResult) is null ?", successResultParams); assertEquals("inputResult (multipleChildResult) resultParam value not equal to fakeBodyString ?", - fakeBodyString, inputResultParams.get(resultParam)); + fakeBodyString, inputResultParams.get(resultParam)); assertEquals("successResult (multipleChildResult) resultParam value not equal to fakeBodyString2 ?", - fakeBodyString2, successResultParams.get(resultParam)); + fakeBodyString2, successResultParams.get(resultParam)); } /** * Test loadGlobalResults() to ensure consistent results for processing * in XML configuration elements. - * - * @throws Exception + * + * @throws Exception */ public void testLoadGlobalResults() throws Exception { // Set up test using two mock DOM Elements: @@ -534,7 +537,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { final String fakeBodyString2 = "/SomePath2/SomePath2/SomePath2/SomeJSP2.jsp"; final String resultParam = "nonNullDefaultParam"; PackageConfig.Builder testPackageConfigBuilder = new PackageConfig.Builder("resultsPackage"); - ResultTypeConfig.Builder resultTypeConfigBuilder = new ResultTypeConfig.Builder("dispatcher", (String) ServletDispatcherResult.class.getName()); + ResultTypeConfig.Builder resultTypeConfigBuilder = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()); resultTypeConfigBuilder.defaultResultParam(resultParam); ResultTypeConfig resultTypeConfig = resultTypeConfigBuilder.build(); testPackageConfigBuilder.addResultTypeConfig(resultTypeConfig); @@ -557,19 +560,19 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { NodeList mockNodeListMultipleChild = new MockNodeList(multipleStringList); NodeList mockNodeListMultipleChild2 = new MockNodeList(multipleStringList2); Element mockSingleChildResultElement = new MockElement("result", fakeBodyString, - "result", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); + "result", fakeBodyString, Node.TEXT_NODE, mockNodeListSingleChild, null); mockSingleChildResultElement.setAttribute("name", "input"); mockSingleChildResultElement.setAttribute("type", "dispatcher"); Element mockSingleChildResultElement2 = new MockElement("result", fakeBodyString2, - "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListSingleChild2, null); + "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListSingleChild2, null); mockSingleChildResultElement2.setAttribute("name", "success"); mockSingleChildResultElement2.setAttribute("type", "dispatcher"); Element mockMultipleChildAllowedMethodsElement = new MockElement("result", fakeBodyString, - "result", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); + "result", fakeBodyString, Node.TEXT_NODE, mockNodeListMultipleChild, null); mockMultipleChildAllowedMethodsElement.setAttribute("name", "input2"); mockMultipleChildAllowedMethodsElement.setAttribute("type", "dispatcher"); Element mockMultipleChildAllowedMethodsElement2 = new MockElement("result", fakeBodyString, - "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListMultipleChild2, null); + "result", fakeBodyString2, Node.TEXT_NODE, mockNodeListMultipleChild2, null); mockMultipleChildAllowedMethodsElement2.setAttribute("name", "success2"); mockMultipleChildAllowedMethodsElement2.setAttribute("type", "dispatcher"); MockNodeList mockGlobalResultsElementChildrenSingle = new MockNodeList(); @@ -579,19 +582,19 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { mockGlobalResultsElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement); mockGlobalResultsElementChildrenMultiple.addToNodeList(mockMultipleChildAllowedMethodsElement2); Element mockGlobalResultsElementSingle = new MockElement("global-results", "fakeBody", "global-results", "fakeValue", - Node.TEXT_NODE, mockGlobalResultsElementChildrenSingle, null); + Node.TEXT_NODE, mockGlobalResultsElementChildrenSingle, null); Element mockGlobalResultsGlobalResultsElementMultiple = new MockElement("global-results", "fakeBody", "global-results", "fakeValue", - Node.TEXT_NODE, mockGlobalResultsElementChildrenMultiple, null); + Node.TEXT_NODE, mockGlobalResultsElementChildrenMultiple, null); MockNodeList mockPackageElementChildrenSingle = new MockNodeList(); mockPackageElementChildrenSingle.addToNodeList(mockGlobalResultsElementSingle); MockNodeList mockPackageElementChildrenMultiple = new MockNodeList(); mockPackageElementChildrenMultiple.addToNodeList(mockGlobalResultsGlobalResultsElementMultiple); Element mockPackageElementSingle = new MockElement("package", "fakeBody", "package", "fakeValue", - Node.TEXT_NODE, mockPackageElementChildrenSingle, null); + Node.TEXT_NODE, mockPackageElementChildrenSingle, null); Element mockPackageElementMultiple = new MockElement("package", "fakeBody", "package", "fakeValue", - Node.TEXT_NODE, mockPackageElementChildrenMultiple, null); + Node.TEXT_NODE, mockPackageElementChildrenMultiple, null); // Attempt the global laod method using single child Elements first, and confirm the results are as expected. - XmlConfigurationProvider prov = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml", false); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork- test.xml"); prov.loadGlobalResults(testPackageConfigBuilder, mockPackageElementSingle); PackageConfig testPackageConfig = testPackageConfigBuilder.build(); Map currentGlobalResults = testPackageConfig.getAllGlobalResults(); @@ -606,9 +609,9 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { assertNotNull("inputResultParams (currentGlobalResults - single) is null ?", inputResultParams); assertNotNull("successResultParams (currentGlobalResults - single) is null ?", successResultParams); assertEquals("inputResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString ?", - fakeBodyString, inputResultParams.get(resultParam)); + fakeBodyString, inputResultParams.get(resultParam)); assertEquals("successResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString2 ?", - fakeBodyString2, successResultParams.get(resultParam)); + fakeBodyString2, successResultParams.get(resultParam)); // Attempt the global laod method using mutliple child Elements next, and confirm the results are as expected. prov.loadGlobalResults(testPackageConfigBuilder, mockPackageElementMultiple); testPackageConfig = testPackageConfigBuilder.build(); @@ -624,9 +627,9 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { assertNotNull("inputResultParams2 (currentGlobalResults - multiple) is null ?", inputResultParams2); assertNotNull("successResultParams2 (currentGlobalResults - multiple) is null ?", successResultParams2); assertEquals("inputResult2 (currentGlobalResults - multiple) resultParam value not equal to fakeBodyString ?", - fakeBodyString, inputResultParams2.get(resultParam)); + fakeBodyString, inputResultParams2.get(resultParam)); assertEquals("successResult2 (currentGlobalResults - multiple) resultParam value not equal to fakeBodyString2 ?", - fakeBodyString2, successResultParams2.get(resultParam)); + fakeBodyString2, successResultParams2.get(resultParam)); // Confirm the previous global results are still present inputResult = currentGlobalResults.get("input"); successResult = currentGlobalResults.get("success"); @@ -637,9 +640,9 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { assertNotNull("inputResultParams (currentGlobalResults - single) is null ?", inputResultParams); assertNotNull("successResultParams (currentGlobalResults - single) is null ?", successResultParams); assertEquals("inputResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString ?", - fakeBodyString, inputResultParams.get(resultParam)); + fakeBodyString, inputResultParams.get(resultParam)); assertEquals("successResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString2 ?", - fakeBodyString2, successResultParams.get(resultParam)); + fakeBodyString2, successResultParams.get(resultParam)); inputResult = currentGlobalResults.get("input"); successResult = currentGlobalResults.get("success"); assertNotNull("inputResult (currentGlobalResults - single) is null ?", inputResult); @@ -649,14 +652,14 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { assertNotNull("inputResultParams (currentGlobalResults - single) is null ?", inputResultParams); assertNotNull("successResultParams (currentGlobalResults - single) is null ?", successResultParams); assertEquals("inputResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString ?", - fakeBodyString, inputResultParams.get(resultParam)); + fakeBodyString, inputResultParams.get(resultParam)); assertEquals("successResult (currentGlobalResults - single) resultParam value not equal to fakeBodyString2 ?", - fakeBodyString2, successResultParams.get(resultParam)); + fakeBodyString2, successResultParams.get(resultParam)); } /** * Mock NodeList. - * + *

* Provides minimal functionality to permit limited mock DOM testing. */ protected class MockNodeList implements org.w3c.dom.NodeList { @@ -669,8 +672,8 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * Produces TEXT_NODE Nodes based on the input List of Strings. Node names * follow a simple pattern "nodeX" where X is the index. - * - * @param stringList + * + * @param stringList */ public MockNodeList(List stringList) { if (stringList != null) { @@ -737,7 +740,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * MockNode - * + *

* Provides minimal functionality to permit limited mock DOM testing. */ protected class MockNode implements org.w3c.dom.Node { @@ -854,7 +857,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { @Override public boolean hasChildNodes() { - return (childNodes != null ? childNodes.getLength() > 0 : false); + return (childNodes != null && childNodes.getLength() > 0); } @Override @@ -960,16 +963,16 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { /** * Mock Element. - * + *

* Provides minimal functionality to permit limited mock DOM testing. */ protected class MockElement extends MockNode implements org.w3c.dom.Element { final private String tagName; final private String tagBody; - final private Map attributes; + final private Map attributes; public MockElement(String tagName, String tagBody, - String nodeName, String nodeValue, short nodeType, NodeList childNodes, Node parentNode) { + String nodeName, String nodeValue, short nodeType, NodeList childNodes, Node parentNode) { super(nodeName, nodeValue, nodeType, childNodes, parentNode); this.tagName = nodeName; this.tagBody = nodeValue; diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java index 90141252e..3671de9b7 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java @@ -18,11 +18,17 @@ */ package com.opensymphony.xwork2.interceptor; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.SimpleFooAction; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.mock.MockActionInvocation; import com.opensymphony.xwork2.mock.MockActionProxy; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -44,6 +50,7 @@ import java.util.Map; * * * + * * @author Matthew Payne */ public class AliasInterceptorTest extends XWorkTestCase { @@ -52,7 +59,7 @@ public class AliasInterceptorTest extends XWorkTestCase { Map params = new HashMap<>(); params.put("aliasSource", "source here"); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", null, params); @@ -72,7 +79,7 @@ public class AliasInterceptorTest extends XWorkTestCase { httpParams.put("notExisting", "from http parameter"); params.put(ActionContext.PARAMETERS, HttpParameters.create(httpParams).build()); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", null, params); @@ -94,8 +101,8 @@ public class AliasInterceptorTest extends XWorkTestCase { MockActionProxy map = new MockActionProxy(); ActionConfig cfg = new ActionConfig.Builder("", "", "") - .addParam("aliases", "invalid alias expression") - .build(); + .addParam("aliases", "invalid alias expression") + .build(); map.setConfig(cfg); mai.setProxy(map); @@ -117,8 +124,8 @@ public class AliasInterceptorTest extends XWorkTestCase { MockActionProxy map = new MockActionProxy(); ActionConfig cfg = new ActionConfig.Builder("", "", "") - .addParam("hello", "invalid alias expression") - .build(); + .addParam("hello", "invalid alias expression") + .build(); map.setConfig(cfg); mai.setProxy(map); @@ -141,8 +148,8 @@ public class AliasInterceptorTest extends XWorkTestCase { MockActionProxy map = new MockActionProxy(); ActionConfig cfg = new ActionConfig.Builder("", "", "") - .addParam("hello", "invalid alias expression") - .build(); + .addParam("hello", "invalid alias expression") + .build(); map.setConfig(cfg); mai.setProxy(map); diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorWithConfigTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorWithConfigTest.java index cf0c6ee8a..ab1bfbf5f 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorWithConfigTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorWithConfigTest.java @@ -18,7 +18,14 @@ */ package com.opensymphony.xwork2.interceptor; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionChainResult; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ActionProxyFactory; +import com.opensymphony.xwork2.DefaultActionProxyFactory; +import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; @@ -30,15 +37,15 @@ import com.opensymphony.xwork2.config.entities.ResultConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.util.location.LocatableProperties; - -import java.util.*; - import org.apache.struts2.TestResult; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; + +import java.util.Collections; +import java.util.HashMap; /** * Unit test for {@link ChainingInterceptor} with a configuration provider. - * */ public class ChainingInterceptorWithConfigTest extends XWorkTestCase { @@ -59,13 +66,13 @@ public class ChainingInterceptorWithConfigTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-default.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml"); container.inject(provider); this.objectFactory = container.getInstance(ObjectFactory.class); loadConfigurationProviders(provider, new MockConfigurationProvider()); } - + private class MockConfigurationProvider implements ConfigurationProvider { private Configuration config; @@ -77,7 +84,8 @@ public class ChainingInterceptorWithConfigTest extends XWorkTestCase { return false; } - public void destroy() { } + public void destroy() { + } public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { @@ -101,17 +109,17 @@ public class ChainingInterceptorWithConfigTest extends XWorkTestCase { successParams2.put("propertyName", "blah"); successParams2.put("expectedValue", null); - InterceptorConfig chainingInterceptorConfig = new InterceptorConfig.Builder("chainStack", ChainingInterceptor.class.getName()).build(); + InterceptorConfig chainingInterceptorConfig = new InterceptorConfig.Builder("chainStack", ChainingInterceptor.class.getName()).build(); PackageConfig packageConfig = new PackageConfig.Builder("default") - .addActionConfig(CHAINED_ACTION, new ActionConfig.Builder("defaultPackage", CHAINED_ACTION, SimpleAction.class.getName()) - .addResultConfig(new ResultConfig.Builder(Action.ERROR, ActionChainResult.class.getName()).addParam("actionName", CHAINTO_ACTION).build()) - .build()) - .addActionConfig(CHAINTO_ACTION, new ActionConfig.Builder("defaultPackage", CHAINTO_ACTION, SimpleAction.class.getName()) - .addInterceptors(Collections.singletonList(new InterceptorMapping("chainStack", objectFactory.buildInterceptor(chainingInterceptorConfig, interceptorParams)))) - .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, TestResult.class.getName()).addParams(successParams1).build()) - .addResultConfig(new ResultConfig.Builder(Action.ERROR, TestResult.class.getName()).addParams(successParams2).build()) - .build()) - .build(); + .addActionConfig(CHAINED_ACTION, new ActionConfig.Builder("defaultPackage", CHAINED_ACTION, SimpleAction.class.getName()) + .addResultConfig(new ResultConfig.Builder(Action.ERROR, ActionChainResult.class.getName()).addParam("actionName", CHAINTO_ACTION).build()) + .build()) + .addActionConfig(CHAINTO_ACTION, new ActionConfig.Builder("defaultPackage", CHAINTO_ACTION, SimpleAction.class.getName()) + .addInterceptors(Collections.singletonList(new InterceptorMapping("chainStack", objectFactory.buildInterceptor(chainingInterceptorConfig, interceptorParams)))) + .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, TestResult.class.getName()).addParams(successParams1).build()) + .addResultConfig(new ResultConfig.Builder(Action.ERROR, TestResult.class.getName()).addParams(successParams2).build()) + .build()) + .build(); config.addPackageConfig("defaultPackage", packageConfig); config.addPackageConfig("default", new PackageConfig.Builder(packageConfig).name("default").build()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java index d2e0e1e3a..2eefbde4a 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java @@ -18,7 +18,14 @@ */ package com.opensymphony.xwork2.interceptor; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ModelDrivenAction; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.TestBean; +import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; @@ -32,13 +39,21 @@ import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor; import com.opensymphony.xwork2.util.CompoundRoot; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.ValueStackFactory; -import org.junit.Assert; import ognl.OgnlContext; import ognl.PropertyAccessor; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; +import org.junit.Assert; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** @@ -80,12 +95,12 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testInsecureParameters() throws Exception { // given - loadConfigurationProviders(new XWorkConfigurationProvider(), new XmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put("name", "(#context[\"xwork.MethodAccessor.denyMethodExecution\"]= new " + - "java.lang.Boolean(false), #_memberAccess[\"allowStaticMethodAccess\"]= new java.lang.Boolean(true), " + - "@java.lang.Runtime@getRuntime().exec('mkdir /tmp/PWNAGE'))(meh)"); + "java.lang.Boolean(false), #_memberAccess[\"allowStaticMethodAccess\"]= new java.lang.Boolean(true), " + + "@java.lang.Runtime@getRuntime().exec('mkdir /tmp/PWNAGE'))(meh)"); put("top['name'](0)", "true"); put("expression", "#f=#_memberAccess.getClass().getDeclaredField('allowStaticMethodAccess'),#f.setAccessible(true),#f.set(#_memberAccess,true),#req=@org.apache.struts2.ServletActionContext@getRequest(),#resp=@org.apache.struts2.ServletActionContext@getResponse().getWriter(),#resp.println(#req.getRealPath('/')),#resp.close()"); } @@ -117,7 +132,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution1 = "class.classLoader.jarPath"; final String pollution2 = "model.class.classLoader.jarPath"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new XmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); @@ -156,7 +171,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution2 = "model.class.classLoader.jarPath"; final String pollution3 = "class.classLoader.defaultAssertionStatus"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new XmlConfigurationProvider("xwork-class-param-test.xml")); + loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-class-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); @@ -240,14 +255,14 @@ public class ParametersInterceptorTest extends XWorkTestCase { Map params = new HashMap<>(); params.put("blah", "This is blah"); params.put("#session.foo", "Foo"); - params.put("\u0023session[\'user\']", "0wn3d"); - params.put("\\u0023session[\'user\']", "0wn3d"); + params.put("\u0023session['user']", "0wn3d"); + params.put("\\u0023session['user']", "0wn3d"); params.put("\u0023session.user2", "0wn3d"); params.put("\\u0023session.user2", "0wn3d"); - params.put("('\u0023'%20%2b%20'session[\'user3\']')(unused)", "0wn3d"); + params.put("('\u0023'%20%2b%20'session['user3']')(unused)", "0wn3d"); params.put("('\\u0023' + 'session[\\'user4\\']')(unused)", "0wn3d"); - params.put("('\u0023'%2b'session[\'user5\']')(unused)", "0wn3d"); - params.put("('\\u0023'%2b'session[\'user5\']')(unused)", "0wn3d"); + params.put("('\u0023'%2b'session['user5']')(unused)", "0wn3d"); + params.put("('\\u0023'%2b'session['user5']')(unused)", "0wn3d"); HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build()); @@ -275,7 +290,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution5 = "class['classLoader']['jarPath']"; final String pollution6 = "class[\"classLoader\"]['jarPath']"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new XmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); @@ -518,8 +533,8 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testEvalExpressionAsParameterName() throws Exception { Map params = new HashMap<>(); params.put("blah", "(#context[\"xwork.MethodAccessor.denyMethodExecution\"]= new " + - "java.lang.Boolean(false), #_memberAccess[\"allowStaticMethodAccess\"]= new java.lang.Boolean(true), " + - "@java.lang.Runtime@getRuntime().exec('mkdir /tmp/PWNAGE'))(meh)"); + "java.lang.Boolean(false), #_memberAccess[\"allowStaticMethodAccess\"]= new java.lang.Boolean(true), " + + "@java.lang.Runtime@getRuntime().exec('mkdir /tmp/PWNAGE'))(meh)"); params.put("top['blah'](0)", "true"); HashMap extraContext = new HashMap<>(); @@ -552,10 +567,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testNonexistentParametersGetLoggedInDevMode() throws Exception { - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, - new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "true"))); + new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "true"))); Map params = new HashMap<>(); params.put("not_a_property", "There is no action property named like this"); @@ -571,10 +586,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testNonexistentParametersAreIgnoredInProductionMode() throws Exception { - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, - new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "false"))); + new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "false"))); Map params = new HashMap<>(); params.put("not_a_property", "There is no action property named like this"); @@ -717,13 +732,13 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testBeanListSingleValue() throws Exception { Map params = new HashMap<>(); - params.put("beanList.name", new String[] { "Superman" }); + params.put("beanList.name", new String[]{"Superman"}); HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build()); ActionProxy proxy = actionProxyFactory.createActionProxy("", - MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); + MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); proxy.execute(); SimpleAction action = (SimpleAction) proxy.getAction(); assertNotNull(action); @@ -762,9 +777,9 @@ public class ParametersInterceptorTest extends XWorkTestCase { private ValueStack createStubValueStack(final Map actual) { ValueStack stack = new OgnlValueStack( - container.getInstance(XWorkConverter.class), - (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()), - container.getInstance(TextProvider.class, "system"), true, true) { + container.getInstance(XWorkConverter.class), + (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()), + container.getInstance(TextProvider.class, "system"), true, true) { @Override public void setValue(String expr, Object value) { actual.put(expr, value); @@ -804,7 +819,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); @@ -816,7 +831,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { class ValidateAction implements ValidationAware { - private List messages = new LinkedList<>(); + private final List messages = new LinkedList<>(); private String name; public void setActionErrors(Collection errorMessages) { diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java index 7019edaa5..425bdeef1 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java @@ -18,7 +18,12 @@ */ package com.opensymphony.xwork2.interceptor.annotations; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ActionProxyFactory; +import com.opensymphony.xwork2.DefaultActionProxyFactory; +import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; @@ -30,6 +35,7 @@ import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.mock.MockResult; import com.opensymphony.xwork2.util.location.LocatableProperties; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.Collections; @@ -43,9 +49,9 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase { private final AnnotationWorkflowInterceptor annotationWorkflow = new AnnotationWorkflowInterceptor(); @Override - public void setUp() throws Exception{ + public void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-default.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); } @@ -53,14 +59,14 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase { public void testInterceptsBeforeAndAfter() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy("", ANNOTATED_ACTION, null, null); assertEquals(Action.SUCCESS, proxy.execute()); - AnnotatedAction action = (AnnotatedAction)proxy.getInvocation().getAction(); + AnnotatedAction action = (AnnotatedAction) proxy.getInvocation().getAction(); assertEquals("interfaceBefore-baseBefore-basePrivateBefore-before-execute-beforeResult-basePrivateBeforeResult-interfaceBeforeResult-after-basePrivateAfter-interfaceAfter", action.log); } public void testInterceptsShortcircuitedAction() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy("", SHORTCIRCUITED_ACTION, null, null); assertEquals("shortcircuit", proxy.execute()); - ShortcircuitedAction action = (ShortcircuitedAction)proxy.getInvocation().getAction(); + ShortcircuitedAction action = (ShortcircuitedAction) proxy.getInvocation().getAction(); assertEquals("interfaceBefore-baseBefore-basePrivateBefore-before-basePrivateBeforeResult-interfaceBeforeResult", action.log); } @@ -75,7 +81,8 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase { return false; } - public void destroy() { } + public void destroy() { + } public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { @@ -89,15 +96,15 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase { public void loadPackages() throws ConfigurationException { PackageConfig packageConfig = new PackageConfig.Builder("default") - .addActionConfig(ANNOTATED_ACTION, new ActionConfig.Builder("defaultPackage", ANNOTATED_ACTION, AnnotatedAction.class.getName()) - .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) - .addResultConfig(new ResultConfig.Builder("success", MockResult.class.getName()).build()) - .build()) - .addActionConfig(SHORTCIRCUITED_ACTION, new ActionConfig.Builder("defaultPackage", SHORTCIRCUITED_ACTION, ShortcircuitedAction.class.getName()) - .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) - .addResultConfig(new ResultConfig.Builder("shortcircuit", MockResult.class.getName()).build()) - .build()) - .build(); + .addActionConfig(ANNOTATED_ACTION, new ActionConfig.Builder("defaultPackage", ANNOTATED_ACTION, AnnotatedAction.class.getName()) + .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) + .addResultConfig(new ResultConfig.Builder("success", MockResult.class.getName()).build()) + .build()) + .addActionConfig(SHORTCIRCUITED_ACTION, new ActionConfig.Builder("defaultPackage", SHORTCIRCUITED_ACTION, ShortcircuitedAction.class.getName()) + .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) + .addResultConfig(new ResultConfig.Builder("shortcircuit", MockResult.class.getName()).build()) + .build()) + .build(); config.addPackageConfig("defaultPackage", packageConfig); config.addPackageConfig("default", new PackageConfig.Builder(packageConfig).name("default").build()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/SecurityMemberAccessProxyTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/SecurityMemberAccessProxyTest.java index 62a9d07fa..eff352b22 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ognl/SecurityMemberAccessProxyTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ognl/SecurityMemberAccessProxyTest.java @@ -18,13 +18,14 @@ */ package com.opensymphony.xwork2.ognl; -import java.lang.reflect.Member; -import java.util.HashMap; -import java.util.Map; - import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; + +import java.lang.reflect.Member; +import java.util.HashMap; +import java.util.Map; public class SecurityMemberAccessProxyTest extends XWorkTestCase { private Map context; @@ -35,14 +36,14 @@ public class SecurityMemberAccessProxyTest extends XWorkTestCase { context = new HashMap<>(); // Set up XWork - XmlConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); container.inject(provider); loadConfigurationProviders(provider); } public void testProxyAccessIsBlocked() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy(null, - "chaintoAOPedTestSubBeanAction", null, context); + "chaintoAOPedTestSubBeanAction", null, context); SecurityMemberAccess sma = new SecurityMemberAccess(false, true); sma.setDisallowProxyMemberAccess(true); @@ -55,7 +56,7 @@ public class SecurityMemberAccessProxyTest extends XWorkTestCase { public void testProxyAccessIsAccessible() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy(null, - "chaintoAOPedTestSubBeanAction", null, context); + "chaintoAOPedTestSubBeanAction", null, context); SecurityMemberAccess sma = new SecurityMemberAccess(false, true); diff --git a/core/src/test/java/com/opensymphony/xwork2/spring/ActionsFromSpringTest.java b/core/src/test/java/com/opensymphony/xwork2/spring/ActionsFromSpringTest.java index 971c4db91..65a3700af 100644 --- a/core/src/test/java/com/opensymphony/xwork2/spring/ActionsFromSpringTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/spring/ActionsFromSpringTest.java @@ -18,9 +18,16 @@ */ package com.opensymphony.xwork2.spring; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.TestSubBean; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import org.apache.commons.lang3.reflect.MethodUtils; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import org.springframework.context.ApplicationContext; @@ -35,14 +42,15 @@ import java.util.Map; public class ActionsFromSpringTest extends XWorkTestCase { private ApplicationContext appContext; - @Override public void setUp() throws Exception { + @Override + public void setUp() throws Exception { super.setUp(); // Set up XWork - XmlConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); container.inject(provider); loadConfigurationProviders(provider); - appContext = ((SpringObjectFactory)container.getInstance(ObjectFactory.class)).appContext; + appContext = ((SpringObjectFactory) container.getInstance(ObjectFactory.class)).appContext; } public void testLoadSimpleAction() throws Exception { @@ -87,20 +95,20 @@ public class ActionsFromSpringTest extends XWorkTestCase { String result = action.execute(); assertEquals(Action.INPUT, result); } - + public void testActionWithSpringResult() throws Exception { - ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleActionSpringResult", null, null); - - proxy.execute(); - - SpringResult springResult = (SpringResult) proxy.getInvocation().getResult(); - assertTrue(springResult.isInitialize()); - assertNotNull(springResult.getStringParameter()); + ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleActionSpringResult", null, null); + + proxy.execute(); + + SpringResult springResult = (SpringResult) proxy.getInvocation().getResult(); + assertTrue(springResult.isInitialize()); + assertNotNull(springResult.getStringParameter()); } public void testChainingProxiedActions() throws Exception { ActionProxy proxy = actionProxyFactory.createActionProxy(null, "chainedAOPedTestBeanAction", - null, null); + null, null); proxy.execute(); @@ -131,7 +139,7 @@ public class ActionsFromSpringTest extends XWorkTestCase { extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build()); ActionProxy proxy = actionProxyFactory.createActionProxy(null, - "chaintoAOPedTestSubBeanAction", null, extraContext); + "chaintoAOPedTestSubBeanAction", null, extraContext); // when proxy.execute(); @@ -140,6 +148,6 @@ public class ActionsFromSpringTest extends XWorkTestCase { //then assertEquals("S2-047", ((TestSubBean) action).getIssueId()); assertFalse("proxied action is accessible!", - (boolean) MethodUtils.invokeMethod(action, "isExposeProxy")); + (boolean) MethodUtils.invokeMethod(action, "isExposeProxy")); } } diff --git a/core/src/test/java/com/opensymphony/xwork2/spring/SpringProxyUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/spring/SpringProxyUtilTest.java index ce19976d3..7b77294e5 100644 --- a/core/src/test/java/com/opensymphony/xwork2/spring/SpringProxyUtilTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/spring/SpringProxyUtilTest.java @@ -18,26 +18,31 @@ */ package com.opensymphony.xwork2.spring; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.TestBean; +import com.opensymphony.xwork2.TestSubBean; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.util.ProxyUtil; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.springframework.context.ApplicationContext; /** * Test various utility methods dealing with spring proxies. - * */ public class SpringProxyUtilTest extends XWorkTestCase { private ApplicationContext appContext; - @Override public void setUp() throws Exception { + @Override + public void setUp() throws Exception { super.setUp(); // Set up XWork - XmlConfigurationProvider provider = new XmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/spring/actionContext-xwork.xml"); container.inject(provider); loadConfigurationProviders(provider); - appContext = ((SpringObjectFactory)container.getInstance(ObjectFactory.class)).appContext; + appContext = ((SpringObjectFactory) container.getInstance(ObjectFactory.class)).appContext; } public void testIsProxy() throws Exception { @@ -91,26 +96,26 @@ public class SpringProxyUtilTest extends XWorkTestCase { Object simpleAction = appContext.getBean("simple-action"); assertFalse(ProxyUtil.isProxyMember( - simpleAction.getClass().getMethod("setName", String.class), simpleAction)); + simpleAction.getClass().getMethod("setName", String.class), simpleAction)); Object proxiedAction = appContext.getBean("proxied-action"); assertTrue(ProxyUtil.isProxyMember( - proxiedAction.getClass().getMethod("setExposeProxy", boolean.class), proxiedAction)); + proxiedAction.getClass().getMethod("setExposeProxy", boolean.class), proxiedAction)); Object autoProxiedAction = appContext.getBean("auto-proxied-action"); assertTrue(ProxyUtil.isProxyMember( - autoProxiedAction.getClass().getMethod("getTargetClass"), autoProxiedAction)); + autoProxiedAction.getClass().getMethod("getTargetClass"), autoProxiedAction)); Object pointcuttedTestBean = appContext.getBean("pointcutted-test-bean"); assertTrue(ProxyUtil.isProxyMember( - pointcuttedTestBean.getClass().getMethod("getTargetSource"), pointcuttedTestBean)); + pointcuttedTestBean.getClass().getMethod("getTargetSource"), pointcuttedTestBean)); Object pointcuttedTestSubBean = appContext.getBean("pointcutted-test-sub-bean"); assertFalse(ProxyUtil.isProxyMember( - pointcuttedTestSubBean.getClass().getConstructor(), pointcuttedTestSubBean)); + pointcuttedTestSubBean.getClass().getConstructor(), pointcuttedTestSubBean)); Object testAspect = appContext.getBean("test-aspect"); assertFalse(ProxyUtil.isProxyMember( - testAspect.getClass().getMethod("setExposeProxy", boolean.class), testAspect)); + testAspect.getClass().getMethod("setExposeProxy", boolean.class), testAspect)); } } diff --git a/core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java index afcd2625a..970c3ee8d 100644 --- a/core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java @@ -18,8 +18,13 @@ */ package com.opensymphony.xwork2.spring.interceptor; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.TestBean; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.springframework.context.ApplicationContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; @@ -52,10 +57,10 @@ public class ActionAutowiringInterceptorTest extends XWorkTestCase { } public void testSetAutowireType() throws Exception { - XmlConfigurationProvider prov = new XmlConfigurationProvider("xwork-default.xml"); + XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("xwork-default.xml"); container.inject(prov); prov.setThrowExceptionOnDuplicateBeans(false); - XmlConfigurationProvider c = new XmlConfigurationProvider("com/opensymphony/xwork2/spring/xwork-autowire.xml"); + XmlConfigurationProvider c = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/spring/xwork-autowire.xml"); container.inject(c); loadConfigurationProviders(c, prov); diff --git a/core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java b/core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java index ab72a9f49..5921db0dd 100644 --- a/core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java @@ -22,10 +22,10 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; -import java.util.Map; /** * MyBeanActionTest @@ -133,7 +133,7 @@ public class MyBeanActionTest extends XWorkTestCase { super.setUp(); // ensure we're using the default configuration, not simple config - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); } 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 251217a0b..aef469dd8 100644 --- a/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProviderTest.java @@ -19,10 +19,19 @@ package com.opensymphony.xwork2.util; import com.mockobjects.dynamic.Mock; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.LocalizedTextProvider; +import com.opensymphony.xwork2.ModelDriven; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.test.ModelDrivenAction2; import com.opensymphony.xwork2.test.TestBean2; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.text.DateFormat; import java.text.ParseException; @@ -37,52 +46,52 @@ import java.util.ResourceBundle; * * @author jcarreira * @author tm_jee - * * @version $Date$ $Id$ */ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { private LocalizedTextProvider localizedTextProvider; - - public void testNpeWhenClassIsPrimitive() throws Exception { - ValueStack stack = ActionContext.getContext().getValueStack(); - stack.push(new MyObject()); - String result = localizedTextProvider.findText(MyObject.class, "someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack); - System.out.println(result); - } - - public static class MyObject extends ActionSupport { - public boolean getSomeObj() { - return true; - } - } - - public void testActionGetTextWithNullObject() throws Exception { - MyAction action = new MyAction(); + + public void testNpeWhenClassIsPrimitive() throws Exception { + ValueStack stack = ActionContext.getContext().getValueStack(); + stack.push(new MyObject()); + String result = localizedTextProvider.findText(MyObject.class, "someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack); + System.out.println(result); + } + + public static class MyObject extends ActionSupport { + public boolean getSomeObj() { + return true; + } + } + + public void testActionGetTextWithNullObject() throws Exception { + MyAction action = new MyAction(); container.inject(action); - - Mock mockActionInvocation = new Mock(ActionInvocation.class); + + Mock mockActionInvocation = new Mock(ActionInvocation.class); mockActionInvocation.expectAndReturn("getAction", action); ActionContext.getContext() .withActionInvocation((ActionInvocation) mockActionInvocation.proxy()) - .getValueStack().push(action); - - String message = action.getText("barObj.title"); - assertEquals("Title:", message); - } - - - public static class MyAction extends ActionSupport { - private Bar testBean2; - - public Bar getBarObj() { - return testBean2; - } - public void setBarObj(Bar testBean2) { - this.testBean2 = testBean2; - } - } - + .getValueStack().push(action); + + String message = action.getText("barObj.title"); + assertEquals("Title:", message); + } + + + public static class MyAction extends ActionSupport { + private Bar testBean2; + + public Bar getBarObj() { + return testBean2; + } + + public void setBarObj(Bar testBean2) { + this.testBean2 = testBean2; + } + } + public void testActionGetText() throws Exception { ModelDrivenAction2 action = new ModelDrivenAction2(); container.inject(action); @@ -207,7 +216,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { public void testLocalizedDateFormatIsUsed() throws ParseException { localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest"); Date date = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse("01/01/2015"); - Object[] params = new Object[]{ date }; + Object[] params = new Object[]{date}; String usDate = localizedTextProvider.findDefaultText("test.format.date", Locale.US, params); String germanDate = localizedTextProvider.findDefaultText("test.format.date", Locale.GERMANY, params); assertEquals(usDate, "1/1/15"); @@ -253,26 +262,26 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { /** * Unit test to confirm expected behaviour of "clearing methods" provided to - * StrutsLocalizedTextProvider (from AbstractLocalizedTextProvider). + * StrutsLocalizedTextProvider (from AbstractLocalizedTextProvider). * * @since 2.6 */ public void testLocalizedTextProviderClearingMethods() { TestStrutsLocalizedTextProvider testStrutsLocalizedTextProvider = new TestStrutsLocalizedTextProvider(); assertTrue("testStrutsLocalizedTextProvider not instance of AbstractLocalizedTextProvider ?", - testStrutsLocalizedTextProvider instanceof AbstractLocalizedTextProvider); + testStrutsLocalizedTextProvider instanceof AbstractLocalizedTextProvider); assertEquals("testStrutsLocalizedTextProvider starting default bundle map size not 0 before any retrievals ?", - 0, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 0, testStrutsLocalizedTextProvider.currentBundlesMapSize()); // Access the two default bundles to populate their cache entries and test bundle map size. ResourceBundle tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - TestStrutsLocalizedTextProvider.XWORK_MESSAGES_BUNDLE, Locale.ENGLISH); + TestStrutsLocalizedTextProvider.XWORK_MESSAGES_BUNDLE, Locale.ENGLISH); assertNotNull("XWORK_MESSAGES_BUNDLE retrieval null ?", tempBundle); tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - TestStrutsLocalizedTextProvider.STRUTS_MESSAGES_BUNDLE, Locale.ENGLISH); + TestStrutsLocalizedTextProvider.STRUTS_MESSAGES_BUNDLE, Locale.ENGLISH); assertNotNull("STRUTS_MESSAGES_BUNDLE retrieval null ?", tempBundle); assertEquals("testStrutsLocalizedTextProvider bundle map size not 2 after retrievals ?", - 2, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 2, testStrutsLocalizedTextProvider.currentBundlesMapSize()); // Add and then access four test bundles to populate their cache entries and test bundle map size. testStrutsLocalizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest"); @@ -280,39 +289,39 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { testStrutsLocalizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction"); testStrutsLocalizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/test"); tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - "com/opensymphony/xwork2/util/LocalizedTextUtilTest", Locale.ENGLISH); + "com/opensymphony/xwork2/util/LocalizedTextUtilTest", Locale.ENGLISH); assertNotNull("com/opensymphony/xwork2/util/LocalizedTextUtilTest retrieval null ?", tempBundle); tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - "com/opensymphony/xwork2/util/FindMe", Locale.ENGLISH); + "com/opensymphony/xwork2/util/FindMe", Locale.ENGLISH); assertNotNull("com/opensymphony/xwork2/util/FindMe retrieval null ?", tempBundle); tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - "com/opensymphony/xwork2/SimpleAction", Locale.ENGLISH); + "com/opensymphony/xwork2/SimpleAction", Locale.ENGLISH); assertNotNull("com/opensymphony/xwork2/SimpleAction retrieval null ?", tempBundle); tempBundle = testStrutsLocalizedTextProvider.findResourceBundle( - "com/opensymphony/xwork2/test", Locale.ENGLISH); + "com/opensymphony/xwork2/test", Locale.ENGLISH); assertNotNull("com/opensymphony/xwork2/test retrieval null ?", tempBundle); assertEquals("testStrutsLocalizedTextProvider bundle map size not 6 after retrievals ?", - 6, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 6, testStrutsLocalizedTextProvider.currentBundlesMapSize()); // Expect the call to be ineffective due to deprecation and change to a "no-op" (but shouldn't throw an Exception or cause failure). testStrutsLocalizedTextProvider.callClearBundleNoLocale("com/opensymphony/xwork2/test"); assertEquals("testStrutsLocalizedTextProvider bundle map size not 6 after non-locale clear call ?", - 6, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 6, testStrutsLocalizedTextProvider.currentBundlesMapSize()); // Expect the call to function with bundle name + locale. Remove all four of the non-default // bundles and confirm the bundle map size changes. testStrutsLocalizedTextProvider.callClearBundleWithLocale("com/opensymphony/xwork2/test", Locale.ENGLISH); assertEquals("testStrutsLocalizedTextProvider bundle map size not 5 after locale clear call ?", - 5, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 5, testStrutsLocalizedTextProvider.currentBundlesMapSize()); testStrutsLocalizedTextProvider.callClearBundleWithLocale("com/opensymphony/xwork2/SimpleAction", Locale.ENGLISH); assertEquals("testStrutsLocalizedTextProvider bundle map size not 4 after locale clear call ?", - 4, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 4, testStrutsLocalizedTextProvider.currentBundlesMapSize()); testStrutsLocalizedTextProvider.callClearBundleWithLocale("com/opensymphony/xwork2/util/FindMe", Locale.ENGLISH); assertEquals("testStrutsLocalizedTextProvider bundle map size not 3 after locale clear call ?", - 3, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 3, testStrutsLocalizedTextProvider.currentBundlesMapSize()); testStrutsLocalizedTextProvider.callClearBundleWithLocale("com/opensymphony/xwork2/util/LocalizedTextUtilTest", Locale.ENGLISH); assertEquals("testStrutsLocalizedTextProvider bundle map size not 2 after locale clear call ?", - 2, testStrutsLocalizedTextProvider.currentBundlesMapSize()); + 2, testStrutsLocalizedTextProvider.currentBundlesMapSize()); // Confirm the missing bundles cache clearing method does not produce any Exceptions or failures. testStrutsLocalizedTextProvider.callClearMissingBundlesCache(); @@ -321,12 +330,12 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); localizedTextProvider = container.getInstance(LocalizedTextProvider.class); - + ActionContext.getContext().withLocale(Locale.US); } @@ -345,7 +354,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase { public void callClearBundleNoLocale(String bundleName) { super.clearBundle(bundleName); -} + } public void callClearBundleWithLocale(String bundleName, Locale locale) { super.clearBundle(bundleName, locale); diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeFieldValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeFieldValidatorTest.java index de9a9440f..41da48fd3 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeFieldValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeFieldValidatorTest.java @@ -29,9 +29,9 @@ import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; -import java.lang.reflect.Array; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -306,7 +306,7 @@ public class DoubleRangeFieldValidatorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-default.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); val = new DoubleRangeFieldValidator(); diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/IntRangeValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/IntRangeValidatorTest.java index f11870dea..fefece9a9 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/IntRangeValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/IntRangeValidatorTest.java @@ -20,10 +20,11 @@ package com.opensymphony.xwork2.validator; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.interceptor.ValidationAware; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -63,7 +64,7 @@ public class IntRangeValidatorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/LongRangeValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/LongRangeValidatorTest.java index 381a1e276..4a24ca8b4 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/LongRangeValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/LongRangeValidatorTest.java @@ -20,10 +20,11 @@ package com.opensymphony.xwork2.validator; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.interceptor.ValidationAware; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -60,7 +61,7 @@ public class LongRangeValidatorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/ModelDrivenValidationTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/ModelDrivenValidationTest.java index b29b819dc..af594617b 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/ModelDrivenValidationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/ModelDrivenValidationTest.java @@ -18,8 +18,13 @@ */ package com.opensymphony.xwork2.validator; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ModelDrivenAction; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -31,7 +36,7 @@ import java.util.Map; * ModelDrivenValidationTest * * @author Jason Carreira - * Created Oct 1, 2003 10:08:25 AM + * Created Oct 1, 2003 10:08:25 AM */ public class ModelDrivenValidationTest extends XWorkTestCase { @@ -42,7 +47,7 @@ public class ModelDrivenValidationTest extends XWorkTestCase { Map context = new HashMap<>(); context.put(ActionContext.PARAMETERS, HttpParameters.create(params).build()); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml"); container.inject(provider); loadConfigurationProviders(provider); ActionProxy proxy = actionProxyFactory.createActionProxy(null, "TestModelDrivenValidation", null, context); diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/ShortRangeValidatorTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/ShortRangeValidatorTest.java index 9ed534da4..abada8f3d 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/ShortRangeValidatorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/ShortRangeValidatorTest.java @@ -20,10 +20,11 @@ package com.opensymphony.xwork2.validator; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.interceptor.ValidationAware; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.HashMap; @@ -60,7 +61,7 @@ public class ShortRangeValidatorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java index c866ee4ea..503d23081 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java @@ -18,15 +18,24 @@ */ package com.opensymphony.xwork2.validator; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.SimpleAction; +import com.opensymphony.xwork2.TextProviderFactory; +import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.validator.validators.ValidatorSupport; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; /** @@ -229,14 +238,14 @@ public class SimpleActionValidationTest extends XWorkTestCase { public void testInitializable() throws Exception { ValidatorFactory validatorFactory = container.getInstance(ValidatorFactory.class); assertEquals("com.opensymphony.xwork2.validator.validators.RequiredFieldValidator", - validatorFactory.lookupRegisteredValidatorType("requiredAnother")); + validatorFactory.lookupRegisteredValidatorType("requiredAnother")); } @Override protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml"); + XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml"); container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider()); } diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/ValidatorAnnotationTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/ValidatorAnnotationTest.java index 08cab704e..100521a35 100644 --- a/core/src/test/java/com/opensymphony/xwork2/validator/ValidatorAnnotationTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/validator/ValidatorAnnotationTest.java @@ -20,9 +20,10 @@ package com.opensymphony.xwork2.validator; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.interceptor.ValidationAware; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.apache.struts2.dispatcher.HttpParameters; import java.util.Collection; @@ -127,9 +128,9 @@ public class ValidatorAnnotationTest extends XWorkTestCase { protected void setUp() throws Exception { super.setUp(); - XmlConfigurationProvider provider1 = new XmlConfigurationProvider("xwork-default.xml"); + XmlConfigurationProvider provider1 = new StrutsXmlConfigurationProvider("xwork-default.xml"); container.inject(provider1); - XmlConfigurationProvider provider2 = new XmlConfigurationProvider("xwork-test-validation.xml"); + XmlConfigurationProvider provider2 = new StrutsXmlConfigurationProvider("xwork-test-validation.xml"); container.inject(provider2); loadConfigurationProviders(provider1, provider2); } diff --git a/core/src/test/java/org/apache/struts2/factory/PrefixBasedActionProxyFactoryTest.java b/core/src/test/java/org/apache/struts2/factory/PrefixBasedActionProxyFactoryTest.java index 109a61fec..01d2bd4f2 100644 --- a/core/src/test/java/org/apache/struts2/factory/PrefixBasedActionProxyFactoryTest.java +++ b/core/src/test/java/org/apache/struts2/factory/PrefixBasedActionProxyFactoryTest.java @@ -23,7 +23,6 @@ import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.DefaultActionProxyFactory; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.inject.Context; import com.opensymphony.xwork2.inject.Factory; @@ -32,6 +31,7 @@ import com.opensymphony.xwork2.mock.MockActionProxy; import com.opensymphony.xwork2.test.StubConfigurationProvider; import com.opensymphony.xwork2.util.location.LocatableProperties; import org.apache.struts2.StrutsInternalTestCase; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.Collections; import java.util.Map; @@ -43,63 +43,65 @@ public class PrefixBasedActionProxyFactoryTest extends StrutsInternalTestCase { public void testDifferentPrefixes() throws Exception { initFactory("/ns1:prefix1,/ns2:prefix2"); - ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); + ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); assertTrue(proxy1 instanceof Prefix1ActionProxy); - ActionProxy proxy2 = factory.createActionProxy("/ns2", "", "", Collections.emptyMap(), false, true); + ActionProxy proxy2 = factory.createActionProxy("/ns2", "", "", Collections.emptyMap(), false, true); assertTrue(proxy2 instanceof Prefix2ActionProxy); } public void testFallbackToDefault() throws Exception { initFactory("/ns1:prefix1"); - ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); + ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); assertTrue(proxy1 instanceof Prefix1ActionProxy); - ActionProxy proxy2 = factory.createActionProxy("", "Foo", "", Collections.emptyMap(), false, true); + ActionProxy proxy2 = factory.createActionProxy("", "Foo", "", Collections.emptyMap(), false, true); assertTrue(proxy2 instanceof StrutsActionProxy); } public void testEmptyPrefix() throws Exception { initFactory(":prefix1"); - ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); + ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true); assertTrue(proxy1 instanceof Prefix1ActionProxy); - ActionProxy proxy2 = factory.createActionProxy("/ns2", "", "", Collections.emptyMap(), false, true); + ActionProxy proxy2 = factory.createActionProxy("/ns2", "", "", Collections.emptyMap(), false, true); assertTrue(proxy2 instanceof Prefix1ActionProxy); } @Override public void setUp() throws Exception { ConfigurationProvider[] providers = new ConfigurationProvider[]{ - new XmlConfigurationProvider("xwork-sample.xml"), - new StubConfigurationProvider() { - @Override - public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { - builder.factory(ActionProxyFactory.class, "prefix1", new Factory() { - public Object create(Context context) throws Exception { - return new Prefix1Factory(); - } - public Class type() { - return Prefix1Factory.class; - } - }, Scope.SINGLETON); - } - }, - new StubConfigurationProvider() { - @Override - public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { - builder.factory(ActionProxyFactory.class, "prefix2", new Factory() { - public Object create(Context context) throws Exception { - return new Prefix2Factory(); - } - public Class type() { - return Prefix2Factory.class; - } - }, Scope.SINGLETON); - } + new StrutsXmlConfigurationProvider("xwork-sample.xml"), + new StubConfigurationProvider() { + @Override + public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { + builder.factory(ActionProxyFactory.class, "prefix1", new Factory() { + public Object create(Context context) throws Exception { + return new Prefix1Factory(); + } + + public Class type() { + return Prefix1Factory.class; + } + }, Scope.SINGLETON); } + }, + new StubConfigurationProvider() { + @Override + public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { + builder.factory(ActionProxyFactory.class, "prefix2", new Factory() { + public Object create(Context context) throws Exception { + return new Prefix2Factory(); + } + + public Class type() { + return Prefix2Factory.class; + } + }, Scope.SINGLETON); + } + } }; loadConfigurationProviders(providers); diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder1/xwork-test-load-order.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder1/xwork-test-load-order.xml index 5b0e6e8b5..e66737355 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder1/xwork-test-load-order.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder1/xwork-test-load-order.xml @@ -19,10 +19,9 @@ * under the License. */ --> - + - - + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder2/xwork-test-load-order.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder2/xwork-test-load-order.xml index 6cb1ef2aa..8cbf2d7ae 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder2/xwork-test-load-order.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder2/xwork-test-load-order.xml @@ -19,10 +19,9 @@ * under the License. */ --> - + - - + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder3/xwork-test-load-order.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder3/xwork-test-load-order.xml index 61653aeb3..03d16f94b 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder3/xwork-test-load-order.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/loadorder3/xwork-test-load-order.xml @@ -19,10 +19,9 @@ * under the License. */ --> - + - - + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork- test.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork- test.xml index 50bc3dab7..456a725fb 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork- test.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork- test.xml @@ -19,13 +19,11 @@ * under the License. */ --> - - - - + + + @@ -55,7 +53,7 @@ 23 foo.jspa?fooID=${fooID}&something=bar - something + something @@ -63,19 +61,19 @@ 18 24 - + - + 18 24 - + @@ -99,4 +97,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package-2.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package-2.xml index 7e7b7ee70..bf6df3e2e 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package-2.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package-2.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -32,4 +30,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package.xml index d45f8d6d7..06d213d82 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-after-package.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -38,4 +36,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package-2.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package-2.xml index 0e4a0ef74..aeae5a6da 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package-2.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package-2.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -32,4 +30,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package.xml index 67a08b4d8..c68115b83 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-before-package.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -40,4 +38,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml index 852a7fed2..dbd77959d 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -40,4 +38,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-action-invalid.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-action-invalid.xml index efe439329..53b9a2fcf 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-action-invalid.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-action-invalid.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -41,4 +39,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions-packagedefaultclassref.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions-packagedefaultclassref.xml index 6b0008b2c..c2717befc 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions-packagedefaultclassref.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions-packagedefaultclassref.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -57,4 +55,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions.xml index 50bc3dab7..456a725fb 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-actions.xml @@ -19,13 +19,11 @@ * under the License. */ --> - - - - + + + @@ -55,7 +53,7 @@ 23 foo.jspa?fooID=${fooID}&something=bar - something + something @@ -63,19 +61,19 @@ 18 24 - + - + 18 24 - + @@ -99,4 +97,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml index 394537e8a..17b33ab38 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + input,cancel @@ -68,4 +66,4 @@ foo,bar - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-bad-inheritance.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-bad-inheritance.xml index 92e1b93c1..d271a1c42 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-bad-inheritance.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-bad-inheritance.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -35,4 +33,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-basic-packages.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-basic-packages.xml index 75aee6f97..ccd8aed7a 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-basic-packages.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-basic-packages.xml @@ -19,16 +19,14 @@ * under the License. */ --> - + + + + - - - + - - - - + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-default-package.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-default-package.xml index 4f13c71d9..2c566d20b 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-default-package.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-default-package.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-defaultclassref-package.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-defaultclassref-package.xml index d352213e7..adc41eb11 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-defaultclassref-package.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-defaultclassref-package.xml @@ -19,14 +19,12 @@ * under the License. */ --> - - - + + - + - \ No newline at end of file + \ No newline at end of file diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-envs-substitution.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-envs-substitution.xml index 47c2d946d..03fe2b715 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-envs-substitution.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-envs-substitution.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -43,4 +41,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml index b7f955e5c..71f607012 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -51,4 +49,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml index db46c1866..461c2e17a 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml @@ -19,50 +19,48 @@ * under the License. */ --> - - - - - - - - - - - p1 - - - p2 - - - - + + + + + + + + + + p1 + + + p2 + + + + - - - - - - - a1 - - - a2 - - - - + + + + + + + a1 + + + a2 + + + + - - - - c1 - - - - - + + + + c1 + + + + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-include-wildcard.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-include-wildcard.xml index 573d55eb8..a9ef73178 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-include-wildcard.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-include-wildcard.xml @@ -19,11 +19,9 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml index 3902c3b33..7cde9bcd1 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-defaultref.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -48,4 +46,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-inheritance.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-inheritance.xml index a20a87358..929a0181f 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-inheritance.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-inheritance.xml @@ -19,13 +19,11 @@ * under the License. */ --> - - - - + + + @@ -52,4 +50,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml index d18d1a438..660f6dcdd 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml @@ -19,11 +19,10 @@ * under the License. */ --> - - - + + @@ -60,5 +59,5 @@ test2 - + \ No newline at end of file diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-params.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-params.xml index 4943bbce0..32c4099a6 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-params.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-params.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -55,4 +53,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml index c9a56f0c5..d94e4f263 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml @@ -19,53 +19,55 @@ * under the License. */ --> - + + + + + + - - - - - + + + + - - - - + + + + + - - - - - + + + - - - + + + - - - + - + + + i1p1 + i1p2 + i2p1 + + test1 + - - - i1p1 - i1p2 - i2p1 - - test1 - - - - - i3p1 - i3p2 - i2p2 - - test2 - - - + + + i3p1 + i3p2 + i2p2 + + test2 + + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-basic.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-basic.xml index ac52fc3f9..6ed804d26 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-basic.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-basic.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -45,4 +43,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-spring.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-spring.xml index bc6e93bfa..431926d9f 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-spring.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-interceptors-spring.xml @@ -19,16 +19,14 @@ * under the License. */ --> - - - - + + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml index 4e4489348..7e3f99baf 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -62,5 +60,5 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-package-inheritance.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-package-inheritance.xml index 676a2603c..b57b54624 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-package-inheritance.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-package-inheritance.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -45,4 +43,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-reload.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-reload.xml index ffd575523..142b8eb38 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-reload.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-reload.xml @@ -19,13 +19,11 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-inheritance.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-inheritance.xml index 518e2322c..b526aabc4 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-inheritance.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-inheritance.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -44,4 +42,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-names.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-names.xml index 8d3dca625..e239161ba 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-names.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-names.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -66,4 +64,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-types.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-types.xml index 68709c249..6763ea62e 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-types.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-result-types.xml @@ -19,55 +19,54 @@ * under the License. */ --> - - - - - - - - value1 - value2 - value3 - - - valueA - valueB - - - - - - - - - value1 - value2 - value3 - - - valueA - valueB - - - - - - newValue1 - newValue3 - value10 - value11 - - - - - - newValueB - valueZ - - - - - + + + + + + + value1 + value2 + value3 + + + valueA + valueB + + + + + + + + + value1 + value2 + value3 + + + valueA + valueB + + + + + + newValue1 + newValue3 + value10 + value11 + + + + + + newValueB + valueZ + + + + + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-results.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-results.xml index fd35dbf30..91ab55548 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-results.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-results.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -50,4 +48,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml index 1a54461f2..a889f0ff7 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml @@ -19,11 +19,9 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml index 53ea572d2..c84108d90 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml @@ -19,11 +19,9 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml index 0b751f1bb..d3525473c 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml @@ -19,15 +19,13 @@ * under the License. */ --> - - - + + - \ No newline at end of file + \ No newline at end of file diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml index 5f3ea4d6f..313507cf3 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml @@ -19,15 +19,13 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.xml index 75f4379a6..886ae18c6 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -32,4 +30,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml b/core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml index 2c3554ab2..d44f41d00 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml @@ -19,8 +19,10 @@ * under the License. */ --> - - + + @@ -65,4 +67,4 @@ - + diff --git a/core/src/test/resources/com/opensymphony/xwork2/spring/xwork-autowire.xml b/core/src/test/resources/com/opensymphony/xwork2/spring/xwork-autowire.xml index 702f8996a..c2c329355 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/spring/xwork-autowire.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/spring/xwork-autowire.xml @@ -19,25 +19,31 @@ * under the License. */ --> - - - - - + + + + + + class="com.opensymphony.xwork2.result.NullResult" default="true"/> - @org.springframework.beans.factory.config.AutowireCapableBeanFactory@AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE + + @org.springframework.beans.factory.config.AutowireCapableBeanFactory@AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE + - + - + diff --git a/core/src/test/resources/includeTest.xml b/core/src/test/resources/includeTest.xml index c232db086..018c3ba30 100644 --- a/core/src/test/resources/includeTest.xml +++ b/core/src/test/resources/includeTest.xml @@ -19,13 +19,11 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/xwork - jar.jar b/core/src/test/resources/xwork - jar.jar index 8206d3e22e95a685b8ed8f647d2e6d5c42cbd121..94050febecab0711b73cc56d307ecb5ecd73d533 100644 GIT binary patch literal 2063 zcmWIWW@Zs#;Nak3*jQT|$bbYm8CV#6T|*poJ^kGD|D9rBU}gyLX6FE@V1g=?g>*2v8kg8o>GWqhA2}dTr zb-1|Yzuj@q+1|I8isr20&wNz;e_wHq_3y){51#E`Evz!tW2#H|{l4?(*lL0nVVXWK%}aGY$H~Vx zu2^i{$K*)|qSfZ@ev;Q*-j|8%v#Uhpw=jq$+;-_-A5wwRdC4HI@vWx0NDE zE-}KVF4n!zWYAbP@!Ho!ugd|664namf|lu}fErk=J+U#h_I zv!yM}@9VF3x{qHSE1kGGKhon|h19PMrW0R`jcV1uhA<{^8Fo&Y_kNLGN~A7F@a4DS zzhrl-onhI|&httK3`N(jHB1T=a(ot(Es%`=SKbK%YXh?c`tsl`HA3)nalRAw|)QMtHz14IlG?SyLTy? z`El-@c}0cR@8rrh?q2kMg3OQJkU3dD;-+==-wrC=5V!H#Q=_jo6NF~>#pNujzfq&r z94Vc?iCHCC>=(1vpY(@8s~_F9KN}zX>l5?0{hPCV66U>pUA3k|ty6B5nJ!UX(OI2^LWSYlh zKf7rAr;l^nG`Gy36S*Z_tnMd+lYx93XT#Cdg}W0U*QXx&GN*6mrS|PoDKDP5zl*nd zEybByR6MiHnlJLsv3h1u9<_>(@p}r)q((f*S!6L<7U6?s5#7-YGMYg~a0X#y5@A5C z17Q^$s18I0@JbC-BL;Y*YDKP^Ks6u&*aDewtw{ADvI(Fn3_0h5sxSoD2V|mGXvn%j ixf@wGD0d^kLuROMcwP_iW@Q7(vjE|DAkD-M;sF4h&Sx$F literal 2538 zcmWIWW@Zs#-~hsC_Z(jaB*4cYz)(@1UzDwzl~`n?SCN|&8o|S`&*)_|2!CZ1VK^I> z>wnuo;Ga)@>&9iZGen|OJ$#~PadLTh@Cc-8|9+vCC*|?zL|Me@%>T9G)=T}O!~}BI zO#Sqz`rX@|*4F>NJ^cCM)$gN%v;GTw5{s>|wXl`^Ch%v2`^&n6ha}yVb-mYW?3D|j zVb^HC)II&iqqHb-dCgEZml=VIPRC3xOTMN2zQ%ucS0_ zOBZnq#^ndk{mx6cy7T(uyZ`z!jf)m@eUp^)<73aSoArDBb{%ay&54D!&6oHOd=g&s z?)cTd%Px7jccZfl|43{;?iAPmySi3p&BNNP&iV}^#~tpUp7!W)viHW_k~dxyg|;b% zbItCH%Ue``qh`**oF3y^Ce_C(y=^{j=N~PdcyxEYl>L-1PubtpuU{4T@G}?x&k9Lx zE{SDPp3`>vC73&ZZ(!V)Sl+Wlr~l;AsdBoh5;qgrf5`n)`L{knW$x!Ui;^BkUcGUq z#WKOVtjJEkVnt<$Z{>qMHOZMLcl)0^b=z3je*fbjHNkpSrfKrrf7#9cg{Sd6E18pF zvFGcCq~mfs>p!l^W(_%c_ISyK&zXM>|49dUvvWvnkbZN4iGhKKhk+pgm^Zk;r#T zM?eG91PNw!0cpmMatdr8?=u=YcVxS8FvmTR5E5cZ-Pioe%qjQ~i|F(81OfkZ=dXI} zXq@o8%I&#UqwuWvIscPqyxUh;^By_H!?TFPv~_8xYiFhE%*vHK3l;NriCt?ursmf6 zY?_!_>n}DoF}G{WJXcOT<|elCnxf=NLs2)jg_WJICnaa5u5`V|1N0#~N0x)K>ug}) zyaQr{j|0#GN&r@fDCjC67bDAoVFkjY#mHzeG7^drNO^#sJEXCc2Y52dkSY-vnM9cp zr66*#%EtgKTOq*VZ6k<*UJ!D?n;8M#AaigP!U%KzI?6CJAQ#CT@FE#v1i~rE1(zg} zQ`+Uk3gz+b;;z* zS0)^p_}1a#mj8CgJ!gC0UMiZihClOB@&A3rIo7`qpFViDf3>j6RFA1H;rIK_pJ$T| z`Ln_GM4;1N$pwP*SGj93%>88YZDo>;T1thn%i=pl2Oev32PLYkNUv9T@`P#nyfiP> z`5Y%7-?(D2btgy1`kF|c=v!y5-M{g+WKPY=w{I+Uz8$*4Zj!3_<>Q};-PPWWA=g+k zblz5qB)P;0pSoE0K9fOX*~DvK6TL16B$m%?S9W+M>TRp4aQf-86&t>%O*tx2sW>&L z{^N;foJT%sdZpRaZSvK!{e9wemR!oN>&IB#Tp!q7b7fFl+o<&J?)GCRr@UGJE6`=- zj#7`k>w*p>u^wu6DZIF5yOP!=j!J6A?_q$yW zVlJ#Guz4!8`vrmdsTeKofi?=ShbT=e_Y2dakdY!B0He@niP*X}#^_hCw zDt)N}$Iq6wFu$+A-swJmb*yya=KM&Ha}`p*GMG+$F*d4I{~E%W#AVnyW#0Qmb}5m% z9Ko00ivN<`t#*d3=X1@fRMX4)t~<{w9WWGKyVfu%P{_%yg4ZnU_QL8Nc1Kq|a$zs6 zet%nZ^SQmU@+H;F&c3mpc|rfz)0`XipD+LUU*)~{$>t}5D`qa+x8C;sgRdGV%I55P zcJJP$Xy(VccjgrpTECMk+qiqt`w22XdPC-9{fL{^)qgvva6{b2Yfp{7+Ds6d-4~a$ zsQyNcR&%6u`X*+TWU*h&T7S|X2CaT{*ZypL@UKtI-}Z0L@=2KY@^#gk4z*6XWrsYL zY)q;$clK_z+qani3SXwojq5wVq$nQN@ZZ)y{gw5@`o->>isr?pX4rK1e)X8aye(C| zy^?7jll|nd687My9*U{NO zI6_}99!Flv0OlhQM$1dd38KmA2}ubbe0{<`@P~B-G%!t&U{)89X8h=;!1hs|+0eNo z+l7NU?tz4m5KC%Pi40>>rHQIfKw%vl+s7w=V)h91PPMFG}FX6|hPk9-Nd*HbreNwg9#O4Ilhm=93L@qDYsjBX+Pj9V!*lFX* z-iK08T#iy#R!6KuX;pd)G0iOqJy98S`8N$nt1ON93&ncwBNR8AlR}b~fLXR&q1H8m zXOZZ|o0og$p*SG#$KkauuikNLnwn8ZQlTf23VMR?%2=1keRret5loa1uBU-(bd}dr z=>YgwC8f-7miGc;R#lXRi_L>xbuwk2TM_6WLQA?Ni@%6y!Bm}%OPkRwhm+RmshxZi z9Su^|5ADplH8Y^=*HlXKk`;J<4&A=5Im=<^btc*RuF{u#l%f~v(a+C9uO=vX9@ zoTj!+c+n?Tik)+*d7Sybr-fxvDLunAlc>wXcGV;$HC`sR0F}oqEBASxQ1VSQxvZ9O z>c#mv+2yFROeL1-4+a{(JY#OxD(V8gM@gfG&{C%sv!2W=!5bActr^yrZ`aj|+zO0D zQPVF!DJn#l;>(l`QHHR7x#$0hdAW8T?p8A1GlgJl?*a>qhfh2no37Lua$A~;d(}Mz z7q?CgQVlQnBGqcg`UfY;1~8di&D)r4DhsY8Kid@?aGTZTT~t)d72x`rhT3rOx5h@9 ziOgJKEf$J6rynGM?w_>SHt+-XCL{x@tN74ywP2lvRny=7s` z950f(s(^*b8PyP_gY%mFt}lbYQLW2x18Za&T1wsKwOn;G*NQsLfacJwe|~QCVq5#8 zvWK^i1UH2)&PLg?KH#qd5R0N~^V0L+0o*nhPI`&Z^T za$pVz2jg$GFPY=c(0u_r@B}^RzMvobYfm8BPL*fD0;gb)FcQv^!f2oo5?%DOsBvuk*fkdSN9 zaO=&DW5e~cwDivUkff&_n$k^8!iku)G@PB8O>Q=kh$EH>Ksn7|e3TMzM_&&gCl?Pt zPsbKKO@U7=%CTMQ)>+PjlGq?~r;v$+gKo?m#9@h%dVj_S^ml9s%Lp@qV@qMdmLC5W zI9PSEOiyXGqxw?|+AG{cAkuLry&t#S&d&R886ZnsU-Y32wgB6z_lA+jyMr#ix4yx1 zlprc3{kA%*FxNHi=4N`v{dTMeK$OC*ekz#qs+l-3xIIk}SJ8ERot|(mmB)0&PNv#P zg32PFzj$jGb6P|QJA!s*DjZt{v|9uQO!RI;{8e`?gsCjDH7CiWOF0qc%mx*8oDunn zK64+FKFFEzkPVPwx)cwh`GeqU8=H=>NmI*4^4!NUzw8QcS!*o+9rk$ePXc31n{Obt ztC-Wm-#rK=-RbW&?!xj}qH_`gK8xLb0`XPU8lL#6#%IV!Jjq<%@xD8{p)S%YCO;57 z>mP|UQ#38%$qsPYM%->Rm$MWQ=M!i5%zAtN!fb>fr{chp`w9U(^B$D!tLA63v|=UV z{U|h`$;I89KqTqc3D#rJ4vptOuT{}GsSGM@?%wgk57rIOOztInDh3s@uOpBqTx|X^ z**lfB(o!0dse$TO`?;H_$4SfN!Q=rQKi^4P??4*-5n0PVWhXLPfHWQL^?hs=jI8;# zBa_nVjDGkGF)|-ydHs|Xdrq>wUqS3hRBp2mK{1+1d`9f%btBy#N^xr2vsk_h>7U-Q zEyh-snNF{CirvO8*!jU$1p;XbjqvZ45W-Jd=$^NiQE(0tHg`t ztt}Qf%~%hPbY4@ztA++?oC&`dVPPCGRUhT-`RduF?$_gr$1gmeF_Ykl6=%v6;@D+V z+Ou-wd>@kQpBRU9G!#Ka3eshdR683W5Pf=tBO0?iY!}R2WHxU`VAX-hxr${{j4UR)<4m950kXaw+~C y^KaGtX^s%!ci=H5N52k?J>+LlDvGycW2o=9 - - - + + - + diff --git a/core/src/test/resources/xwork-jar.jar b/core/src/test/resources/xwork-jar.jar index 70434e63e141fb7d38ea716c4b638c52b4cf69aa..5c71c0a869a76c8127aff30676466676e9556ecd 100644 GIT binary patch literal 2059 zcmWIWW@Zs#;Nak3;H#?*WIzI(3@i-3t|5-Po_=on|4uP5Ff#;rvvYt{FhP|C;M6Pv zQ~}rQ>*(j{<{BKL=j-;__snS@Z(Y5MyxzK6=gyqp9At3C_`%a6JuhD!Pv48Bt5`TA zUPvC1o;g!1!(!PJ@hLyVmprT7S&{vz=wlHh*a1(H<+AO8#)B}z0l#WdUC$4cttihg z%2v=-$Vx2ItH{kc8y4+<+d!ml+5STjm*vz{!>rYo>7HfL_3+>kNY$<`nSA-mgd-E* zI$YfH-|o2QZ13AkMRV5hXFe+azppsQ`uE|}2haAe7FL<+G1Vpfe&6}?Y_cJLHn^S$ zblNMqKydylcP)mwpG>~3OtMi+sW5g~e5dHZV@>X$M3oik^$Jg(FioGA=A}BH&&(LH{O=asX6)fjit`FLs!^MQWd{^{4=q;+Pg928cT-G+e(on zml)ww7wg_1G{Uk3~Fl|mEPUme(dCwH|u`|x~$w$>allS z(19e@L(MLQ7uRf8(z?V^DX_sJ?8{NpWh6R)lHs)+LwjhU6~|+_pupbJg62Oy&z}N-3&7Q%_r^FIC|9 z+0qu~_x0C1-N&zvl}_B8AL((fLh4rr(}^#}Mz!i+Ll~2|3_GXHd%wsoB~q6o`0`uv zU$VQ^&am}-u3438dRgCf=Xs?AhN5fN8YTq_IoVb4nuXn7SiQsU=&DC9?4{N3Z;Ng| zw^vraqK|}bEE$AA`Q zj+9Q{#H^Am_KR8TPx`~4)sODlpN$Xx^@;i0{>@oF3G-gQu3FQf)+x8_kjIjZNmb^~ z-mP}~7V}@>%aplsedm`H#lsr@+xn-!vVK^<*nLycyx7zXo9^DP9y6G?rK-1AGRr;<>nbSA(Qu}tPlowCj-^JU! zmf}n;DxO(p%@=v+SUoc+i(19U_&o*YQ6nDY9KwW_zjN$O zKv?w#ssT{}yh;PrhXLNGT9GRzQ2mDhwm>FaD^hKUYyzkPL(aIM3Jd}E0hwsk8M0?(I%%>wn)K{`~Oj_ff%F{{=pY#n#wb*h+pA__M+NW!=F;lJ3g7-fK1X%7xFc zYqVeLo_^y|T9mlFW+j6g-FV&Xb_w$KD9h{I-!xcm8YPj&tguemmO7dYhypx$0-}=bld`RZ9pZiRXeCxj< z3ZGc@wu&EL<3GD{EsN*6ojjEbTXUYj?s#PoBzW9YuH5ZW#-!lY#hap{PM6;e4BdD9 z`RiMGv({znMTSYw<7#ByA#;oA#}$s~j{)im?W@by%)4~K_iUI{sQ2uqg0Cv`w{hee zJ6*rCV{6W}9Mz6s!^D;8-g|dehu1AEWPXxgEf-`QxJ+0vFF##`n`U;j<%iV#6sKVOZ*2u39or~ z{A%B2m%QA&(bSLAOHXpb1kCsk6y1QP=e#)1p>~HGVuL^wlnT!8tg`_r@ z#Ih*QX*>NA%$>hCFz!n%?^&YLe{$(mIo(u=n+fbcDrTc4mZ_w$=YNslA1-Z;}@ znP6R3WT#)TqB6v{^1+^(}LPM(|Deh%*n9W z^L0bgak-uKAJ=5FhMYWmyyU{?%)f^JqyxO!IV3hnzq!D~z`(=9zz_h;8eHHEVS<)5 zIDuIsKHk^S**`c!ACxUpfLQ{BLD>SN4SSA~K-Q)gk2iBACx|AeCnP0&@bwA%z#rBT z(7-f7f>~Wan(?EX0^3JmF@jCYPafXVV=+rjQ$B(FT1;mC zp~!V7Y`hH@HGX{Ttg~I`nMS%~g0fv|>Z*;RQVmbI!ff_x?1<9c?z*+kBH6PqaE8&+ z2fisTA~xaOYi4xTIQnQDsGwk>yhz@XQ@jls_JP?*gX&Jzz;$*x{*QWCs*s@v5|%M@a4PcGMWy4`cZ)I3jj zwrMoyqY$5nS2u(5-`$%UpK*ub=k0mzSA3>qwy4R>taDrTUc^V#z0@e#;Q%~GlBP(NY^QP2d744ur_VuB?U&~&+&*i(w>USV> z!{>d{5vA|GR&3v&e5>cqil*AO_Q{72&Yu75-)r5|UH)DvG3OV2VczhEW%cjEt&dG6 zMn`|Y7A0eU?9Ijr*B}3jlV{Jam>=~>UgxOch3}h|{`hbs=uIA**{+zWi6^EWTDExl z>=*K8^63WBkA3DloV4&a36-dk#6<#U1NnYFimL zDRrIjjk6bQ6B_bw$SP}|PAh3M+W_E*dU%P$he{BiR=Qg`n+^7gMH8W1+yU{my z&UtRREVc_hBG;puUw|Bb!>r%EWy$GKn%HN;%|Wla~P)2oT`#wh_cYE9f}jt%v|`kTJN* zScEZu9i^EWkV{++c!>)!0^t(ma!LZpB}*EEkd447ebF6-h(YAI - - - + + - + diff --git a/core/src/test/resources/xwork-proxyinvoke.xml b/core/src/test/resources/xwork-proxyinvoke.xml index 2ce698dc2..109907cee 100644 --- a/core/src/test/resources/xwork-proxyinvoke.xml +++ b/core/src/test/resources/xwork-proxyinvoke.xml @@ -19,11 +19,10 @@ * under the License. */ --> - - - + + @@ -64,4 +63,4 @@ - + diff --git a/core/src/test/resources/xwork-sample.xml b/core/src/test/resources/xwork-sample.xml index 5ff1e39e3..89eb64554 100644 --- a/core/src/test/resources/xwork-sample.xml +++ b/core/src/test/resources/xwork-sample.xml @@ -19,13 +19,10 @@ * under the License. */ --> - - - - + + @@ -277,4 +274,4 @@ - + diff --git a/core/src/test/resources/xwork-test-beans.xml b/core/src/test/resources/xwork-test-beans.xml index d57483455..2ed15b282 100644 --- a/core/src/test/resources/xwork-test-beans.xml +++ b/core/src/test/resources/xwork-test-beans.xml @@ -19,12 +19,11 @@ * under the License. */ --> - - - + + - + diff --git a/core/src/test/resources/xwork-test-default.xml b/core/src/test/resources/xwork-test-default.xml index bdcc91ba1..f805aa3cb 100644 --- a/core/src/test/resources/xwork-test-default.xml +++ b/core/src/test/resources/xwork-test-default.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -56,4 +54,4 @@ - + diff --git a/core/src/test/resources/xwork-test-validation.xml b/core/src/test/resources/xwork-test-validation.xml index ca60347b8..fe71c26b8 100644 --- a/core/src/test/resources/xwork-test-validation.xml +++ b/core/src/test/resources/xwork-test-validation.xml @@ -19,12 +19,10 @@ * under the License. */ --> - - - + + @@ -80,4 +78,4 @@ - + diff --git a/core/src/test/resources/xwork-zip.zip b/core/src/test/resources/xwork-zip.zip index 1825195edceb60fc8ceb75d16c2ccc9ef0e3e0fa..136a03afd5c7439d15be9785c15e4eb83ced53f4 100644 GIT binary patch literal 2564 zcmWIWW@Zs#-~d96y4pYnC@|t-VBlp?V5lh1FUr=f$}G^U$ju22;bmZdv*mF7MB|sy zAiA`In}Lz#Do{qUa#=v3Dfj>XTa)}W>b+PV!CWFSZiPyd+dR-1kET7q~?C?s|+g4TK^wVW4HhfQ;a#W&HacWTg z#}m&uk9^YfO0%ik!?qGR`hZ%AEh)EdA*vuf3}qjec!gzx~zjce@_M zTv$#yDx`j8FrD~fY*efMHH0yV%dm6Gy!VUjQX+LZ zf-k=n|0TOy?F?Jb=bBZirkC|ycb-=|U?{qFtzlB2kds{nuUXjbh1EOkj;?y-!d_ba z{#8*!YMpY+4tXru zm{eu%?A>a&Z!!NBzD$`L*LQwNQ9P{Szpa1zE9-~#i`_RB&5KRVu<7po>M?_PTdI0{ zCDS}6``Ja?KYg6rrnzPQoX9QdVs$?moDAgSI2(?pF5I2?xIXpBmpOeiFST!%N_p|b z{aw7xYbnmuqT-ol)_jq7j@2^~n2kUfEh{A_h$g2eBqe`IfAD{e**?Xj^X->%A30Jy=uJ3vBXUds9B^|p? zJLnuZpwJpHd2&QdP}H1RlO{z>S|uaE6C@(_Xjyh*ZbnX0N=9C0;-`Ys4=W~oSh)B3 zRYwz`57{~1e*U|&2k0k|zYsoFL@P1)VI_uwt^#tIaUbZx7GRkHqR~7$T4s!v86&vN zK+Zv+yd{OD%)pYF24$&HlnE|1F6}dN6W|4x8XY}n0uiMKBa;X-qNRachJsoeFz~h! z#KK-!;%IjSc%vGPTv&k$VHkMZ=)lZCc9D#13n#+w1Pr`wEMdp=0v3C4q>un_RyL4XEI`=C$iR@n0pbAwc~CUt literal 2500 zcmWIWW@Zs#-~d85j~rhHB*4!gz)(@1UzDw&t5B6$pjVNb6B@z8&|>^Dx*3SSGKw&q z4a@bvZ6NT^r@nRLvf3FU(WxFj(X%+YJUn;=Qni1-P|K6@cyyvHVs+;KT5;>8eoLyw7M8&mqib@?kf;lbIIZ`pDpXNanJi`%I2} z>%SoipIG&_iXUI&Kf7`*i|4wXJe3PubDqEMcx4bIc-&L2-0e}uq~O)Xo1&slm){Kx z-FN)?>sxuV)@AEOhDp!kYGmFabBpQ66^`hS0qP3vtIO8RyL7?#Y?xH2_w1&EuPXDm zapW31UB9zqYtFSC)sA4p#FgpZdv{ic*DWk$ev)4;7i1i`OmJ2~$}h>8`+^NZWmKh9 zxiV+mx3YgyDa&Jg`EB}#9_Gi-82fT<@}k~;2v^G9Tvl)(B|W=m(i)GQvU|czuiaj_ zf4ilNxCP_#gXezdC0yNk{qfy@eVN8Zi@Cl@%K7oJ=hw~py?(onww>n0Lfhs`{0BY> zuX%U;YTsp-yxhCd*@b^3HXnD2>;GL{E3@WdZB}Rf29e_q_fJoIbU4|2<8H|tFN#9j z6vMe@_r>Kcs=rY)=U`5caV?YTW0l@EAGh<5mQFmnyI#tE%9p3?Z|c{t3VisPi~nbZ zq&AntvMA4KJN**Ooxe9Q?n^B1S)$W_a_Lk#-BgL23G6@Q{;B+1pP(}L^P5FUk0Y<% zIMZU8U|m*Zr(dz6GQ_v?!JeAr%#*wQ&z-t$ENs93agdr|y(-f*dG5dLX8*#|c%GHa z$*|b-bwko|xt;YN*JQJXoIHEH zkCr(&fte#d-q+FDKR7}klr5$Kvjhl(vIR&R_Bl5~Y zKdd95foXySv$}vZ<3~3IwvY16hRz+?E*#8p4sCQXW%v`R*RCrCu< z(X#Bs+>D&0l#IO0#GuqaMp7y@tDM?IU6_G>V&^bw{cYF-435V@jPRomTF~&q$_-tl zQez@8XeNx78l$Dg2q`rn*&jV?NMOnSxN^zBX8ucQpv?bgt0UhNMmBKfFDhi4hRFPk zOrp$)A`ZFC - - - + + @@ -72,4 +70,4 @@ - + diff --git a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java index 5bead8228..cf0f840b6 100644 --- a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java +++ b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java @@ -19,17 +19,16 @@ package org.apache.struts2.oval.interceptor; import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.interceptor.ValidationAware; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.interceptor.ValidationAware; +import junit.framework.AssertionFailedError; import net.sf.oval.configuration.Configurer; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import java.util.Arrays; import java.util.List; import java.util.Map; -import junit.framework.AssertionFailedError; - public class OValValidationInterceptorTest extends XWorkTestCase { public void testSimpleFieldsXML() throws Exception { ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldsXML", null, null); @@ -42,7 +41,7 @@ public class OValValidationInterceptorTest extends XWorkTestCase { assertValue(fieldErrors, "lastName", Arrays.asList("lastName cannot be null")); } - public void testSimpleFieldsJPAAnnotations() throws Exception { + public void testSimpleFieldsJPAAnnotations() throws Exception { ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldsJPA", null, null); baseActionProxy.execute(); @@ -290,8 +289,7 @@ public class OValValidationInterceptorTest extends XWorkTestCase { assertValue(fieldErrors, "address", Arrays.asList("net.sf.oval.constraint.AssertValid.violated")); // Oval version <= 1.40 validation error for minimum length reports: "street cannot be smaller than 7 characters". assertValue(fieldErrors, "address.street", Arrays.asList("street cannot be smaller than 7 characters")); - } - catch (AssertionFailedError afe) { + } catch (AssertionFailedError afe) { // Oval version >= 1.50 validation error for invalid data reports: "address is invalid". assertValue(fieldErrors, "address", Arrays.asList("address is invalid")); // Oval version >= 1.50 validation error for minimum length reports: "street cannot be shorter than 7 characters". @@ -301,30 +299,29 @@ public class OValValidationInterceptorTest extends XWorkTestCase { } public void testMemberObject() throws Exception { - ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "memberObject", null, null); - MemberObject action = (MemberObject) baseActionProxy.getAction(); - action.getPerson().setName(null); - action.getPerson().setEmail(null); - action.getPerson().getAddress().setStreet("short"); - baseActionProxy.execute(); + ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "memberObject", null, null); + MemberObject action = (MemberObject) baseActionProxy.getAction(); + action.getPerson().setName(null); + action.getPerson().setEmail(null); + action.getPerson().getAddress().setStreet("short"); + baseActionProxy.execute(); - Map> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors(); - assertNotNull(fieldErrors); - assertEquals(5, fieldErrors.size()); // 5: as there will be field errors for 'person' and 'person.address' themselves - assertValue(fieldErrors, "person.name", Arrays.asList("name cannot be null")); - assertValue(fieldErrors, "person.email", Arrays.asList("email cannot be null")); - try { - // Oval version <= 1.40 validation error for invalid data reports: "net.sf.oval.constraint.AssertValid.violated". - assertValue(fieldErrors, "person.address", Arrays.asList("net.sf.oval.constraint.AssertValid.violated")); - // Oval version <= 1.40 validation error for minimum length reports: "street cannot be smaller than 7 characters". - assertValue(fieldErrors, "person.address.street", Arrays.asList("street cannot be smaller than 7 characters")); - } - catch (AssertionFailedError afe) { - // Oval version >= 1.50 validation error for invalid data reports: "address is invalid". - assertValue(fieldErrors, "person.address", Arrays.asList("address is invalid")); - // Oval version >= 1.50 validation error for minimum length reports: "street cannot be shorter than 7 characters". - assertValue(fieldErrors, "person.address.street", Arrays.asList("street cannot be shorter than 7 characters")); - } + Map> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors(); + assertNotNull(fieldErrors); + assertEquals(5, fieldErrors.size()); // 5: as there will be field errors for 'person' and 'person.address' themselves + assertValue(fieldErrors, "person.name", Arrays.asList("name cannot be null")); + assertValue(fieldErrors, "person.email", Arrays.asList("email cannot be null")); + try { + // Oval version <= 1.40 validation error for invalid data reports: "net.sf.oval.constraint.AssertValid.violated". + assertValue(fieldErrors, "person.address", Arrays.asList("net.sf.oval.constraint.AssertValid.violated")); + // Oval version <= 1.40 validation error for minimum length reports: "street cannot be smaller than 7 characters". + assertValue(fieldErrors, "person.address.street", Arrays.asList("street cannot be smaller than 7 characters")); + } catch (AssertionFailedError afe) { + // Oval version >= 1.50 validation error for invalid data reports: "address is invalid". + assertValue(fieldErrors, "person.address", Arrays.asList("address is invalid")); + // Oval version >= 1.50 validation error for minimum length reports: "street cannot be shorter than 7 characters". + assertValue(fieldErrors, "person.address.street", Arrays.asList("street cannot be shorter than 7 characters")); + } } @@ -342,6 +339,6 @@ public class OValValidationInterceptorTest extends XWorkTestCase { @Override protected void setUp() throws Exception { super.setUp(); - loadConfigurationProviders(new XmlConfigurationProvider("oval-test.xml")); + loadConfigurationProviders(new StrutsXmlConfigurationProvider("oval-test.xml")); } } diff --git a/plugins/oval/src/test/resources/oval-test.xml b/plugins/oval/src/test/resources/oval-test.xml index 353e86c9d..522e92fbe 100644 --- a/plugins/oval/src/test/resources/oval-test.xml +++ b/plugins/oval/src/test/resources/oval-test.xml @@ -19,15 +19,14 @@ * under the License. */ --> - - - - + + + - + @@ -87,11 +86,13 @@ - + - + @@ -109,15 +110,15 @@ - true + true - true + true - + From 8a0cdb4da15a758329b2b6d78cdb5a9fde0e59ae Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 29 Nov 2020 16:00:51 +0100 Subject: [PATCH 2/3] WW-5078 Uses more informative name for XWorkConfigurationProvider --- .../xwork2/config/ConfigurationManager.java | 8 ++++---- .../xwork2/config/impl/MockConfiguration.java | 4 ++-- ...er.java => StrutsDefaultConfigurationProvider.java} | 2 +- .../opensymphony/xwork2/util/XWorkTestCaseHelper.java | 6 +++--- .../xwork2/config/ConfigurationManagerTest.java | 4 ++-- ...nfigurationProviderGlobalResultInheritenceTest.java | 2 +- ...gurationProviderInterceptorParamOverridingTest.java | 2 +- ...ionProviderInterceptorStackParamOverridingTest.java | 2 +- .../xwork2/interceptor/ParametersInterceptorTest.java | 10 +++++----- 9 files changed, 20 insertions(+), 20 deletions(-) rename core/src/main/java/com/opensymphony/xwork2/config/providers/{XWorkConfigurationProvider.java => StrutsDefaultConfigurationProvider.java} (99%) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java index c5dcae192..41e24b1b3 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java @@ -19,7 +19,7 @@ package com.opensymphony.xwork2.config; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.StrutsConstants; @@ -85,8 +85,8 @@ public class ConfigurationManager { /** *

* Get the current list of ConfigurationProviders. If no custom ConfigurationProviders have been added, this method - * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider. If a custom - * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand. + * will return a list containing only a default ConfigurationProvider, {@link StrutsDefaultConfigurationProvider}. + * If a custom ConfigurationProvider has been added, then the StrutsDefaultConfigurationProvider must be added by hand. *

* *

@@ -100,7 +100,7 @@ public class ConfigurationManager { providerLock.lock(); try { if (containerProviders.size() == 0) { - containerProviders.add(new XWorkConfigurationProvider()); + containerProviders.add(new StrutsDefaultConfigurationProvider()); } return containerProviders; diff --git a/core/src/main/java/com/opensymphony/xwork2/config/impl/MockConfiguration.java b/core/src/main/java/com/opensymphony/xwork2/config/impl/MockConfiguration.java index b21dc45cd..997c5f1de 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/impl/MockConfiguration.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/impl/MockConfiguration.java @@ -21,7 +21,7 @@ package com.opensymphony.xwork2.config.impl; import com.opensymphony.xwork2.config.*; import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.inject.Scope; @@ -50,7 +50,7 @@ public class MockConfiguration implements Configuration { //this cannot be done in the constructor, as it causes an infinite loop builder.factory(Configuration.class, MockConfiguration.class, Scope.SINGLETON); LocatableProperties props = new LocatableProperties(); - new XWorkConfigurationProvider().register(builder, props); + new StrutsDefaultConfigurationProvider().register(builder, props); builder.constant(StrutsConstants.STRUTS_DEVMODE, "false"); builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true"); builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, "true"); diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java similarity index 99% rename from core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java rename to core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java index 63d8fab40..ccdb78202 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java @@ -123,7 +123,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class XWorkConfigurationProvider implements ConfigurationProvider { +public class StrutsDefaultConfigurationProvider implements ConfigurationProvider { public void destroy() { } diff --git a/core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java b/core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java index bde73ca92..e139f0535 100644 --- a/core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java +++ b/core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java @@ -20,7 +20,7 @@ package com.opensymphony.xwork2.util; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.config.*; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.inject.ContainerBuilder; @@ -33,7 +33,7 @@ public class XWorkTestCaseHelper { public static ConfigurationManager setUp() throws Exception { ConfigurationManager configurationManager = new ConfigurationManager(Container.DEFAULT_NAME); - configurationManager.addContainerProvider(new XWorkConfigurationProvider()); + configurationManager.addContainerProvider(new StrutsDefaultConfigurationProvider()); Configuration config = configurationManager.getConfiguration(); Container container = config.getContainer(); @@ -62,7 +62,7 @@ public class XWorkTestCaseHelper { } }); - configurationManager.addContainerProvider(new XWorkConfigurationProvider()); + configurationManager.addContainerProvider(new StrutsDefaultConfigurationProvider()); for (ConfigurationProvider prov : providers) { if (prov instanceof XmlConfigurationProvider) { ((XmlConfigurationProvider)prov).setThrowExceptionOnDuplicateBeans(false); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationManagerTest.java b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationManagerTest.java index 864f790d5..307cd3be0 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationManagerTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationManagerTest.java @@ -22,7 +22,7 @@ import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.Mock; import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider; import com.opensymphony.xwork2.conversion.TypeConverterHolder; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.inject.ContainerBuilder; @@ -168,7 +168,7 @@ public class ConfigurationManagerTest extends XWorkTestCase { configProviderMock.matchAndReturn("equals", C.ANY_ARGS, false); ConfigurationProvider mockProvider = (ConfigurationProvider) configProviderMock.proxy(); - configurationManager.addContainerProvider(new XWorkConfigurationProvider()); + configurationManager.addContainerProvider(new StrutsDefaultConfigurationProvider()); configurationManager.addContainerProvider(mockProvider); //the first time it always inits diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java index a40c71497..a5c12f31c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java @@ -39,7 +39,7 @@ public class XmlConfigurationProviderGlobalResultInheritenceTest extends Configu ConfigurationProvider provider = buildConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml"); ConfigurationManager configurationManager = new ConfigurationManager(Container.DEFAULT_NAME); - configurationManager.addContainerProvider(new XWorkConfigurationProvider()); + configurationManager.addContainerProvider(new StrutsDefaultConfigurationProvider()); configurationManager.addContainerProvider(provider); Configuration configuration = configurationManager.getConfiguration(); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java index 6b6057b12..aab4a50ca 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java @@ -46,7 +46,7 @@ public class XmlConfigurationProviderInterceptorParamOverridingTest extends XWor p.setFileManagerFactory(factory); conf.reloadContainer(new ArrayList() { { - add(new XWorkConfigurationProvider()); + add(new StrutsDefaultConfigurationProvider()); add(p); } }); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java index 401c66f16..e629d4486 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java @@ -49,7 +49,7 @@ public class XmlConfigurationProviderInterceptorStackParamOverridingTest extends configurationManager.addContainerProvider(p); conf.reloadContainer(new ArrayList() { { - add(new XWorkConfigurationProvider()); + add(new StrutsDefaultConfigurationProvider()); add(p); } }); diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java index 2eefbde4a..381f909d3 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java @@ -28,7 +28,7 @@ import com.opensymphony.xwork2.TextProvider; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.mock.MockActionInvocation; @@ -95,7 +95,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testInsecureParameters() throws Exception { // given - loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new StrutsDefaultConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put("name", "(#context[\"xwork.MethodAccessor.denyMethodExecution\"]= new " + @@ -132,7 +132,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution1 = "class.classLoader.jarPath"; final String pollution2 = "model.class.classLoader.jarPath"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new StrutsDefaultConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); @@ -171,7 +171,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution2 = "model.class.classLoader.jarPath"; final String pollution3 = "class.classLoader.defaultAssertionStatus"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-class-param-test.xml")); + loadConfigurationProviders(new StrutsDefaultConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-class-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); @@ -290,7 +290,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { final String pollution5 = "class['classLoader']['jarPath']"; final String pollution6 = "class[\"classLoader\"]['jarPath']"; - loadConfigurationProviders(new XWorkConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); + loadConfigurationProviders(new StrutsDefaultConfigurationProvider(), new StrutsXmlConfigurationProvider("xwork-param-test.xml")); final Map params = new HashMap() { { put(pollution1, "bad"); From b2fb778909e05379e25fd174e7b9e3619add9712 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 29 Nov 2020 17:01:46 +0100 Subject: [PATCH 3/3] WW-5078 Drops unneeded DTDs --- .../providers/XmlConfigurationProvider.java | 12 +- .../StrutsXmlConfigurationProvider.java | 3 +- .../apache/struts2/dispatcher/Dispatcher.java | 2 +- core/src/main/resources/struts-default.xml | 8 +- core/src/main/resources/xwork-1.0.dtd | 106 ------------ core/src/main/resources/xwork-1.1.1.dtd | 123 -------------- core/src/main/resources/xwork-1.1.2.dtd | 131 --------------- core/src/main/resources/xwork-1.1.dtd | 115 ------------- core/src/main/resources/xwork-2.0.dtd | 137 --------------- core/src/main/resources/xwork-2.1.3.dtd | 146 ---------------- core/src/main/resources/xwork-2.1.dtd | 143 ---------------- core/src/main/resources/xwork-2.3.dtd | 149 ----------------- core/src/main/resources/xwork-2.5.dtd | 151 ----------------- core/src/main/resources/xwork-2.6.dtd | 157 ------------------ .../xwork2/util/ClassLoaderUtilTest.java | 12 +- .../FetchMetadataInterceptorTest.java | 4 +- .../struts2/dispatcher/ng/struts-no-op.xml | 4 +- .../struts2/views/jsp/WW3090-struts.xml | 4 +- .../{xwork-1.0.dtd => struts-2.0.dtd} | 0 core/src/test/resources/struts.xml | 4 +- 20 files changed, 26 insertions(+), 1385 deletions(-) delete mode 100644 core/src/main/resources/xwork-1.0.dtd delete mode 100644 core/src/main/resources/xwork-1.1.1.dtd delete mode 100644 core/src/main/resources/xwork-1.1.2.dtd delete mode 100644 core/src/main/resources/xwork-1.1.dtd delete mode 100644 core/src/main/resources/xwork-2.0.dtd delete mode 100644 core/src/main/resources/xwork-2.1.3.dtd delete mode 100644 core/src/main/resources/xwork-2.1.dtd delete mode 100644 core/src/main/resources/xwork-2.3.dtd delete mode 100644 core/src/main/resources/xwork-2.5.dtd delete mode 100644 core/src/main/resources/xwork-2.6.dtd rename core/src/test/resources/{xwork-1.0.dtd => struts-2.0.dtd} (100%) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java index d2da19768..e02338f9a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java @@ -72,6 +72,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.Vector; @@ -106,7 +107,7 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider private ValueSubstitutor valueSubstitutor; public XmlConfigurationProvider() { - this("xwork.xml", true); + this("struts.xml", true); } public XmlConfigurationProvider(String filename) { @@ -170,11 +171,7 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider final XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o; - if ((configFileName != null) ? (!configFileName.equals(xmlConfigurationProvider.configFileName)) : (xmlConfigurationProvider.configFileName != null)) { - return false; - } - - return true; + return Objects.equals(configFileName, xmlConfigurationProvider.configFileName); } @Override @@ -1066,7 +1063,8 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider } if (urls == null || !urls.hasNext()) { - throw new ConfigurationException("Could not open file: " + fileName, ioException); + LOG.debug("Ignoring file that does not exist: " + fileName, ioException); + return docs; } URL url = null; diff --git a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java index 3461c7545..f876d0632 100644 --- a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java +++ b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java @@ -51,6 +51,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider { * * @param errorIfMissing If we should throw an exception if the file can't be found */ + @Deprecated public StrutsXmlConfigurationProvider(boolean errorIfMissing) { this("struts.xml", errorIfMissing, null); } @@ -75,7 +76,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider { super(filename, errorIfMissing); this.servletContext = ctx; this.filename = filename; - reloadKey = "configurationReload-"+filename; + reloadKey = "configurationReload-" + filename; Map dtdMappings = new HashMap(getDtdMappings()); dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.0//EN", "struts-2.0.dtd"); dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.1//EN", "struts-2.1.dtd"); diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index eeb813f9f..8d7b5fbed 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -446,7 +446,7 @@ public class Dispatcher { String[] classes = configClasses.split("\\s*[,]\\s*"); for (String cname : classes) { try { - Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); + Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); StrutsJavaConfiguration config = (StrutsJavaConfiguration) cls.newInstance(); configurationManager.addContainerProvider(createJavaConfigurationProvider(config)); } catch (InstantiationException e) { diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 8d30cf4d3..045d453c9 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -31,8 +31,8 @@ and {@link com.opensymphony.xwork2.inject.Inject} --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> @@ -401,10 +401,10 @@ false false - + - + same-origin diff --git a/core/src/main/resources/xwork-1.0.dtd b/core/src/main/resources/xwork-1.0.dtd deleted file mode 100644 index 23661a186..000000000 --- a/core/src/main/resources/xwork-1.0.dtd +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.1.dtd b/core/src/main/resources/xwork-1.1.1.dtd deleted file mode 100644 index c8b01b4b1..000000000 --- a/core/src/main/resources/xwork-1.1.1.dtd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.2.dtd b/core/src/main/resources/xwork-1.1.2.dtd deleted file mode 100644 index 296c8a5b3..000000000 --- a/core/src/main/resources/xwork-1.1.2.dtd +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.dtd b/core/src/main/resources/xwork-1.1.dtd deleted file mode 100644 index f1fbfd7b0..000000000 --- a/core/src/main/resources/xwork-1.1.dtd +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.0.dtd b/core/src/main/resources/xwork-2.0.dtd deleted file mode 100644 index c9c3b3bfa..000000000 --- a/core/src/main/resources/xwork-2.0.dtd +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.1.3.dtd b/core/src/main/resources/xwork-2.1.3.dtd deleted file mode 100644 index bce8e2315..000000000 --- a/core/src/main/resources/xwork-2.1.3.dtd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.1.dtd b/core/src/main/resources/xwork-2.1.dtd deleted file mode 100644 index 40db431ca..000000000 --- a/core/src/main/resources/xwork-2.1.dtd +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.3.dtd b/core/src/main/resources/xwork-2.3.dtd deleted file mode 100644 index 2a81073d2..000000000 --- a/core/src/main/resources/xwork-2.3.dtd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.5.dtd b/core/src/main/resources/xwork-2.5.dtd deleted file mode 100644 index 4d61e8a4f..000000000 --- a/core/src/main/resources/xwork-2.5.dtd +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.6.dtd b/core/src/main/resources/xwork-2.6.dtd deleted file mode 100644 index ba6dddf67..000000000 --- a/core/src/main/resources/xwork-2.6.dtd +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java index b3ef289a6..90cc5f1bf 100644 --- a/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java @@ -39,26 +39,26 @@ public class ClassLoaderUtilTest extends TestCase { } public void testGetResources_Multiple() throws IOException { - Iterator i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, false); + Iterator i = ClassLoaderUtil.getResources("struts-2.0.dtd", ClassLoaderUtilTest.class, false); assertNotNull(i); assertTrue(i.hasNext()); URL url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); assertTrue(!i.hasNext()); } public void testGetResources_Aggregate() throws IOException { - Iterator i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, true); + Iterator i = ClassLoaderUtil.getResources("struts-2.0.dtd", ClassLoaderUtilTest.class, true); assertNotNull(i); assertTrue(i.hasNext()); URL url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); assertTrue(!i.hasNext()); } diff --git a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java index 2249077c5..7d7c4bd21 100644 --- a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java +++ b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java @@ -18,7 +18,6 @@ */ package org.apache.struts2.interceptor; - import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_EMBED; import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_OBJECT; import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_SCRIPT; @@ -43,6 +42,7 @@ import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.mock.MockActionInvocation; import org.apache.struts2.ServletActionContext; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -155,7 +155,7 @@ public class FetchMetadataInterceptorTest extends XWorkTestCase { // Perform a multi-step test to confirm (indirectly) that the method parameter injection of setExemptedPaths() for // the FetchMetadataInterceptor is functioning as expected, when configured appropriately. // Ensure we're using the specific test configuration, not the default simple configuration. - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("struts-testing.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("struts-testing.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); diff --git a/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml b/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml index 28c0d656a..55a8f3206 100644 --- a/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml +++ b/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml @@ -20,6 +20,6 @@ */ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> \ No newline at end of file diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml b/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml index c6e256f82..8e23a208f 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml +++ b/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml @@ -21,8 +21,8 @@ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> diff --git a/core/src/test/resources/xwork-1.0.dtd b/core/src/test/resources/struts-2.0.dtd similarity index 100% rename from core/src/test/resources/xwork-1.0.dtd rename to core/src/test/resources/struts-2.0.dtd diff --git a/core/src/test/resources/struts.xml b/core/src/test/resources/struts.xml index cae2eb88b..ca6609e75 100644 --- a/core/src/test/resources/struts.xml +++ b/core/src/test/resources/struts.xml @@ -20,8 +20,8 @@ */ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd">