Restructure test resources in samples

This commit is contained in:
Mahmoud Ben Hassine
2023-10-02 11:57:36 +02:00
parent e42167b52d
commit f4bb0c7aac
26 changed files with 51 additions and 122 deletions

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:default.amqp.properties" />
</beans:beans>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<beans:bean id="amqpItemReader" class="org.springframework.batch.item.amqp.AmqpItemReader">
<beans:constructor-arg ref="inboundAmqpTemplate"/>
</beans:bean>
<beans:bean id="amqpItemProcessor" class="org.springframework.batch.sample.rabbitmq.processor.MessageProcessor"/>
<beans:bean id="amqpItemWriter" class="org.springframework.batch.item.amqp.AmqpItemWriter">
<beans:constructor-arg ref="outboundAmqpTemplate"/>
</beans:bean>
</beans:beans>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<beans:import resource="classpath:/META-INF/spring/config-beans.xml"/>
<beans:import resource="classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml"/>
<beans:import resource="classpath:/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml"/>
<batch:job id="amqp-example-job">
<batch:step id="processQueue">
<batch:tasklet>
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
</batch:tasklet>
</batch:step>
</batch:job>
</beans:beans>

View File

@@ -5,7 +5,7 @@
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingLocations" value="classpath*:/org/springframework/batch/sample/domain/**/*.hbm.xml" />
<property name="mappingLocations" value="classpath*:/org/springframework/batch/sample/hibernate/*.hbm.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" lazy-init="true">

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<beans:import resource="classpath:/META-INF/spring/config-beans.xml"/>
<beans:import resource="classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml"/>
<beans:import resource="classpath:/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml"/>
<batch:job id="amqp-example-job">
<batch:step id="processQueue">
<batch:tasklet>
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
</batch:tasklet>
</batch:step>
</batch:job>
</beans:beans>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd
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">
<context:property-placeholder location="classpath:org/springframework/batch/sample/rabbitmq/default.amqp.properties" />
<beans:import resource="classpath:org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml"/>
<batch:job id="amqp-example-job">
<batch:step id="processQueue">
<batch:tasklet>
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
</batch:tasklet>
</batch:step>
</batch:job>
<beans:bean id="amqpItemReader" class="org.springframework.batch.item.amqp.AmqpItemReader">
<beans:constructor-arg ref="inboundAmqpTemplate"/>
</beans:bean>
<beans:bean id="amqpItemProcessor" class="org.springframework.batch.sample.rabbitmq.processor.MessageProcessor"/>
<beans:bean id="amqpItemWriter" class="org.springframework.batch.item.amqp.AmqpItemWriter">
<beans:constructor-arg ref="outboundAmqpTemplate"/>
</beans:bean>
</beans:beans>

View File

@@ -4,8 +4,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="data-source-context.xml" />
<import
resource="classpath:/org/springframework/batch/sample/config/common-context.xml" />
<import resource="common-context.xml" />
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
<property name="jobRepository" ref="jobRepository" />

View File

@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="data-source-context.xml" />
<import resource="classpath:/org/springframework/batch/sample/config/common-context.xml" />
<import resource="common-context.xml" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
<property name="jobRepository" ref="jobRepository" />

View File

@@ -61,8 +61,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
* </p>
*/
@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 {

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:/simple-job-launcher-context.xml" />
<import resource="classpath:/jobs/jobStepSample.xml" />
<bean class="org.springframework.batch.test.JobLauncherTestUtils">
<property name="job" ref="jobStepJob"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobLauncher" ref="jobLauncher"/>
</bean>
</beans>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:data-source-context.xml"/>
</beans>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:staging-test-context.xml"/>
</beans>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:staging-test-context.xml"/>
</beans>