From 94bbf85c0e348091ee2923d834ee1e1ef35a19c2 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 17 Mar 2023 10:42:58 +0100 Subject: [PATCH] Stop printing to System.out in SpEL tests --- .../expression/spel/AbstractExpressionTests.java | 8 +++++--- .../springframework/expression/spel/EvaluationTests.java | 6 ++++-- .../springframework/expression/spel/SpelReproTests.java | 5 +---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java index 0e133522f621..867076e121fc 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java @@ -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 @@ */ 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 @@ protected void evaluateAndCheckError(String expression, Class expectedReturnT 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) { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java index 5a628c7051fc..ec2fcfc55ead 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java @@ -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 @@ private void expectFailNotDecrementable(ExpressionParser parser, EvaluationConte 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)); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 35011fba218d..94aa7468cfa6 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -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 @@ else if (beanName.equals("goo")) { static class CCC { public boolean method(Object o) { - System.out.println(o); return false; } } @@ -1889,7 +1888,6 @@ static class Foo { static class Foo2 { public void execute(String str) { - System.out.println("Value: " + str); } } @@ -1964,7 +1962,6 @@ public String process(String... args) { public static class ReflectionUtil { public Object methodToCall(T param) { - System.out.println(param + " " + param.getClass()); return "Object methodToCall(T param)"; }