diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java index 7b44e971a..d373a1429 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 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. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java index 3d5f72b27..d2d3a9ed8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 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. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JsrSplitParsingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JsrSplitParsingTests.java index 4833f337b..436148b02 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JsrSplitParsingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JsrSplitParsingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 the original author or authors. + * Copyright 2013-2021 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. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index 2af14d49d..2913ae38c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2019 the original author or authors. + * Copyright 2008-2021 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. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 48acbf275..4cdd686f8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 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. diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java index 142572d28..1991b2a40 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2021 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. diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java index 98ae63ca0..7d7313834 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 the original author or authors. + * Copyright 2018-2021 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. diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java index 9871e3e7e..4c4e28990 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2021 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. diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilderTests.java index bffc4e1aa..4888b4bc9 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2021 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. diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java index 78b72684d..944e72dd4 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2021 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. @@ -85,12 +85,9 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void inputChannelMustNotBeNull() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .inputChannel(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingManagerStepBuilder("step").inputChannel(null).build()); // then assertThat(expectedException).hasMessage("inputChannel must not be null"); @@ -98,12 +95,9 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void outputChannelMustNotBeNull() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .outputChannel(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingManagerStepBuilder("step").outputChannel(null).build()); // then assertThat(expectedException).hasMessage("outputChannel must not be null"); @@ -111,12 +105,9 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void messagingTemplateMustNotBeNull() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .messagingTemplate(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingManagerStepBuilder("step").messagingTemplate(null).build()); // then assertThat(expectedException).hasMessage("messagingTemplate must not be null"); @@ -124,12 +115,9 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void maxWaitTimeoutsMustBeGreaterThanZero() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .maxWaitTimeouts(-1); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingManagerStepBuilder("step").maxWaitTimeouts(-1).build()); // then assertThat(expectedException).hasMessage("maxWaitTimeouts must be greater than zero"); @@ -137,12 +125,9 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void throttleLimitMustNotBeGreaterThanZero() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .throttleLimit(-1L); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingManagerStepBuilder("step").throttleLimit(-1L).build()); // then assertThat(expectedException).hasMessage("throttleLimit must be greater than zero"); @@ -177,17 +162,16 @@ public class RemoteChunkingManagerStepBuilderTest { @Test public void testUnsupportedOperationExceptionWhenSpecifyingAnItemWriter() { - // given - final RemoteChunkingManagerStepBuilder builder = new RemoteChunkingManagerStepBuilder("step") - .reader(this.itemReader) - .writer(items -> { }) - .repository(this.jobRepository) - .transactionManager(this.transactionManager) - .inputChannel(this.inputChannel) - .outputChannel(this.outputChannel); - // when - final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class, builder::build); + final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class, + () -> new RemoteChunkingManagerStepBuilder("step") + .reader(this.itemReader) + .writer(items -> { }) + .repository(this.jobRepository) + .transactionManager(this.transactionManager) + .inputChannel(this.inputChannel) + .outputChannel(this.outputChannel) + .build()); // then assertThat(expectedException).hasMessage("When configuring a manager " + diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilderTest.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilderTest.java index a2815e883..d20aa29d0 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilderTest.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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. @@ -36,12 +36,9 @@ public class RemoteChunkingWorkerBuilderTest { @Test public void itemProcessorMustNotBeNull() { - // given - final RemoteChunkingWorkerBuilder builder = new RemoteChunkingWorkerBuilder() - .itemProcessor(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingWorkerBuilder().itemProcessor(null).build()); // then assertThat(expectedException).hasMessage("itemProcessor must not be null"); @@ -49,12 +46,9 @@ public class RemoteChunkingWorkerBuilderTest { @Test public void itemWriterMustNotBeNull() { - // given - final RemoteChunkingWorkerBuilder builder = new RemoteChunkingWorkerBuilder() - .itemWriter(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingWorkerBuilder().itemWriter(null).build()); // then assertThat(expectedException).hasMessage("itemWriter must not be null"); @@ -62,12 +56,9 @@ public class RemoteChunkingWorkerBuilderTest { @Test public void inputChannelMustNotBeNull() { - // given - final RemoteChunkingWorkerBuilder builder = new RemoteChunkingWorkerBuilder() - .inputChannel(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingWorkerBuilder().inputChannel(null).build()); // then assertThat(expectedException).hasMessage("inputChannel must not be null"); @@ -75,12 +66,9 @@ public class RemoteChunkingWorkerBuilderTest { @Test public void outputChannelMustNotBeNull() { - // given - final RemoteChunkingWorkerBuilder builder = new RemoteChunkingWorkerBuilder() - .outputChannel(null); - // when - final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build); + final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + () -> new RemoteChunkingWorkerBuilder().outputChannel(null).build()); // then assertThat(expectedException).hasMessage("outputChannel must not be null"); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningMasterStepBuilderTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningMasterStepBuilderTests.java index 8e4587d75..0e95cda87 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningMasterStepBuilderTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningMasterStepBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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. diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java index ed2675210..7fc002513 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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. diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/context/BatchTestContextCustomizerTest.java b/spring-batch-test/src/test/java/org/springframework/batch/test/context/BatchTestContextCustomizerTest.java index c47d65a3b..d2f3163c4 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/context/BatchTestContextCustomizerTest.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/context/BatchTestContextCustomizerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2021 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,8 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.test.context.MergedContextConfiguration; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Mahmoud Ben Hassine @@ -57,6 +58,6 @@ public class BatchTestContextCustomizerTest { () -> this.contextCustomizer.customizeContext(context, mergedConfig)); // then - assertEquals("The bean factory must be an instance of BeanDefinitionRegistry", expectedException.getMessage()); + assertThat(expectedException.getMessage(), containsString("The bean factory must be an instance of BeanDefinitionRegistry")); } }