Skip to content

Commit 531be0d

Browse files
committed
Upgraded to Spring Boot 2.6.7 - Fixed test sources
1 parent dd07381 commit 531be0d

File tree

21 files changed

+117
-173
lines changed

21 files changed

+117
-173
lines changed

Diff for: batch-web-spring-boot-autoconfigure/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<dependency>
7575
<groupId>commons-io</groupId>
7676
<artifactId>commons-io</artifactId>
77-
<version>2.6</version>
77+
<version>2.11.0</version>
7878
<scope>test</scope>
7979
</dependency>
8080
<dependency>
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
package de.codecentric.batch.listener;
22

3-
import static org.hamcrest.CoreMatchers.containsString;
4-
import static org.junit.Assert.assertThat;
5-
6-
import java.util.Date;
7-
8-
import org.junit.Rule;
9-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.ExtendWith;
105
import org.springframework.batch.core.ExitStatus;
116
import org.springframework.batch.core.JobExecution;
127
import org.springframework.batch.core.JobInstance;
138
import org.springframework.batch.core.JobParametersBuilder;
149
import org.springframework.batch.core.StepExecution;
15-
import org.springframework.boot.test.rule.OutputCapture;
10+
import org.springframework.boot.test.system.CapturedOutput;
11+
import org.springframework.boot.test.system.OutputCaptureExtension;
1612

