use of org.springframework.expression.ExpressionException in project spring-framework by spring-projects.
the class SpelReproTests method checkTemplateParsingError.
private void checkTemplateParsingError(String expression, ParserContext context, String expectedMessage) throws Exception {
SpelExpressionParser parser = new SpelExpressionParser();
try {
parser.parseExpression(expression, context);
fail("Should have failed with message: " + expectedMessage);
} catch (Exception ex) {
String message = ex.getMessage();
if (ex instanceof ExpressionException) {
message = ((ExpressionException) ex).getSimpleMessage();
}
if (!message.equals(expectedMessage)) {
ex.printStackTrace();
}
assertThat(expectedMessage, equalTo(message));
}
}
use of org.springframework.expression.ExpressionException in project spring-framework by spring-projects.
the class SpelParserTests method exceptions.
@Test
public void exceptions() {
ExpressionException exprEx = new ExpressionException("test");
assertEquals("test", exprEx.getSimpleMessage());
assertEquals("test", exprEx.toDetailedString());
assertEquals("test", exprEx.getMessage());
exprEx = new ExpressionException("wibble", "test");
assertEquals("test", exprEx.getSimpleMessage());
assertEquals("Expression [wibble]: test", exprEx.toDetailedString());
assertEquals("Expression [wibble]: test", exprEx.getMessage());
exprEx = new ExpressionException("wibble", 3, "test");
assertEquals("test", exprEx.getSimpleMessage());
assertEquals("Expression [wibble] @3: test", exprEx.toDetailedString());
assertEquals("Expression [wibble] @3: test", exprEx.getMessage());
}
Aggregations