Search in sources :

Example 71 with Bar

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"));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) Map(java.util.Map) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig)

Aggregations

HashMap (java.util.HashMap)17 Bar (com.opensymphony.xwork2.util.Bar)14 Foo (com.opensymphony.xwork2.util.Foo)13 ValueStack (com.opensymphony.xwork2.util.ValueStack)12 ActionProxy (com.opensymphony.xwork2.ActionProxy)9 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)9 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)7 ValidationAware (com.opensymphony.xwork2.interceptor.ValidationAware)7 List (java.util.List)6 Map (java.util.Map)6 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)5 Mock (com.mockobjects.dynamic.Mock)4 ActionContext (com.opensymphony.xwork2.ActionContext)4 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)4 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)3 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)3 MockResult (com.opensymphony.xwork2.mock.MockResult)3 ModelDrivenAction2 (com.opensymphony.xwork2.test.ModelDrivenAction2)3 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)3 ActionSupport (com.opensymphony.xwork2.ActionSupport)2