SPR-6941: part (1) correct exception handling when null cachedExecutor

This commit is contained in:
Andy Clement
2010-03-09 17:33:36 +00:00
parent 0efb9d8023
commit 2dd1134303
2 changed files with 49 additions and 11 deletions

View File

@@ -156,6 +156,33 @@ public class MethodInvocationTests extends ExpressionTestCase {
Assert.assertEquals(4,parser.parseExpression("counter").getValue(eContext));
}
/**
* Check on first usage (when the cachedExecutor in MethodReference is null) that the exception is not wrapped.
*/
@Test
public void testMethodThrowingException_SPR6941() {
// Test method on inventor: throwException()
// On 1 it will throw an IllegalArgumentException
// On 2 it will throw a RuntimeException
// On 3 it will exit normally
// In each case it increments the Inventor field 'counter' when invoked
SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("throwException(#bar)");
eContext.setVariable("bar",2);
try {
expr.getValue(eContext);
Assert.fail();
} catch (Exception e) {
if (e instanceof SpelEvaluationException) {
e.printStackTrace();
Assert.fail("Should not be a SpelEvaluationException");
}
// normal
}
}
@Test
public void testMethodFiltering_SPR6764() {
SpelExpressionParser parser = new SpelExpressionParser();