use of com.opensymphony.xwork2.util.Foo 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.Foo in project struts by apache.
the class ActionConfigMatcherTest method testReplaceParametersWithNoAppendingParams.
/**
* Test to make sure the {@link AbstractMatcher#replaceParameters(Map, Map)} method isn't adding values to the
* return value.
*/
public void testReplaceParametersWithNoAppendingParams() {
Map<String, ActionConfig> map = new HashMap<>();
HashMap<String, String> params = new HashMap<>();
params.put("first", "{1}");
ActionConfig config = new ActionConfig.Builder("package", "foo/{one}/{two}/{three}", "foo.bar.Action").addParams(params).addExceptionMapping(new ExceptionMappingConfig.Builder("foo{1}", "java.lang.{2}Exception", "success{1}").addParams(new HashMap<>(params)).build()).addResultConfig(new ResultConfig.Builder("success{1}", "foo.{2}").addParams(params).build()).setStrictMethodInvocation(false).build();
map.put("foo/{one}/{two}/{three}", config);
ActionConfigMatcher replaceMatcher = new ActionConfigMatcher(new RegexPatternMatcher(), map, false, false);
ActionConfig matched = replaceMatcher.match("foo/paramOne/paramTwo/paramThree");
assertNotNull("ActionConfig should be matched", matched);
// Verify all The ActionConfig, ExceptionConfig, and ResultConfig have the correct number of params
assertEquals("The ActionConfig should have the correct number of params", 1, matched.getParams().size());
assertEquals("The ExceptionMappingConfigs should have the correct number of params", 1, matched.getExceptionMappings().get(0).getParams().size());
assertEquals("The ResultConfigs should have the correct number of params", 1, matched.getResults().get("successparamOne").getParams().size());
// Verify the params are still getting their values replaced correctly
assertEquals("The ActionConfig params have replaced values", "paramOne", matched.getParams().get("first"));
assertEquals("The ActionConfig params have replaced values", "paramOne", matched.getExceptionMappings().get(0).getParams().get("first"));
assertEquals("The ActionConfig params have replaced values", "paramOne", matched.getResults().get("successparamOne").getParams().get("first"));
}
use of com.opensymphony.xwork2.util.Foo 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.Foo in project struts by apache.
the class ActionConfigMatcherTest method testCheckSubstitutionsMatch.
public void testCheckSubstitutionsMatch() {
ActionConfig m = matcher.match("foo/class/method");
assertTrue("Class hasn't been replaced", "foo.bar.classAction".equals(m.getClassName()));
assertTrue("Method hasn't been replaced", "domethod".equals(m.getMethodName()));
assertTrue("Package isn't correct", "package-class".equals(m.getPackageName()));
assertTrue("First param isn't correct", "class".equals(m.getParams().get("first")));
assertTrue("Second param isn't correct", "method".equals(m.getParams().get("second")));
ExceptionMappingConfig ex = m.getExceptionMappings().get(0);
assertTrue("Wrong name, was " + ex.getName(), "fooclass".equals(ex.getName()));
assertTrue("Wrong result", "successclass".equals(ex.getResult()));
assertTrue("Wrong exception", "java.lang.methodException".equals(ex.getExceptionClassName()));
assertTrue("First param isn't correct", "class".equals(ex.getParams().get("first")));
assertTrue("Second param isn't correct", "method".equals(ex.getParams().get("second")));
ResultConfig result = m.getResults().get("successclass");
assertTrue("Wrong name, was " + result.getName(), "successclass".equals(result.getName()));
assertTrue("Wrong classname", "foo.method".equals(result.getClassName()));
assertTrue("First param isn't correct", "class".equals(result.getParams().get("first")));
assertTrue("Second param isn't correct", "method".equals(result.getParams().get("second")));
}
use of com.opensymphony.xwork2.util.Foo in project struts by apache.
the class ActionConfigMatcherTest method testShouldMatch.
public void testShouldMatch() {
ActionConfig matched = matcher.match("foo/class/method");
assertNotNull("ActionConfig should be matched", matched);
assertTrue("ActionConfig should have properties, had " + matched.getParams().size(), matched.getParams().size() == 2);
assertTrue("ActionConfig should have interceptors", matched.getInterceptors().size() == 1);
assertTrue("ActionConfig should have ex mappings", matched.getExceptionMappings().size() == 1);
assertTrue("ActionConfig should have external refs", matched.getExceptionMappings().size() == 1);
assertTrue("ActionConfig should have results", matched.getResults().size() == 1);
}
Aggregations