use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderActionsTest method testInvalidActions.
public void testInvalidActions() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-action-invalid.xml";
try {
ConfigurationProvider provider = buildConfigurationProvider(filename);
fail("Should have thrown an exception");
} catch (ConfigurationException ex) {
// it worked correctly
}
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderActionsTest method testPackageDefaultClassRef.
public void testPackageDefaultClassRef() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions-packagedefaultclassref.xml";
final String testDefaultClassName = "com.opensymphony.xwork2.UserSpecifiedDefaultAction";
ConfigurationProvider provider = buildConfigurationProvider(filename);
// setup expectations
params.put("foo", "17");
params.put("bar", "23");
ActionConfig barWithPackageDefaultClassRefConfig = new ActionConfig.Builder("", "Bar", "").addParams(params).build();
// execute the configuration
provider.init(configuration);
PackageConfig pkg = configuration.getPackageConfig("default");
Map actionConfigs = pkg.getActionConfigs();
// assertions
assertEquals(1, actionConfigs.size());
assertEquals(barWithPackageDefaultClassRefConfig, actionConfigs.get("Bar"));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderAllowedMethodsTest method testDefaultAllowedMethods.
public void testDefaultAllowedMethods() 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("default");
Map actionConfigs = pkg.getActionConfigs();
// assertions
assertEquals(5, actionConfigs.size());
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(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"));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider 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