Search in sources :

Example 16 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class ConfigurationTest method testInterceptorParamInheritance.

public void testInterceptorParamInheritance() {
    try {
        ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInheritance", null, null);
        assertEquals(1, proxy.getConfig().getInterceptors().size());
        MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
        assertEquals("expectedFoo", testInterceptor.getExpectedFoo());
        proxy.execute();
        assertTrue(testInterceptor.isExecuted());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) MockInterceptor(com.opensymphony.xwork2.mock.MockInterceptor)

Example 17 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class ConfigurationTest method testPackageExtension.

public void testPackageExtension() {
    try {
        ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "Bar", null, null);
        assertEquals(4, proxy.getConfig().getInterceptors().size());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy)

Example 18 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class ActionConfigMatcherTest method buildActionConfigMap.

private Map<String, ActionConfig> buildActionConfigMap() {
    Map<String, ActionConfig> map = new HashMap<>();
    HashMap<String, String> params = new HashMap<>();
    params.put("first", "{1}");
    params.put("second", "{2}");
    ActionConfig config = new ActionConfig.Builder("package-{1}", "foo/*/*", "foo.bar.{1}Action").methodName("do{2}").addParams(params).addExceptionMapping(new ExceptionMappingConfig.Builder("foo{1}", "java.lang.{2}Exception", "success{1}").addParams(new HashMap<>(params)).build()).addInterceptor(new InterceptorMapping(null, null)).addResultConfig(new ResultConfig.Builder("success{1}", "foo.{2}").addParams(params).build()).setStrictMethodInvocation(false).build();
    map.put("foo/*/*", config);
    config = new ActionConfig.Builder("package-{1}", "bar/*/**", "bar").methodName("do{1}_{1}").addParam("first", "{2}").setStrictMethodInvocation(false).build();
    map.put("bar/*/**", config);
    config = new ActionConfig.Builder("package", "eventAdd!*", "bar").methodName("{1}").setStrictMethodInvocation(false).build();
    map.put("addEvent!*", config);
    map.put("noWildcard", new ActionConfig.Builder("", "", "").build());
    return map;
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) ResultConfig(com.opensymphony.xwork2.config.entities.ResultConfig) HashMap(java.util.HashMap) InterceptorMapping(com.opensymphony.xwork2.config.entities.InterceptorMapping) ExceptionMappingConfig(com.opensymphony.xwork2.config.entities.ExceptionMappingConfig)

Example 19 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class ActionConfigMatcherTest method testCheckMultipleSubstitutions.

public void testCheckMultipleSubstitutions() {
    ActionConfig m = matcher.match("bar/class/method/more");
    assertTrue("Method hasn't been replaced correctly: " + m.getMethodName(), "doclass_class".equals(m.getMethodName()));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig)

Example 20 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class XmlConfigurationProviderActionsTest method testDefaultActionClass.

public void testDefaultActionClass() throws Exception {
    final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml";
    final String testDefaultClassName = "com.opensymphony.xwork2.ActionSupport";
    ConfigurationProvider provider = buildConfigurationProvider(filename);
    // setup expectations
    params.put("foo", "17");
    params.put("bar", "23");
    ActionConfig barWithoutClassNameConfig = new ActionConfig.Builder("", "BarWithoutClassName", "").addParams(params).build();
    // execute the configuration
    provider.init(configuration);
    PackageConfig pkg = configuration.getPackageConfig("default");
    Map actionConfigs = pkg.getActionConfigs();
    // assertions
    assertEquals(7, actionConfigs.size());
    assertEquals(barWithoutClassNameConfig, actionConfigs.get("BarWithoutClassName"));
}
Also used : ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) Map(java.util.Map) HashMap(java.util.HashMap)

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