Skip to content

Commit 7bbbd4f

Browse files
committed
Refine contribution #3962
- Fix failing tests - Update year in license headers Related to #3838
1 parent 24422b5 commit 7bbbd4f

File tree

14 files changed

+44
-71
lines changed

14 files changed

+44
-71
lines changed

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JsrSplitParsingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2020 the original author or authors.
2+
* Copyright 2013-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2019 the original author or authors.
2+
* Copyright 2008-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2020 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamWriterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,64 +85,49 @@ public class RemoteChunkingManagerStepBuilderTest {
8585

8686
@Test
8787
public void inputChannelMustNotBeNull() {
88-
// given
89-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
90-
.inputChannel(null);
91-
9288
// when
93-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
89+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
90+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step").inputChannel(null).build());
9491

9592
// then
9693
assertThat(expectedException).hasMessage("inputChannel must not be null");
9794
}
9895

9996
@Test
10097
public void outputChannelMustNotBeNull() {
101-
// given
102-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
103-
.outputChannel(null);
104-
10598
// when
106-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
99+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
100+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step").outputChannel(null).build());
107101

108102
// then
109103
assertThat(expectedException).hasMessage("outputChannel must not be null");
110104
}
111105

112106
@Test
113107
public void messagingTemplateMustNotBeNull() {
114-
// given
115-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
116-
.messagingTemplate(null);
117-
118108
// when
119-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
109+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
110+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step").messagingTemplate(null).build());
120111

121112
// then
122113
assertThat(expectedException).hasMessage("messagingTemplate must not be null");
123114
}
124115

125116
@Test
126117
public void maxWaitTimeoutsMustBeGreaterThanZero() {
127-
// given
128-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
129-
.maxWaitTimeouts(-1);
130-
131118
// when
132-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
119+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
120+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step").maxWaitTimeouts(-1).build());
133121

134122
// then
135123
assertThat(expectedException).hasMessage("maxWaitTimeouts must be greater than zero");
136124
}
137125

138126
@Test
139127
public void throttleLimitMustNotBeGreaterThanZero() {
140-
// given
141-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
142-
.throttleLimit(-1L);
143-
144128
// when
145-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
129+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
130+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step").throttleLimit(-1L).build());
146131

147132
// then
148133
assertThat(expectedException).hasMessage("throttleLimit must be greater than zero");
@@ -177,17 +162,16 @@ public void eitherOutputChannelOrMessagingTemplateMustBeProvided() {
177162

178163
@Test
179164
public void testUnsupportedOperationExceptionWhenSpecifyingAnItemWriter() {
180-
// given
181-
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
182-
.reader(this.itemReader)
183-
.writer(items -> { })
184-
.repository(this.jobRepository)
185-
.transactionManager(this.transactionManager)
186-
.inputChannel(this.inputChannel)
187-
.outputChannel(this.outputChannel);
188-
189165
// when
190-
final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class, builder::build);
166+
final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class,
167+
() -> new RemoteChunkingManagerStepBuilder<String, String>("step")
168+
.reader(this.itemReader)
169+
.writer(items -> { })
170+
.repository(this.jobRepository)
171+
.transactionManager(this.transactionManager)
172+
.inputChannel(this.inputChannel)
173+
.outputChannel(this.outputChannel)
174+
.build());
191175

192176
// then
193177
assertThat(expectedException).hasMessage("When configuring a manager " +

spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilderTest.java

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,51 +36,39 @@ public class RemoteChunkingWorkerBuilderTest {
3636

3737
@Test
3838
public void itemProcessorMustNotBeNull() {
39-
// given
40-
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
41-
.itemProcessor(null);
42-
4339
// when
44-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
40+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
41+
() -> new RemoteChunkingWorkerBuilder<String, String>().itemProcessor(null).build());
4542

4643
// then
4744
assertThat(expectedException).hasMessage("itemProcessor must not be null");
4845
}
4946

5047
@Test
5148
public void itemWriterMustNotBeNull() {
52-
// given
53-
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
54-
.itemWriter(null);
55-
5649
// when
57-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
50+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
51+
() -> new RemoteChunkingWorkerBuilder<String, String>().itemWriter(null).build());
5852

5953
// then
6054
assertThat(expectedException).hasMessage("itemWriter must not be null");
6155
}
6256

6357
@Test
6458
public void inputChannelMustNotBeNull() {
65-
// given
66-
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
67-
.inputChannel(null);
68-
6959
// when
70-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
60+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
61+
() -> new RemoteChunkingWorkerBuilder<String, String>().inputChannel(null).build());
7162

7263
// then
7364
assertThat(expectedException).hasMessage("inputChannel must not be null");
7465
}
7566

7667
@Test
7768
public void outputChannelMustNotBeNull() {
78-
// given
79-
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
80-
.outputChannel(null);
81-
8269
// when
83-
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
70+
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
71+
() -> new RemoteChunkingWorkerBuilder<String, String>().outputChannel(null).build());
8472

8573
// then
8674
assertThat(expectedException).hasMessage("outputChannel must not be null");

spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningMasterStepBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-batch-test/src/test/java/org/springframework/batch/test/context/BatchTestContextCustomizerTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,8 @@
2323
import org.springframework.context.support.GenericApplicationContext;
2424
import org.springframework.test.context.MergedContextConfiguration;
2525

26-
import static org.junit.jupiter.api.Assertions.assertEquals;
26+
import static org.hamcrest.CoreMatchers.containsString;
27+
import static org.hamcrest.MatcherAssert.assertThat;
2728

2829
/**
2930
* @author Mahmoud Ben Hassine
@@ -57,6 +58,6 @@ public void testCustomizeContext_whenBeanFactoryIsNotAnInstanceOfBeanDefinitionR
5758
() -> this.contextCustomizer.customizeContext(context, mergedConfig));
5859

5960
// then
60-
assertEquals("The bean factory must be an instance of BeanDefinitionRegistry", expectedException.getMessage());
61+
assertThat(expectedException.getMessage(), containsString("The bean factory must be an instance of BeanDefinitionRegistry"));
6162
}
6263
}

0 commit comments

Comments
 (0)