From f4bb0c7aac0de37562afa4de94d7be7554a056e8 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Mon, 2 Oct 2023 11:57:36 +0200 Subject: [PATCH] Restructure test resources in samples --- .../META-INF/spring/config-beans.xml | 12 ------- .../jobs/amqp/amqp-example-job-beans.xml | 18 ----------- .../spring/jobs/amqp/amqp-example-job.xml | 22 ------------- .../sample/config => }/common-context.xml | 0 .../src/main/resources/hibernate-context.xml | 2 +- .../resources/job-runner-context.xml | 0 .../JdbcCustomerDebitDaoTests-context.xml | 0 .../main/resources/jobs/amqp-example-job.xml | 22 ------------- .../batch/sample/file/json/data}/trades.json | 0 .../CustomerCredit.hbm.xml | 0 .../sample/rabbitmq}/default.amqp.properties | 0 .../sample/rabbitmq/job/amqp-example-job.xml | 32 +++++++++++++++++++ .../sample/rabbitmq/job}/rabbitmq-beans.xml | 0 .../resources/simple-job-launcher-context.xml | 3 +- .../skipSample-job-launcher-context.xml | 2 +- .../batch/sample/AMQPJobFunctionalTests.java | 4 +-- .../batch/sample/JobStepFunctionalTests.java | 8 ++++- .../common/ColumnRangePartitionerTests.java | 2 +- .../sample/common/StagingItemReaderTests.java | 2 +- .../sample/common/StagingItemWriterTests.java | 2 +- .../internal/JdbcCustomerDebitDaoTests.java | 2 +- .../json}/JsonSupportIntegrationTests.java | 6 ++-- .../sample/JobStepFunctionalTests-context.xml | 13 -------- .../ColumnRangePartitionerTests-context.xml | 7 ---- .../common/StagingItemReaderTests-context.xml | 7 ---- .../common/StagingItemWriterTests-context.xml | 7 ---- 26 files changed, 51 insertions(+), 122 deletions(-) delete mode 100644 spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml delete mode 100644 spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml delete mode 100644 spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml rename spring-batch-samples/src/main/resources/{org/springframework/batch/sample/config => }/common-context.xml (100%) rename spring-batch-samples/src/{test => main}/resources/job-runner-context.xml (100%) rename spring-batch-samples/src/{test/resources/org/springframework/batch/sample/domain/trade/internal => main/resources/jobs}/JdbcCustomerDebitDaoTests-context.xml (100%) delete mode 100644 spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml rename spring-batch-samples/src/{test/resources/org/springframework/batch/item/json => main/resources/org/springframework/batch/sample/file/json/data}/trades.json (100%) rename spring-batch-samples/src/main/resources/org/springframework/batch/sample/{domain/trade => hibernate}/CustomerCredit.hbm.xml (100%) rename spring-batch-samples/src/main/resources/{ => org/springframework/batch/sample/rabbitmq}/default.amqp.properties (100%) create mode 100644 spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml rename spring-batch-samples/src/main/resources/{META-INF/spring/jobs/messaging => org/springframework/batch/sample/rabbitmq/job}/rabbitmq-beans.xml (100%) rename spring-batch-samples/src/test/java/org/springframework/batch/sample/{ => file/json}/JsonSupportIntegrationTests.java (95%) delete mode 100644 spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml delete mode 100644 spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml delete mode 100644 spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml delete mode 100644 spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml deleted file mode 100644 index e83c28ddb..000000000 --- a/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml deleted file mode 100644 index 2979a57f0..000000000 --- a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml deleted file mode 100644 index e251ef6b8..000000000 --- a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml b/spring-batch-samples/src/main/resources/common-context.xml similarity index 100% rename from spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml rename to spring-batch-samples/src/main/resources/common-context.xml diff --git a/spring-batch-samples/src/main/resources/hibernate-context.xml b/spring-batch-samples/src/main/resources/hibernate-context.xml index f1b354154..55faaa717 100644 --- a/spring-batch-samples/src/main/resources/hibernate-context.xml +++ b/spring-batch-samples/src/main/resources/hibernate-context.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-batch-samples/src/test/resources/job-runner-context.xml b/spring-batch-samples/src/main/resources/job-runner-context.xml similarity index 100% rename from spring-batch-samples/src/test/resources/job-runner-context.xml rename to spring-batch-samples/src/main/resources/job-runner-context.xml diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml b/spring-batch-samples/src/main/resources/jobs/JdbcCustomerDebitDaoTests-context.xml similarity index 100% rename from spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml rename to spring-batch-samples/src/main/resources/jobs/JdbcCustomerDebitDaoTests-context.xml diff --git a/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml b/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml deleted file mode 100644 index e251ef6b8..000000000 --- a/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/item/json/trades.json b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/json/data/trades.json similarity index 100% rename from spring-batch-samples/src/test/resources/org/springframework/batch/item/json/trades.json rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/json/data/trades.json diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/domain/trade/CustomerCredit.hbm.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/hibernate/CustomerCredit.hbm.xml similarity index 100% rename from spring-batch-samples/src/main/resources/org/springframework/batch/sample/domain/trade/CustomerCredit.hbm.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/hibernate/CustomerCredit.hbm.xml diff --git a/spring-batch-samples/src/main/resources/default.amqp.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/default.amqp.properties similarity index 100% rename from spring-batch-samples/src/main/resources/default.amqp.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/default.amqp.properties diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml new file mode 100644 index 000000000..40e3fc316 --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml similarity index 100% rename from spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml diff --git a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index 7995dae4a..b29452800 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -4,8 +4,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml index e82c0ee36..850c1b746 100644 --- a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java index bd7b528cc..1bc9eeca5 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java @@ -61,8 +61,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext *

