// 4 will make it throw a checked exception - this will be wrapped by spel on the way out
// Now cause it to throw an exception:
eContext.setVariable("bar",4);
eContext.setVariable("bar",1);
try{
try{
o=expr.getValue(eContext);
o=expr.getValue(eContext);
Assert.fail("Should have failed");
}catch(Exceptione){
}catch(Exceptione){
// A problem occurred whilst attempting to construct an object of type 'org.springframework.expression.spel.ConstructorInvocationTests$Tester' using arguments '(java.lang.Integer)'
// A problem occurred whilst attempting to construct an object of type 'org.springframework.expression.spel.ConstructorInvocationTests$Tester' using arguments '(java.lang.Integer)'
intidx=e.getMessage().indexOf("Tester");
intidx=e.getMessage().indexOf("Tester");
@ -115,6 +122,22 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
}
}
// If counter is 4 then the method got called twice!
// If counter is 4 then the method got called twice!
// 1 will make it throw a RuntimeException - SpEL will let this through
eContext.setVariable("bar",1);
try{
o=expr.getValue(eContext);
Assert.fail("Should have failed");
}catch(Exceptione){
// A problem occurred whilst attempting to construct an object of type 'org.springframework.expression.spel.ConstructorInvocationTests$Tester' using arguments '(java.lang.Integer)'
if(einstanceofSpelEvaluationException){
e.printStackTrace();
Assert.fail("Should not have been wrapped");
}
}
// If counter is 5 then the method got called twice!