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 b04cffb36..c27f95b58 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 @@ -862,7 +862,6 @@ public class XmlConfigurationProvider implements ConfigurationProvider { allowedMethods = packageContext.getGlobalAllowedMethods(); if (allowedMethodsEls.getLength() > 0) { - allowedMethods = new HashSet<>(); Node n = allowedMethodsEls.item(0).getFirstChild(); if (n != null) { String s = n.getNodeValue().trim(); diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java index 4b4460ae7..e5f397f94 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderAllowedMethodsTest.java @@ -29,38 +29,48 @@ public class XmlConfigurationProviderAllowedMethodsTest extends ConfigurationTes ActionConfig action = (ActionConfig) actionConfigs.get("Default"); assertEquals(1, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); assertTrue(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Boring"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Foo"); - assertEquals(1, action.getAllowedMethods().size()); + assertEquals(3, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Bar"); - assertEquals(2, action.getAllowedMethods().size()); + assertEquals(4, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Baz"); - assertEquals(3, action.getAllowedMethods().size()); + assertEquals(5, action.getAllowedMethods().size()); assertFalse(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); @@ -82,40 +92,50 @@ public class XmlConfigurationProviderAllowedMethodsTest extends ConfigurationTes assertEquals(5, actionConfigs.size()); ActionConfig action = (ActionConfig) actionConfigs.get("Default"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Boring"); - assertEquals(0, action.getAllowedMethods().size()); + assertEquals(2, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertFalse(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Foo"); - assertEquals(1, action.getAllowedMethods().size()); + assertEquals(3, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertFalse(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Bar"); - assertEquals(2, action.getAllowedMethods().size()); + assertEquals(4, action.getAllowedMethods().size()); assertTrue(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertFalse(action.isAllowedMethod("baz")); assertFalse(action.isAllowedMethod("xyz")); action = (ActionConfig) actionConfigs.get("Baz"); - assertEquals(3, action.getAllowedMethods().size()); + assertEquals(5, action.getAllowedMethods().size()); assertFalse(action.isAllowedMethod("execute")); + assertTrue(action.isAllowedMethod("input")); + assertTrue(action.isAllowedMethod("cancel")); assertTrue(action.isAllowedMethod("foo")); assertTrue(action.isAllowedMethod("bar")); assertTrue(action.isAllowedMethod("baz")); 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 6741e668c..c19ef525b 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 @@ -1,10 +1,11 @@ + input,cancel @@ -26,6 +27,7 @@ + input,cancel