*/ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) @Testcontainers(disabledWithoutDocker = true) class AMQPJobFunctionalTests { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java index 7d2f605d5..3e0148b27 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java @@ -20,6 +20,7 @@ import javax.sql.DataSource; import org.junit.jupiter.api.Test; +import org.springframework.batch.core.Job; import org.springframework.batch.core.converter.DefaultJobParametersConverter; import org.springframework.batch.support.PropertiesConverter; import org.springframework.batch.test.JobLauncherTestUtils; @@ -38,9 +39,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author Glenn Renfro */ -@SpringJUnitConfig +@SpringJUnitConfig(locations = { "classpath:/simple-job-launcher-context.xml", "classpath:/jobs/jobStepSample.xml", + "/job-runner-context.xml" }) class JobStepFunctionalTests { + @Autowired + private Job jobStepJob; + @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @@ -53,6 +58,7 @@ class JobStepFunctionalTests { @Test void testJobLaunch() throws Exception { + jobLauncherTestUtils.setJob(jobStepJob); JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE"); jobLauncherTestUtils diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ColumnRangePartitionerTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ColumnRangePartitionerTests.java index 035239126..225c4ad7b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ColumnRangePartitionerTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ColumnRangePartitionerTests.java @@ -27,7 +27,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig +@SpringJUnitConfig(locations = "classpath:data-source-context.xml") class ColumnRangePartitionerTests { private DataSource dataSource; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java index 3b2ada91a..903ff6378 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java @@ -39,7 +39,7 @@ import org.springframework.transaction.support.TransactionTemplate; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -@SpringJUnitConfig +@SpringJUnitConfig(locations = "classpath:staging-test-context.xml") class StagingItemReaderTests { private JdbcTemplate jdbcTemplate; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java index 80531654d..c6041db12 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java @@ -33,7 +33,7 @@ import org.springframework.transaction.annotation.Transactional; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig +@SpringJUnitConfig(locations = "classpath:staging-test-context.xml") class StagingItemWriterTests { private JdbcTemplate jdbcTemplate; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java index 5037a45a2..a1bf96dc1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java @@ -30,7 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig +@SpringJUnitConfig(locations = "classpath:jobs/JdbcCustomerDebitDaoTests-context.xml") class JdbcCustomerDebitDaoTests { private JdbcOperations jdbcTemplate; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JsonSupportIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/json/JsonSupportIntegrationTests.java similarity index 95% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/JsonSupportIntegrationTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/file/json/JsonSupportIntegrationTests.java index 7eb693988..89389ae2d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JsonSupportIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/json/JsonSupportIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.file.json; import java.io.File; import java.io.FileInputStream; @@ -60,13 +60,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ class JsonSupportIntegrationTests { - private static final String INPUT_FILE_DIRECTORY = "src/test/resources/org/springframework/batch/item/json/"; + private static final String INPUT_FILE_DIRECTORY = "src/main/resources/org/springframework/batch/sample/file/json/data/"; private static final String OUTPUT_FILE_DIRECTORY = "target/"; @BeforeEach void setUp() throws Exception { - Files.deleteIfExists(Paths.get("build", "trades.json")); + Files.deleteIfExists(Paths.get("target", "trades.json")); } @Configuration diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml deleted file mode 100644 index ad024fcd5..000000000 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml deleted file mode 100644 index 6df7cd7d0..000000000 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml deleted file mode 100644 index 9c09e635e..000000000 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml deleted file mode 100644 index 36af20657..000000000 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file