use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class XmlConfigurationProviderAllowedMethodsTest method testStrictAllowedMethods.
public void testStrictAllowedMethods() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-allowed-methods.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
// execute the configuration
provider.init(configuration);
provider.loadPackages();
PackageConfig pkg = configuration.getPackageConfig("strict");
Map actionConfigs = pkg.getActionConfigs();
// assertions
assertEquals(5, actionConfigs.size());
ActionConfig action = (ActionConfig) actionConfigs.get("Default");
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(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(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(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(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"));
assertFalse(action.isAllowedMethod("xyz"));
}
Aggregations