Stop printing to System.out in SpEL tests

This commit is contained in:
Sam Brannen 2023-03-17 10:42:58 +01:00
parent 46bd6add15
commit dd4a34778b
3 changed files with 7 additions and 6 deletions

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/ */
public abstract class AbstractExpressionTests { public abstract class AbstractExpressionTests {
private static final boolean DEBUG = false; protected static final boolean DEBUG = false;
protected static final boolean SHOULD_BE_WRITABLE = true; protected static final boolean SHOULD_BE_WRITABLE = true;
@ -202,7 +202,9 @@ public abstract class AbstractExpressionTests {
protected void parseAndCheckError(String expression, SpelMessage expectedMessage, Object... otherProperties) { protected void parseAndCheckError(String expression, SpelMessage expectedMessage, Object... otherProperties) {
assertThatExceptionOfType(SpelParseException.class).isThrownBy(() -> { assertThatExceptionOfType(SpelParseException.class).isThrownBy(() -> {
Expression expr = parser.parseExpression(expression); Expression expr = parser.parseExpression(expression);
SpelUtilities.printAbstractSyntaxTree(System.out, expr); if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
}).satisfies(ex -> { }).satisfies(ex -> {
assertThat(ex.getMessageCode()).isEqualTo(expectedMessage); assertThat(ex.getMessageCode()).isEqualTo(expectedMessage);
if (otherProperties != null && otherProperties.length != 0) { if (otherProperties != null && otherProperties.length != 0) {

View File

@ -1450,7 +1450,9 @@ class EvaluationTests extends AbstractExpressionTests {
private void expectFail(ExpressionParser parser, EvaluationContext eContext, String expressionString, SpelMessage messageCode) { private void expectFail(ExpressionParser parser, EvaluationContext eContext, String expressionString, SpelMessage messageCode) {
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> { assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> {
Expression e = parser.parseExpression(expressionString); Expression e = parser.parseExpression(expressionString);
SpelUtilities.printAbstractSyntaxTree(System.out, e); if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
}
e.getValue(eContext); e.getValue(eContext);
}).satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(messageCode)); }).satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(messageCode));
} }

View File

@ -1811,7 +1811,6 @@ class SpelReproTests extends AbstractExpressionTests {
static class CCC { static class CCC {
public boolean method(Object o) { public boolean method(Object o) {
System.out.println(o);
return false; return false;
} }
} }
@ -1883,7 +1882,6 @@ class SpelReproTests extends AbstractExpressionTests {
static class Foo2 { static class Foo2 {
public void execute(String str) { public void execute(String str) {
System.out.println("Value: " + str);
} }
} }
@ -1958,7 +1956,6 @@ class SpelReproTests extends AbstractExpressionTests {
public static class ReflectionUtil<T extends Number> { public static class ReflectionUtil<T extends Number> {
public Object methodToCall(T param) { public Object methodToCall(T param) {
System.out.println(param + " " + param.getClass());
return "Object methodToCall(T param)"; return "Object methodToCall(T param)";
} }