add EventAttributeELResolver

improved invalid variable ex message
This commit is contained in:
Keith Donald
2008-04-11 15:24:55 +00:00
parent a5a5c8e4cd
commit ab3d438119
7 changed files with 131 additions and 9 deletions

View File

@@ -12,6 +12,7 @@ import javax.el.VariableMapper;
import junit.framework.TestCase;
import org.jboss.el.ExpressionFactoryImpl;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionVariable;
import org.springframework.binding.expression.ParserException;
@@ -70,12 +71,24 @@ public class ELExpressionParserTests extends TestCase {
assertEquals(new Long(2), exp.getValue(new TestBean()));
}
public void testParseEvalExpressionWithContextCustomTestBeanResolver() {
public void testParseEvalExpressionWithContextCustomELVariableResolver() {
String expressionString = "specialProperty";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().evaluate(TestBean.class));
assertEquals("Custom resolver resolved this special property!", exp.getValue(new TestBean()));
}
public void testParseBeanEvalExpressionInvalidELVariable() {
try {
String expressionString = "bogus";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
.evaluate(TestBean.class));
exp.getValue(new TestBean());
fail("Should have failed");
} catch (EvaluationException e) {
}
}
public void testParseLiteralExpression() {
String expressionString = "'value'";
Expression exp = parser.parseExpression(expressionString, null);
@@ -181,9 +194,10 @@ public class ELExpressionParserTests extends TestCase {
public Object getValue(ELContext arg0, Object arg1, Object arg2) {
if (arg1 == null && arg2.equals("specialProperty")) {
arg0.setPropertyResolved(true);
return "Custom resolver resolved this special property!";
} else {
throw new IllegalStateException();
return null;
}
}