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();
}
}
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();
}
}
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;
}
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()));
}
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"));
}
Aggregations