cause linking tests and improvements

This commit is contained in:
Keith Donald
2008-11-04 12:10:16 +00:00
parent 4014d389ef
commit ed67d269c0
3 changed files with 61 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ package org.springframework.binding.expression.ognl;
import junit.framework.TestCase;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionVariable;
import org.springframework.binding.expression.ParserException;
@@ -215,4 +216,24 @@ public class OgnlExpressionParserTests extends TestCase {
}
}
public void testReasonCauseLinkingGetValue() {
String exp = "getException()";
Expression e = parser.parseExpression(exp, null);
try {
e.getValue(bean);
} catch (EvaluationException ex) {
assertTrue(ex.getCause().getCause() instanceof IllegalStateException);
}
}
public void testReasonCauseLinkingSetValue() {
String exp = "exceptionProperty";
Expression e = parser.parseExpression(exp, null);
try {
e.setValue(bean, "does not matter");
} catch (EvaluationException ex) {
assertTrue(ex.getCause().getCause() instanceof IllegalStateException);
}
}
}

View File

@@ -61,4 +61,12 @@ public class TestBean {
this.date = date;
}
public Exception getException() {
throw new IllegalStateException("Test");
}
public void setExceptionProperty(String whatever) {
throw new IllegalStateException("Test");
}
}