use of com.opensymphony.xwork2.util.Foo in project struts by apache.
the class AnnotationActionValidatorManagerTest method testDefaultMessageInterpolation.
public void testDefaultMessageInterpolation() {
// get validators
List validatorList = annotationActionValidatorManager.getValidators(AnnotatedTestBean.class, "beanMessageBundle");
assertEquals(3, validatorList.size());
try {
AnnotatedTestBean bean = new AnnotatedTestBean();
bean.setName("foo");
bean.setCount(99);
ValidatorContext context = new DummyValidatorContext(bean, tpf);
annotationActionValidatorManager.validate(bean, "beanMessageBundle", context);
assertTrue(context.hasErrors());
assertTrue(context.hasFieldErrors());
List<String> l = context.getFieldErrors().get("count");
assertNotNull(l);
assertEquals(1, l.size());
assertEquals("Smaller Invalid Count: 99", l.get(0));
} catch (ValidationException ex) {
ex.printStackTrace();
fail("Validation error: " + ex.getMessage());
}
}
use of com.opensymphony.xwork2.util.Foo in project struts by apache.
the class AnnotationActionValidatorManagerTest method testMessageInterpolation.
public void testMessageInterpolation() {
// get validators
List validatorList = annotationActionValidatorManager.getValidators(AnnotatedTestBean.class, "beanMessageBundle");
assertEquals(3, validatorList.size());
try {
AnnotatedTestBean bean = new AnnotatedTestBean();
bean.setName("foo");
bean.setCount(150);
ValidatorContext context = new DummyValidatorContext(bean, tpf);
annotationActionValidatorManager.validate(bean, "beanMessageBundle", context);
assertTrue(context.hasErrors());
assertTrue(context.hasFieldErrors());
List<String> l = context.getFieldErrors().get("count");
assertNotNull(l);
assertEquals(1, l.size());
assertEquals("Count must be between 1 and 100, current value is 150.", l.get(0));
} catch (ValidationException ex) {
ex.printStackTrace();
fail("Validation error: " + ex.getMessage());
}
}
use of com.opensymphony.xwork2.util.Foo in project struts by apache.
the class NamedVariablePatternMatcherTest method testMatch.
@Test
public void testMatch() {
NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher();
Map<String, String> vars = new HashMap<>();
CompiledPattern pattern = new CompiledPattern(Pattern.compile("foo([^/]+)"), Arrays.asList("bar"));
assertTrue(matcher.match(vars, "foobaz", pattern));
assertEquals("baz", vars.get("bar"));
}
use of com.opensymphony.xwork2.util.Foo in project struts by apache.
the class ConfigurationTest method testGlobalResults.
public void testGlobalResults() {
try {
ActionProxy proxy = actionProxyFactory.createActionProxy("", "Foo", null, null);
assertNotNull(proxy.getConfig().getResults().get("login"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of com.opensymphony.xwork2.util.Foo 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();
}
}
Aggregations