From 98c426ca4f4c8d1618a4035bbd150d052f9c2cbc Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 7 Jun 2023 15:14:27 +0200 Subject: [PATCH] Remove System.out.println from tests --- .../annotation/InlineDataSourceDefinitionTests.java | 3 +-- .../support/DefaultBatchConfigurationTests.java | 3 +-- .../batch/core/configuration/xml/DummyStep.java | 4 ++-- .../core/launch/support/SimpleJvmExitCodeMapperTests.java | 3 +-- .../batch/core/listener/ItemListenerErrorTests.java | 7 +------ .../batch/core/observability/BatchMetricsTests.java | 8 +++++--- .../repository/dao/OptimisticLockingFailureTests.java | 5 +---- .../batch/core/step/skip/ReprocessExceptionTests.java | 5 +---- .../tasklet/SystemCommandTaskletIntegrationTests.java | 3 +-- .../batch/core/step/tasklet/TaskletSupport.java | 3 +-- .../core/test/concurrent/ConcurrentTransactionTests.java | 2 -- .../batch/repeat/support/AbstractTradeBatchTests.java | 3 +-- .../chunk/RemoteChunkingManagerStepBuilderTests.java | 3 --- .../retry/TransactionalPollingIntegrationTests.java | 3 +-- .../test/StepScopeAnnotatedListenerIntegrationTests.java | 3 --- 15 files changed, 17 insertions(+), 41 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/InlineDataSourceDefinitionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/InlineDataSourceDefinitionTests.java index bc36a2635..cdacf2c81 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/InlineDataSourceDefinitionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/InlineDataSourceDefinitionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-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. @@ -62,7 +62,6 @@ class InlineDataSourceDefinitionTests { public Job job(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new JobBuilder("job", jobRepository) .start(new StepBuilder("step", jobRepository).tasklet((contribution, chunkContext) -> { - System.out.println("hello world"); return RepeatStatus.FINISHED; }, transactionManager).build()) .build(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultBatchConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultBatchConfigurationTests.java index 9f0a641d2..cefcd11d1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultBatchConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultBatchConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-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. @@ -132,7 +132,6 @@ class DefaultBatchConfigurationTests { @Bean public Step myStep(JobRepository jobRepository, PlatformTransactionManager transactionManager) { Tasklet myTasklet = (contribution, chunkContext) -> { - System.out.println("Hello world"); return RepeatStatus.FINISHED; }; return new StepBuilder("myStep", jobRepository).tasklet(myTasklet, transactionManager).build(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java index cfa2222f7..8b59289a0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-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. @@ -22,6 +22,7 @@ import org.springframework.beans.factory.BeanNameAware; /** * @author Dan Garrette + * @author Mahmoud Ben Hassine * @since 2.0.1 */ public class DummyStep implements Step, BeanNameAware { @@ -40,7 +41,6 @@ public class DummyStep implements Step, BeanNameAware { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { - System.out.println("EXECUTING " + getName()); } @Override diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java index 077673db3..f1e0ca621 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-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. @@ -57,7 +57,6 @@ class SimpleJvmExitCodeMapperTests { @Test void testGetExitCodeWithPredefinedCodesOverridden() { - System.out.println(ecm2.intValue(ExitStatus.COMPLETED.getExitCode())); assertEquals(ecm2.intValue(ExitStatus.COMPLETED.getExitCode()), -1); assertEquals(ecm2.intValue(ExitStatus.FAILED.getExitCode()), -2); assertEquals(ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java index b75c36111..12a95871b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-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. @@ -196,11 +196,6 @@ class ItemListenerErrorTests { if (goingToFail) { throw new RuntimeException("failure in the writer"); } - else { - for (String item : items) { - System.out.println(item); - } - } } public void setGoingToFail(boolean goingToFail) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/observability/BatchMetricsTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/observability/BatchMetricsTests.java index dc1a10f15..760f23566 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/observability/BatchMetricsTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/observability/BatchMetricsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-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. @@ -261,7 +261,8 @@ class BatchMetricsTests { public Step step2(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("step2", jobRepository).chunk(2, transactionManager) .reader(new ListItemReader<>(Arrays.asList(1, 2, 3, 4, 5))) - .writer(items -> items.forEach(System.out::println)) + .writer(items -> { + }) .build(); } @@ -269,7 +270,8 @@ class BatchMetricsTests { public Step step3(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("step3", jobRepository).chunk(2, transactionManager) .reader(new ListItemReader<>(Arrays.asList(6, 7, 8, 9, 10))) - .writer(items -> items.forEach(System.out::println)) + .writer(items -> { + }) .faultTolerant() .skip(Exception.class) .skipLimit(3) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java index ef17f78f5..7443fbc3f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-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. @@ -110,9 +110,6 @@ class OptimisticLockingFailureTests { @Override public void write(Chunk items) throws Exception { - for (String item : items) { - System.out.println(item); - } } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java index 9416a3275..632212852 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-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. @@ -68,8 +68,6 @@ public class ReprocessExceptionTests { final Person transformedPerson = new Person(firstName, lastName); - System.out.println("Converting (" + person + ") into (" + transformedPerson + ")"); - return transformedPerson; } @@ -80,7 +78,6 @@ public class ReprocessExceptionTests { @Override public void write(Chunk persons) throws Exception { for (Person person : persons) { - System.out.println(person.getFirstName() + " " + person.getLastName()); if (person.getFirstName().equals("JANE")) { throw new RuntimeException("jane doe write exception causing rollback"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java index 08ceb3f7a..f4b401ba3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-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. @@ -176,7 +176,6 @@ class SystemCommandTaskletIntegrationTests { stepExecution.setTerminateOnly(); Exception exception = assertThrows(JobInterruptedException.class, () -> tasklet.execute(null, null)); String message = exception.getMessage(); - System.out.println(message); assertTrue(message.contains("Job interrupted while executing system command")); assertTrue(message.contains(command[0])); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java index 60c4dcb4f..308d67f73 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-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. @@ -25,7 +25,6 @@ public class TaskletSupport implements Tasklet { @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { - System.out.println("The tasklet was executed"); return RepeatStatus.FINISHED; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java index 09dfe7fb1..5a7686296 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java @@ -125,7 +125,6 @@ class ConcurrentTransactionTests { @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { - System.out.println(">> Beginning concurrent job test"); return RepeatStatus.FINISHED; } }, transactionManager).build(); @@ -137,7 +136,6 @@ class ConcurrentTransactionTests { @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { - System.out.println(">> Ending concurrent job test"); return RepeatStatus.FINISHED; } }, transactionManager).build(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java index 8f656101c..a95e9fbed 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-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. @@ -84,7 +84,6 @@ abstract class AbstractTradeBatchTests { @Override public synchronized void write(Chunk data) { count++; - System.out.println("Executing trade '" + data + "'"); } } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTests.java index f91e8396d..3173a0e89 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTests.java @@ -242,7 +242,6 @@ class RemoteChunkingManagerStepBuilderTests { when(retryListener.open(any(), any())).thenReturn(true); ItemProcessor itemProcessor = item -> { - System.out.println("processing item " + item); if (item.equals("b")) { throw new Exception("b was found"); } @@ -260,7 +259,6 @@ class RemoteChunkingManagerStepBuilderTests { @Nullable @Override public String read() throws Exception { - System.out.println(">> count == " + count); if (count == 6) { count++; throw new IOException("6th item"); @@ -271,7 +269,6 @@ class RemoteChunkingManagerStepBuilderTests { } else if (count < items.size()) { String item = items.get(count++); - System.out.println(">> item read was " + item); return item; } else { diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java index 0ce5f6242..1b8499583 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-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. @@ -106,7 +106,6 @@ class TransactionalPollingIntegrationTests implements ApplicationContextAware { assertEquals(expected, processed); } catch (Throwable t) { - System.out.println(t.getMessage()); t.printStackTrace(); } } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java index f0e3ec469..8360af7e4 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java @@ -80,9 +80,6 @@ class StepScopeAnnotatedListenerIntegrationTests { @AfterStep public ExitStatus exploitState(StepExecution stepExecution) { - System.out.println("******************************"); - System.out.println(" READING RESULTS : " + list.size()); - return stepExecution.getExitStatus(); }