}
public void testCreateMethodValidationRule() throws Exception {
loader.setFunctionExpressionParser(new OgnlFunctionExpressionParser());
loader.setConditionExpressionParser(new OgnlConditionExpressionParser());
ValidationMethodValidationRule rule = loader.createMethodValidationRule(TestBean.class, "validate", "code", "message", "'a', 'b', 'c'", "bla", "true");
TestBean testBean = new TestBean() {
public boolean validate() {
return false;
}
};
assertEquals("code", rule.getErrorCode());
assertEquals("message", rule.getDefaultErrorMessage());
ValidationContextUtils.setContext("bla");
assertTrue(rule.isApplicable(testBean));
ValidationContextUtils.clearContext();
Object[] args = rule.getErrorArguments(testBean);
assertEquals(3, args.length);
assertEquals(new Character('a'), args[0]);
assertEquals(new Character('b'), args[1]);
assertEquals(new Character('c'), args[2]);
assertFalse(rule.getCondition().check(testBean));
}