From 39bc7566df266f74888b723d64c2c0f34e7b114e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 24 Jun 2023 14:10:12 +0200 Subject: [PATCH] Stop printing to System.out in tests --- .../expression/spel/support/Spr7538Tests.java | 11 ++++++++--- .../aop/framework/IntroductionBenchmarkTests.java | 6 ++++-- .../test/java/example/scannable/FooServiceImpl.java | 3 +-- .../aop/target/CommonsPool2TargetSourceTests.java | 3 +-- .../springframework/context/support/Assembler.java | 6 ++++-- .../org/springframework/context/support/Logic.java | 5 +++-- .../listener/adapter/StubMessageListenerAdapter.java | 4 ++-- ...istenceExceptionTranslationPostProcessorTests.java | 4 ++-- .../web/servlet/tags/form/TextareaTagTests.java | 3 +-- 9 files changed, 26 insertions(+), 19 deletions(-) diff --git a/integration-tests/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java b/integration-tests/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java index 372d232f714..6fe548b5de8 100644 --- a/integration-tests/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java +++ b/integration-tests/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 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. @@ -21,11 +21,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.MethodExecutor; +import org.springframework.expression.TypedValue; + +import static org.assertj.core.api.Assertions.assertThat; class Spr7538Tests { @@ -49,8 +53,9 @@ class Spr7538Tests { ReflectiveMethodResolver resolver = new ReflectiveMethodResolver(); MethodExecutor executor = resolver.resolve(context, target, "checkCompleteness", argumentTypes); - Object result = executor.execute(context, target, arguments); - System.out.println("Result: " + result); + TypedValue typedValue = executor.execute(context, target, arguments); + assertThat(typedValue.getValue()).asInstanceOf(InstanceOfAssertFactories.BOOLEAN).isTrue(); + assertThat(typedValue.getTypeDescriptor().getType()).isEqualTo(Boolean.class); } static class AlwaysTrueReleaseStrategy { diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java index aa9b1706f71..959c4cd25a3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -82,6 +82,8 @@ public class IntroductionBenchmarkTests { } sw.stop(); - System.out.println(sw.prettyPrint()); + // TODO Add reasonable assertions. + // System.out.println(sw.prettyPrint()); } + } diff --git a/spring-context/src/test/java/example/scannable/FooServiceImpl.java b/spring-context/src/test/java/example/scannable/FooServiceImpl.java index 7a858e5462b..11cd8390e68 100644 --- a/spring-context/src/test/java/example/scannable/FooServiceImpl.java +++ b/spring-context/src/test/java/example/scannable/FooServiceImpl.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. @@ -93,7 +93,6 @@ public abstract class FooServiceImpl implements FooService { @Override @SuppressWarnings("deprecation") public Future asyncFoo(int id) { - System.out.println(Thread.currentThread().getName()); Assert.state(ServiceInvocationCounter.getThreadLocalCount() != null, "Thread-local counter not exposed"); return new org.springframework.scheduling.annotation.AsyncResult<>(fooDao().findFoo(id)); } diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index cd5f3835893..e4ecb2bb655 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.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. @@ -187,7 +187,6 @@ class CommonsPool2TargetSourceTests { // release all objects for (int i = 0; i < pooledInstances.length; i++) { - System.out.println(i); targetSource.releaseTarget(pooledInstances[i]); } } diff --git a/spring-context/src/test/java/org/springframework/context/support/Assembler.java b/spring-context/src/test/java/org/springframework/context/support/Assembler.java index 53f40a5dfe7..812febe301b 100644 --- a/spring-context/src/test/java/org/springframework/context/support/Assembler.java +++ b/spring-context/src/test/java/org/springframework/context/support/Assembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -23,7 +23,10 @@ public class Assembler implements TestIF { @SuppressWarnings("unused") private Service service; + private Logic l; + + @SuppressWarnings("unused") private String name; public void setService(Service service) { @@ -42,7 +45,6 @@ public class Assembler implements TestIF { } public void output() { - System.out.println("Bean " + name); l.output(); } diff --git a/spring-context/src/test/java/org/springframework/context/support/Logic.java b/spring-context/src/test/java/org/springframework/context/support/Logic.java index 6ac62b33ad6..8dfba5efb42 100644 --- a/spring-context/src/test/java/org/springframework/context/support/Logic.java +++ b/spring-context/src/test/java/org/springframework/context/support/Logic.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanNameAware; public class Logic implements BeanNameAware { + @SuppressWarnings("unused") private String name; @SuppressWarnings("unused") @@ -35,7 +36,7 @@ public class Logic implements BeanNameAware { } public void output() { - System.out.println("Bean " + name); + // System.out.println("Bean " + name); } } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/StubMessageListenerAdapter.java b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/StubMessageListenerAdapter.java index bffa75ed49d..39c1b3d48de 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/StubMessageListenerAdapter.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/StubMessageListenerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -37,7 +37,7 @@ public class StubMessageListenerAdapter extends MessageListenerAdapter { @Override protected void handleListenerException(Throwable ex) { - System.out.println(ex); + // System.out.println(ex); } } diff --git a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java index 46e125464da..bf48b55b033 100644 --- a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 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. @@ -131,7 +131,7 @@ public class PersistenceExceptionTranslationPostProcessorTests { @Before("execution(void *.additionalMethod(*))") public void log(JoinPoint jp) { - System.out.println("Before " + jp.getSignature().getName()); + // System.out.println("Before " + jp.getSignature().getName()); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java index cb08134dd72..fd1597724e8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 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. @@ -103,7 +103,6 @@ public class TextareaTagTests extends AbstractFormTagTests { assertThat(this.tag.doStartTag()).isEqualTo(Tag.SKIP_BODY); String output = getOutput(); - System.out.println(output); assertContainsAttribute(output, "name", "name"); assertBlockTagContains(output, HTML_ESCAPED_NAME); }