Skip to content

Commit

Permalink
Restructure test resources in samples
Browse files Browse the repository at this point in the history
  • Loading branch information
fmbenhassine committed Oct 2, 2023
1 parent e42167b commit f4bb0c7
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 122 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
22 changes: 0 additions & 22 deletions spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
* </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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand All @@ -38,9 +39,13 @@
* @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;

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

@Test
void testJobLaunch() throws Exception {
jobLauncherTestUtils.setJob(jobStepJob);
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");

jobLauncherTestUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

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

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

private DataSource dataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

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

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

private JdbcTemplate jdbcTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

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

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

private JdbcOperations jdbcTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,13 +60,13 @@
*/
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
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f4bb0c7

Please sign in to comment.