Skip to content

Commit f4bb0c7

Browse files
committed
Restructure test resources in samples
1 parent e42167b commit f4bb0c7

26 files changed

+51
-122
lines changed

spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

spring-batch-samples/src/main/resources/hibernate-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
77
<property name="dataSource" ref="dataSource" />
8-
<property name="mappingLocations" value="classpath*:/org/springframework/batch/sample/domain/**/*.hbm.xml" />
8+
<property name="mappingLocations" value="classpath*:/org/springframework/batch/sample/hibernate/*.hbm.xml" />
99
</bean>
1010

1111
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" lazy-init="true">

spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<beans:beans
4+
xmlns:beans="http://www.springframework.org/schema/beans"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns:batch="http://www.springframework.org/schema/batch"
7+
xmlns:context="http://www.springframework.org/schema/context"
8+
xsi:schemaLocation="http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd
9+
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
10+
11+
<context:property-placeholder location="classpath:org/springframework/batch/sample/rabbitmq/default.amqp.properties" />
12+
<beans:import resource="classpath:org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml"/>
13+
14+
<batch:job id="amqp-example-job">
15+
<batch:step id="processQueue">
16+
<batch:tasklet>
17+
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
18+
</batch:tasklet>
19+
</batch:step>
20+
</batch:job>
21+
22+
<beans:bean id="amqpItemReader" class="org.springframework.batch.item.amqp.AmqpItemReader">
23+
<beans:constructor-arg ref="inboundAmqpTemplate"/>
24+
</beans:bean>
25+
26+
<beans:bean id="amqpItemProcessor" class="org.springframework.batch.sample.rabbitmq.processor.MessageProcessor"/>
27+
28+
<beans:bean id="amqpItemWriter" class="org.springframework.batch.item.amqp.AmqpItemWriter">
29+
<beans:constructor-arg ref="outboundAmqpTemplate"/>
30+
</beans:bean>
31+
32+
</beans:beans>

spring-batch-samples/src/main/resources/simple-job-launcher-context.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
xsi:schemaLocation="
55
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
66
<import resource="data-source-context.xml" />
7-
<import
8-
resource="classpath:/org/springframework/batch/sample/config/common-context.xml" />
7+
<import resource="common-context.xml" />
98
<bean id="jobLauncher"
109
class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
1110
<property name="jobRepository" ref="jobRepository" />

spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
66

77
<import resource="data-source-context.xml" />
8-
<import resource="classpath:/org/springframework/batch/sample/config/common-context.xml" />
8+
<import resource="common-context.xml" />
99

1010
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
1111
<property name="jobRepository" ref="jobRepository" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
* </p>
6262
*/
6363

64-
@SpringJUnitConfig(
65-
locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
64+
@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml",
65+
"/simple-job-launcher-context.xml", "/job-runner-context.xml" })
6666
@Testcontainers(disabledWithoutDocker = true)
6767
class AMQPJobFunctionalTests {
6868

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.junit.jupiter.api.Test;
2222

23+
import org.springframework.batch.core.Job;
2324
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
2425
import org.springframework.batch.support.PropertiesConverter;
2526
import org.springframework.batch.test.JobLauncherTestUtils;
@@ -38,9 +39,13 @@
3839
* @author Glenn Renfro
3940
*/
4041

41-
@SpringJUnitConfig
42+
@SpringJUnitConfig(locations = { "classpath:/simple-job-launcher-context.xml", "classpath:/jobs/jobStepSample.xml",
43+
"/job-runner-context.xml" })
4244
class JobStepFunctionalTests {
4345

46+
@Autowired
47+
private Job jobStepJob;
48+
4449
@Autowired
4550
private JobLauncherTestUtils jobLauncherTestUtils;
4651

@@ -53,6 +58,7 @@ public void setDataSource(DataSource dataSource) {
5358

5459
@Test
5560
void testJobLaunch() throws Exception {
61+
jobLauncherTestUtils.setJob(jobStepJob);
5662
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
5763

5864
jobLauncherTestUtils

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import static org.junit.jupiter.api.Assertions.assertEquals;
2929

30-
@SpringJUnitConfig
30+
@SpringJUnitConfig(locations = "classpath:data-source-context.xml")
3131
class ColumnRangePartitionerTests {
3232

3333
private DataSource dataSource;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import static org.junit.jupiter.api.Assertions.assertEquals;
4040
import static org.junit.jupiter.api.Assertions.fail;
4141

42-
@SpringJUnitConfig
42+
@SpringJUnitConfig(locations = "classpath:staging-test-context.xml")
4343
class StagingItemReaderTests {
4444

4545
private JdbcTemplate jdbcTemplate;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import static org.junit.jupiter.api.Assertions.assertEquals;
3535

36-
@SpringJUnitConfig
36+
@SpringJUnitConfig(locations = "classpath:staging-test-context.xml")
3737
class StagingItemWriterTests {
3838

3939
private JdbcTemplate jdbcTemplate;

spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import static org.junit.jupiter.api.Assertions.assertEquals;
3232

33-
@SpringJUnitConfig
33+
@SpringJUnitConfig(locations = "classpath:jobs/JdbcCustomerDebitDaoTests-context.xml")
3434
class JdbcCustomerDebitDaoTests {
3535

3636
private JdbcOperations jdbcTemplate;

spring-batch-samples/src/test/java/org/springframework/batch/sample/JsonSupportIntegrationTests.java renamed to spring-batch-samples/src/test/java/org/springframework/batch/sample/file/json/JsonSupportIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.batch.sample;
17+
package org.springframework.batch.sample.file.json;
1818

1919
import java.io.File;
2020
import java.io.FileInputStream;
@@ -60,13 +60,13 @@
6060
*/
6161
class JsonSupportIntegrationTests {
6262

63-
private static final String INPUT_FILE_DIRECTORY = "src/test/resources/org/springframework/batch/item/json/";
63+
private static final String INPUT_FILE_DIRECTORY = "src/main/resources/org/springframework/batch/sample/file/json/data/";
6464

6565
private static final String OUTPUT_FILE_DIRECTORY = "target/";
6666

6767
@BeforeEach
6868
void setUp() throws Exception {
69-
Files.deleteIfExists(Paths.get("build", "trades.json"));
69+
Files.deleteIfExists(Paths.get("target", "trades.json"));
7070
}
7171

7272
@Configuration

spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)