13+
import java.util.Date;
14+
15+
import static org.hamcrest.CoreMatchers.containsString;
16+
import static org.hamcrest.MatcherAssert.assertThat;
17+
18+
@ExtendWith(OutputCaptureExtension.class)
1719
public class ProtocolListenerTest {
1820

19-
@Rule
20-
public OutputCapture outputCapture = new OutputCapture();
21+
2122

2223
@Test
23-
public void createProtocol() throws Exception {
24+
public void createProtocol(CapturedOutput output) throws Exception {
2425
// Given
2526
JobExecution jobExecution = new JobExecution(1L,
2627
new JobParametersBuilder().addString("test", "value").toJobParameters());
@@ -36,8 +37,7 @@ public void createProtocol() throws Exception {
3637
// When
3738
protocolListener.afterJob(jobExecution);
3839
// Then
39-
String output = this.outputCapture.toString();
40-
assertThat(output, containsString("Protocol for test-job"));
41-
assertThat(output, containsString("COMPLETED_WITH_ERRORS"));
40+
assertThat(output.getOut(), containsString("Protocol for test-job"));
41+
assertThat(output.getOut(), containsString("COMPLETED_WITH_ERRORS"));
4242
}
4343
}

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/metrics/BatchMetricsImplTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.codecentric.batch.metrics;
22

3-
import org.junit.Before;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
55
import org.springframework.batch.core.JobExecution;
66
import org.springframework.batch.core.JobInstance;
77
import org.springframework.batch.core.StepExecution;
@@ -14,7 +14,7 @@ public class BatchMetricsImplTest {
1414

1515
private BatchMetricsImpl batchMetrics;
1616

17-
@Before
17+
@BeforeEach
1818
public void beforeTest() {
1919
batchMetrics = new BatchMetricsImpl();
2020
StepSynchronizationManager

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/scheduling/concurrent/MdcThreadPoolTaskExecutorTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package de.codecentric.batch.scheduling.concurrent;
22

3-
import static org.hamcrest.CoreMatchers.equalTo;
4-
import static org.hamcrest.CoreMatchers.is;
5-
import static org.junit.Assert.assertThat;
3+
import org.junit.jupiter.api.Test;
4+
import org.slf4j.MDC;
5+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
66

77
import java.util.concurrent.Callable;
88
import java.util.concurrent.FutureTask;
99

10-
import org.junit.Test;
11-
import org.slf4j.MDC;
12-
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
10+
import static org.hamcrest.CoreMatchers.equalTo;
11+
import static org.hamcrest.CoreMatchers.is;
12+
import static org.hamcrest.MatcherAssert.assertThat;
1313

1414
public class MdcThreadPoolTaskExecutorTest {
1515

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/FlatFileJobTest.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,22 @@
1616

1717
package de.codecentric.batch.test;
1818

19-
import static org.junit.Assert.assertEquals;
20-
21-
import java.io.File;
22-
import java.nio.charset.StandardCharsets;
23-
19+
import de.codecentric.batch.AutoconfigureBatchWebStarter;
20+
import de.codecentric.batch.TestConfiguration;
2421
import org.apache.commons.io.FileUtils;
25-
import org.junit.Test;
26-
import org.junit.runner.RunWith;
22+
import org.junit.jupiter.api.Test;
2723
import org.springframework.batch.core.BatchStatus;
2824
import org.springframework.batch.core.JobParameters;
2925
import org.springframework.batch.core.launch.JobOperator;
3026
import org.springframework.batch.core.repository.JobRepository;
3127
import org.springframework.beans.factory.annotation.Autowired;
3228
import org.springframework.boot.test.context.SpringBootTest;
33-
import org.springframework.test.context.junit4.SpringRunner;
3429

35-
import de.codecentric.batch.AutoconfigureBatchWebStarter;
36-
import de.codecentric.batch.TestConfiguration;
30+
import java.io.File;
31+
import java.nio.charset.StandardCharsets;
32+
33+
import static org.junit.jupiter.api.Assertions.assertEquals;
3734

38-
@RunWith(SpringRunner.class)
3935
@AutoconfigureBatchWebStarter
4036
@SpringBootTest(classes = TestConfiguration.class)
4137
public class FlatFileJobTest {

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/JavaConfigIntegrationTest.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import java.util.List;
22-
23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import org.junit.jupiter.api.Test;
2520
import org.springframework.batch.core.BatchStatus;
2621
import org.springframework.batch.core.JobExecution;
2722
import org.springframework.batch.core.explore.JobExplorer;
@@ -30,16 +25,17 @@
3025
import org.springframework.boot.test.context.SpringBootTest;
3126
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3227
import org.springframework.boot.test.web.client.TestRestTemplate;
33-
import org.springframework.test.context.junit4.SpringRunner;
3428

35-
import de.codecentric.batch.TestApplication;
29+
import java.util.List;
30+
31+
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3633

3734
/**
3835
* This test class starts a batch job configured in JavaConfig and tests several endpoints.
3936
*
4037
* @author Tobias Flohre
4138
*/
42-
@RunWith(SpringRunner.class)
4339
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
4440
public class JavaConfigIntegrationTest {
4541

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/JobParametersIncrementerIntegrationTest.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import org.junit.jupiter.api.Test;
2320
import org.springframework.batch.core.BatchStatus;
2421
import org.springframework.batch.core.JobExecution;
2522
import org.springframework.batch.core.explore.JobExplorer;
@@ -28,18 +25,17 @@
2825
import org.springframework.boot.test.context.SpringBootTest;
2926
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3027
import org.springframework.boot.test.web.client.TestRestTemplate;
31-
import org.springframework.test.context.junit4.SpringRunner;
3228
import org.springframework.util.LinkedMultiValueMap;
3329
import org.springframework.util.MultiValueMap;
3430

35-
import de.codecentric.batch.TestApplication;
31+
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3633

3734
/**
3835
* This test class starts a batch job configured in JavaConfig that uses a JobParametersIncrementer.
3936
*
4037
* @author Tobias Flohre
4138
*/
42-
@RunWith(SpringRunner.class)
4339
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
4440
public class JobParametersIncrementerIntegrationTest {
4541

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/Jsr352IntegrationTest.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import java.util.List;
22-
23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import org.junit.jupiter.api.Test;
2520
import org.springframework.batch.core.BatchStatus;
2621
import org.springframework.batch.core.JobExecution;
2722
import org.springframework.batch.core.explore.JobExplorer;
@@ -30,16 +25,17 @@
3025
import org.springframework.boot.test.context.SpringBootTest;
3126
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3227
import org.springframework.boot.test.web.client.TestRestTemplate;
33-
import org.springframework.test.context.junit4.SpringRunner;
3428

35-
import de.codecentric.batch.TestApplication;
29+
import java.util.List;
30+
31+
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3633

3734
/**
3835
* This test class starts a JSR-352 type batch job and tests several endpoints.
3936
*
4037
* @author Tobias Flohre
4138
*/
42-
@RunWith(SpringRunner.class)
4339
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
4440
public class Jsr352IntegrationTest {
4541

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/ListenerProviderIntegrationTest.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,26 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import de.codecentric.batch.listener.TestListener;
20+
import org.junit.jupiter.api.Test;
2321
import org.springframework.beans.factory.annotation.Autowired;
2422
import org.springframework.beans.factory.annotation.Value;
2523
import org.springframework.boot.test.context.SpringBootTest;
2624
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2725
import org.springframework.boot.test.web.client.TestRestTemplate;
28-
import org.springframework.test.context.junit4.SpringRunner;
2926
import org.springframework.util.LinkedMultiValueMap;
3027
import org.springframework.util.MultiValueMap;
3128

32-
import de.codecentric.batch.TestApplication;
33-
import de.codecentric.batch.listener.TestListener;
29+
import static org.hamcrest.CoreMatchers.is;
30+
import static org.hamcrest.MatcherAssert.assertThat;
3431

3532
/**
3633
* This test class starts a batch job configured in JavaConfig and tests the ListenerProvider concept.
3734
*
3835
* @author Tobias Flohre
3936
*/
40-
@RunWith(SpringRunner.class)
4137
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
42-
4338
public class ListenerProviderIntegrationTest {
4439

4540
private TestRestTemplate restTemplate = new TestRestTemplate();

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/PartitionedFlatFileJobTest.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@
1616

1717
package de.codecentric.batch.test;
1818

19-
import static org.junit.Assert.assertEquals;
20-
21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
19+
import de.codecentric.batch.AutoconfigureBatchWebStarter;
20+
import de.codecentric.batch.TestConfiguration;
21+
import org.junit.jupiter.api.Test;
2322
import org.springframework.batch.core.BatchStatus;
2423
import org.springframework.batch.core.JobParameters;
2524
import org.springframework.batch.core.launch.JobOperator;
2625
import org.springframework.batch.core.repository.JobRepository;
2726
import org.springframework.beans.factory.annotation.Autowired;
2827
import org.springframework.boot.test.context.SpringBootTest;
29-
import org.springframework.test.context.junit4.SpringRunner;
3028

31-
import de.codecentric.batch.AutoconfigureBatchWebStarter;
32-
import de.codecentric.batch.TestConfiguration;
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
3330

34-
@RunWith(SpringRunner.class)
3531
@AutoconfigureBatchWebStarter
3632
@SpringBootTest(classes = TestConfiguration.class, properties = { "batch.metrics.enabled=true" })
3733
public class PartitionedFlatFileJobTest {

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/StopJobIntegrationTest.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import java.util.List;
22-
23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import org.junit.jupiter.api.Test;
2520
import org.springframework.batch.core.BatchStatus;
2621
import org.springframework.batch.core.JobExecution;
2722
import org.springframework.batch.core.explore.JobExplorer;
@@ -30,17 +25,18 @@
3025
import org.springframework.boot.test.context.SpringBootTest;
3126
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3227
import org.springframework.boot.test.web.client.TestRestTemplate;
33-
import org.springframework.test.context.junit4.SpringRunner;
3428

35-
import de.codecentric.batch.TestApplication;
29+
import java.util.List;
30+
31+
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3633

3734
/**
3835
* This test class starts a batch job that needs some time to finish. It tests the endpoints monitoring running jobs and
3936
* then stops the job.
4037
*
4138
* @author Tobias Flohre
4239
*/
43-
@RunWith(SpringRunner.class)
4440
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
4541
public class StopJobIntegrationTest {
4642

Diff for: batch-web-spring-boot-autoconfigure/src/test/java/de/codecentric/batch/test/XmlIntegrationTest.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
*/
1616
package de.codecentric.batch.test;
1717

18-
import static org.hamcrest.CoreMatchers.is;
19-
import static org.junit.Assert.assertThat;
20-
21-
import java.util.List;
22-
23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
18+
import de.codecentric.batch.TestApplication;
19+
import org.junit.jupiter.api.Test;
2520
import org.springframework.batch.core.BatchStatus;
2621
import org.springframework.batch.core.JobExecution;
2722
import org.springframework.batch.core.explore.JobExplorer;
@@ -30,16 +25,17 @@
3025
import org.springframework.boot.test.context.SpringBootTest;
3126
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3227
import org.springframework.boot.test.web.client.TestRestTemplate;
33-
import org.springframework.test.context.junit4.SpringRunner;
3428

35-
import de.codecentric.batch.TestApplication;
29+
import java.util.List;
30+
31+
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3633

3734
/**
3835
* This test class starts a batch job configured in XML and tests several endpoints.
3936
*
4037
* @author Tobias Flohre
4138
*/
42-
@RunWith(SpringRunner.class)
4339
@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
4440
"batch.metrics.enabled=true", "batch.metrics.profiling.readprocesswrite.enabled=true" })
4541
public class XmlIntegrationTest {

0 commit comments

Comments
 (0)