Stop printing to System.out in SpEL tests

This commit is contained in:
Sam Brannen
2023-03-17 10:42:58 +01:00
parent 2c2ef12f68
commit 94bbf85c0e
3 changed files with 10 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
public abstract class AbstractExpressionTests {
private static final boolean DEBUG = false;
protected static final boolean DEBUG = false;
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) {
assertThatExceptionOfType(SpelParseException.class).isThrownBy(() -> {
Expression expr = parser.parseExpression(expression);
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
}).satisfies(ex -> {
assertThat(ex.getMessageCode()).isEqualTo(expectedMessage);
if (otherProperties != null && otherProperties.length != 0) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1448,7 +1448,9 @@ class EvaluationTests extends AbstractExpressionTests {
private void expectFail(ExpressionParser parser, EvaluationContext eContext, String expressionString, SpelMessage messageCode) {
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> {
Expression e = parser.parseExpression(expressionString);
SpelUtilities.printAbstractSyntaxTree(System.out, e);
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
}
e.getValue(eContext);
}).satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(messageCode));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1817,7 +1817,6 @@ class SpelReproTests extends AbstractExpressionTests {
static class CCC {
public boolean method(Object o) {
System.out.println(o);
return false;
}
}
@@ -1889,7 +1888,6 @@ class SpelReproTests extends AbstractExpressionTests {
static class Foo2 {
public void execute(String str) {
System.out.println("Value: " + str);
}
}
@@ -1964,7 +1962,6 @@ class SpelReproTests extends AbstractExpressionTests {
public static class ReflectionUtil<T extends Number> {
public Object methodToCall(T param) {
System.out.println(param + " " + param.getClass());
return "Object methodToCall(T param)";
}