Skip to content

Commit 7e535af

Browse files
committed
Refine contribution #4112
Revert the removal of `@SpringJUnitConfig` usage in the test suite of samples. Related to #4111
1 parent 8ca9802 commit 7e535af

File tree

52 files changed

+294
-378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+294
-378
lines changed

spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515
*/
1616
package org.springframework.batch.sample;
1717

18-
import static org.junit.jupiter.api.Assertions.assertTrue;
19-
2018
import org.junit.jupiter.api.Test;
2119

22-
import org.junit.jupiter.api.extension.ExtendWith;
2320
import org.springframework.batch.core.Job;
2421
import org.springframework.batch.core.explore.JobExplorer;
2522
import org.springframework.batch.test.JobLauncherTestUtils;
2623
import org.springframework.beans.factory.annotation.Autowired;
27-
import org.springframework.test.context.ContextConfiguration;
28-
import org.springframework.test.context.junit.jupiter.SpringExtension;
24+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
25+
26+
import static org.junit.jupiter.api.Assertions.assertTrue;
2927

3028
/**
3129
* <p>
@@ -41,8 +39,7 @@
4139
* </p>
4240
*/
4341

44-
@ExtendWith(SpringExtension.class)
45-
@ContextConfiguration(
42+
@SpringJUnitConfig(
4643
locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
4744
class AMQPJobFunctionalTests {
4845

spring-batch-samples/src/test/java/org/springframework/batch/sample/BeanWrapperMapperSampleJobFunctionalTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
package org.springframework.batch.sample;
1818

1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
20+
2121
import org.springframework.batch.core.Job;
2222
import org.springframework.batch.test.JobLauncherTestUtils;
2323
import org.springframework.beans.factory.annotation.Autowired;
24-
import org.springframework.test.context.ContextConfiguration;
25-
import org.springframework.test.context.junit.jupiter.SpringExtension;
24+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2625

27-
@ExtendWith(SpringExtension.class)
28-
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
26+
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
2927
"/job-runner-context.xml" })
3028
class BeanWrapperMapperSampleJobFunctionalTests {
3129

spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,31 @@
1515
*/
1616
package org.springframework.batch.sample;
1717

18+
import java.io.FileInputStream;
19+
import java.io.IOException;
20+
import java.math.BigDecimal;
21+
import java.sql.ResultSet;
22+
import java.sql.SQLException;
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
26+
import javax.sql.DataSource;
27+
1828
import org.apache.commons.io.IOUtils;
1929
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
30+
2131
import org.springframework.batch.core.Job;
2232
import org.springframework.batch.sample.domain.trade.Trade;
2333
import org.springframework.batch.test.JobLauncherTestUtils;
2434
import org.springframework.beans.factory.annotation.Autowired;
2535
import org.springframework.jdbc.core.JdbcTemplate;
2636
import org.springframework.jdbc.core.RowCallbackHandler;
27-
import org.springframework.test.context.ContextConfiguration;
28-
import org.springframework.test.context.junit.jupiter.SpringExtension;
37+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2938
import org.springframework.test.jdbc.JdbcTestUtils;
3039

31-
import javax.sql.DataSource;
32-
import java.io.FileInputStream;
33-
import java.io.IOException;
34-
import java.math.BigDecimal;
35-
import java.sql.ResultSet;
36-
import java.sql.SQLException;
37-
import java.util.ArrayList;
38-
import java.util.List;
39-
4040
import static org.junit.jupiter.api.Assertions.assertEquals;
4141

42-
@ExtendWith(SpringExtension.class)
43-
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
42+
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
4443
"/job-runner-context.xml" })
4544
class CompositeItemWriterSampleFunctionalTests {
4645

spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,31 @@
1616

1717
package org.springframework.batch.sample;
1818

19+
import java.sql.ResultSet;
20+
import java.sql.SQLException;
21+
import java.util.Arrays;
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
25+
26+
import javax.sql.DataSource;
27+
1928
import org.junit.jupiter.api.AfterEach;
2029
import org.junit.jupiter.api.BeforeEach;
2130
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.ExtendWith;
31+
2332
import org.springframework.batch.core.Job;
2433
import org.springframework.batch.core.JobExecution;
2534
import org.springframework.batch.test.JobLauncherTestUtils;
2635
import org.springframework.beans.factory.annotation.Autowired;
2736
import org.springframework.jdbc.core.JdbcTemplate;
2837
import org.springframework.jdbc.core.RowCallbackHandler;
29-
import org.springframework.test.context.ContextConfiguration;
30-
import org.springframework.test.context.junit.jupiter.SpringExtension;
38+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3139
import org.springframework.test.jdbc.JdbcTestUtils;
3240

33-
import javax.sql.DataSource;
34-
import java.sql.ResultSet;
35-
import java.sql.SQLException;
36-
import java.util.Arrays;
37-
import java.util.HashMap;
38-
import java.util.List;
39-
import java.util.Map;
40-
4141
import static org.junit.jupiter.api.Assertions.assertEquals;
4242

43-
@ExtendWith(SpringExtension.class)
44-
@ContextConfiguration(
43+
@SpringJUnitConfig(
4544
locations = { "/simple-job-launcher-context.xml", "/jobs/customerFilterJob.xml", "/job-runner-context.xml" })
4645
class CustomerFilterJobFunctionalTests {
4746

spring-batch-samples/src/test/java/org/springframework/batch/sample/DatabaseShutdownFunctionalTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
import org.apache.commons.logging.Log;
2020
import org.apache.commons.logging.LogFactory;
2121
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.ExtendWith;
22+
2323
import org.springframework.batch.core.BatchStatus;
2424
import org.springframework.batch.core.Job;
2525
import org.springframework.batch.core.JobExecution;
2626
import org.springframework.batch.core.launch.JobOperator;
2727
import org.springframework.batch.test.JobLauncherTestUtils;
2828
import org.springframework.beans.factory.annotation.Autowired;
29-
import org.springframework.test.context.ContextConfiguration;
30-
import org.springframework.test.context.junit.jupiter.SpringExtension;
29+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3130

32-
import static org.junit.jupiter.api.Assertions.*;
31+
import static org.junit.jupiter.api.Assertions.assertEquals;
32+
import static org.junit.jupiter.api.Assertions.assertFalse;
33+
import static org.junit.jupiter.api.Assertions.assertNotNull;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
3335

3436
/**
3537
* Functional test for graceful shutdown. A batch container is started in a new thread,
@@ -41,8 +43,7 @@
4143
*
4244
*/
4345

44-
@ExtendWith(SpringExtension.class)
45-
@ContextConfiguration(
46+
@SpringJUnitConfig(
4647
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
4748
class DatabaseShutdownFunctionalTests {
4849

spring-batch-samples/src/test/java/org/springframework/batch/sample/DelegatingJobFunctionalTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
package org.springframework.batch.sample;
1717

1818
import org.junit.jupiter.api.Test;
19-
import org.junit.jupiter.api.extension.ExtendWith;
2019

2120
import org.springframework.batch.core.Job;
2221
import org.springframework.batch.sample.domain.person.PersonService;
2322
import org.springframework.batch.test.JobLauncherTestUtils;
2423
import org.springframework.beans.factory.annotation.Autowired;
25-
import org.springframework.test.context.ContextConfiguration;
26-
import org.springframework.test.context.junit.jupiter.SpringExtension;
24+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2725

2826
import static org.junit.jupiter.api.Assertions.assertEquals;
2927
import static org.junit.jupiter.api.Assertions.assertTrue;
3028

31-
@ExtendWith(SpringExtension.class)
32-
@ContextConfiguration(
29+
@SpringJUnitConfig(
3330
locations = { "/simple-job-launcher-context.xml", "/jobs/delegatingJob.xml", "/job-runner-context.xml" })
3431
class DelegatingJobFunctionalTests {
3532

spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,20 @@
1515
*/
1616
package org.springframework.batch.sample;
1717

18+
import javax.sql.DataSource;
19+
1820
import org.junit.jupiter.api.Test;
19-
import org.junit.jupiter.api.extension.ExtendWith;
21+
2022
import org.springframework.batch.core.Job;
2123
import org.springframework.batch.test.JobLauncherTestUtils;
2224
import org.springframework.beans.factory.annotation.Autowired;
2325
import org.springframework.jdbc.core.JdbcTemplate;
24-
import org.springframework.test.context.ContextConfiguration;
25-
import org.springframework.test.context.junit.jupiter.SpringExtension;
26+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2627
import org.springframework.test.jdbc.JdbcTestUtils;
2728

28-
import javax.sql.DataSource;
29-
3029
import static org.junit.jupiter.api.Assertions.assertTrue;
3130

32-
@ExtendWith(SpringExtension.class)
33-
@ContextConfiguration(
31+
@SpringJUnitConfig(
3432
locations = { "/simple-job-launcher-context.xml", "/jobs/footballJob.xml", "/job-runner-context.xml" })
3533
class FootballJobFunctionalTests {
3634

spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTests.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@
1919
import org.apache.commons.logging.Log;
2020
import org.apache.commons.logging.LogFactory;
2121
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.ExtendWith;
23-
import org.springframework.batch.core.*;
22+
23+
import org.springframework.batch.core.BatchStatus;
24+
import org.springframework.batch.core.Job;
25+
import org.springframework.batch.core.JobExecution;
26+
import org.springframework.batch.core.JobParameters;
27+
import org.springframework.batch.core.JobParametersBuilder;
2428
import org.springframework.batch.core.launch.JobOperator;
2529
import org.springframework.batch.test.JobLauncherTestUtils;
2630
import org.springframework.beans.factory.annotation.Autowired;
27-
import org.springframework.test.context.ContextConfiguration;
28-
import org.springframework.test.context.junit.jupiter.SpringExtension;
31+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2932

30-
import static org.junit.jupiter.api.Assertions.*;
33+
import static org.junit.jupiter.api.Assertions.assertEquals;
34+
import static org.junit.jupiter.api.Assertions.assertFalse;
35+
import static org.junit.jupiter.api.Assertions.assertTrue;
3136

3237
/**
3338
* Functional test for graceful shutdown. A batch container is started in a new thread,
@@ -36,10 +41,10 @@
3641
* @author Lucas Ward
3742
* @author Parikshit Dutta
3843
* @author Glenn Renfro
44+
* @author Mahmoud Ben Hassine
3945
*
4046
*/
41-
@ExtendWith(SpringExtension.class)
42-
@ContextConfiguration(
47+
@SpringJUnitConfig(
4348
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
4449
class GracefulShutdownFunctionalTests {
4550

spring-batch-samples/src/test/java/org/springframework/batch/sample/GroovyJobFunctionalTests.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,22 @@
1616

1717
package org.springframework.batch.sample;
1818

19+
import java.io.File;
20+
import java.io.IOException;
21+
1922
import org.apache.commons.io.FileUtils;
2023
import org.junit.jupiter.api.BeforeEach;
2124
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.ExtendWith;
25+
2326
import org.springframework.batch.core.Job;
2427
import org.springframework.batch.test.JobLauncherTestUtils;
2528
import org.springframework.beans.factory.annotation.Autowired;
26-
import org.springframework.test.context.ContextConfiguration;
27-
import org.springframework.test.context.junit.jupiter.SpringExtension;
28-
29-
import java.io.File;
30-
import java.io.IOException;
29+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3130

3231
import static org.junit.jupiter.api.Assertions.assertFalse;
3332
import static org.junit.jupiter.api.Assertions.assertTrue;
3433

35-
@ExtendWith(SpringExtension.class)
36-
@ContextConfiguration(
37-
locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
34+
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
3835
public class GroovyJobFunctionalTests {
3936

4037
@Autowired

spring-batch-samples/src/test/java/org/springframework/batch/sample/HeaderFooterSampleFunctionalTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@
1919
import java.io.FileReader;
2020

2121
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.ExtendWith;
2322

2423
import org.springframework.batch.core.Job;
2524
import org.springframework.batch.test.JobLauncherTestUtils;
2625
import org.springframework.beans.factory.annotation.Autowired;
2726
import org.springframework.beans.factory.annotation.Qualifier;
2827
import org.springframework.core.io.Resource;
29-
import org.springframework.test.context.ContextConfiguration;
30-
import org.springframework.test.context.junit.jupiter.SpringExtension;
28+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3129

3230
import static org.springframework.test.util.AssertionErrors.assertTrue;
3331

34-
@ExtendWith(SpringExtension.class)
35-
@ContextConfiguration(
32+
@SpringJUnitConfig(
3633
locations = { "/simple-job-launcher-context.xml", "/jobs/headerFooterSample.xml", "/job-runner-context.xml" })
3734
class HeaderFooterSampleFunctionalTests {
3835

0 commit comments

Comments
 (0)