Tidy up config in test project
This commit is contained in:
@@ -1,30 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.2.0.v200809261800]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/resources/data-source-context-init.xml</config>
|
||||
<config>src/test/resources/data-source-context.xml</config>
|
||||
<config>src/test/resources/simple-job-launcher-context.xml</config>
|
||||
<config>src/test/resources/jobs/sampleJob.xml</config>
|
||||
<config>src/test/resources/org/springframework/batch/sample/config/common-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
<name><![CDATA[SampleJob]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
<config>src/test/resources/data-source-context.xml</config>
|
||||
<config>src/test/resources/data-source-context-init.xml</config>
|
||||
<config>src/test/resources/jobs/sampleJob.xml</config>
|
||||
<config>src/test/resources/org/springframework/batch/sample/config/common-context.xml</config>
|
||||
<config>src/test/resources/simple-job-launcher-context.xml</config>
|
||||
</configs>
|
||||
</configSet>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.2.0.v200809261800]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/resources/data-source-context.xml</config>
|
||||
<config>src/test/resources/simple-job-launcher-context.xml</config>
|
||||
<config>src/test/resources/jobs/sampleJob.xml</config>
|
||||
<config>src/test/resources/org/springframework/batch/sample/config/common-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
<name><![CDATA[SampleJob]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
<config>src/test/resources/data-source-context.xml</config>
|
||||
<config>src/test/resources/jobs/sampleJob.xml</config>
|
||||
<config>src/test/resources/org/springframework/batch/sample/config/common-context.xml</config>
|
||||
<config>src/test/resources/simple-job-launcher-context.xml</config>
|
||||
</configs>
|
||||
</configSet>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
|
||||
@@ -33,16 +33,6 @@ public class SampleJobTests extends AbstractSimpleJobTests {
|
||||
this.jdbcTemplate.update("drop table TESTS");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
assertEquals(BatchStatus.COMPLETED, this.launchStep("step1").getStatus());
|
||||
this.verifyTasklet(1);
|
||||
}
|
||||
|
||||
private void verifyTasklet(int id) {
|
||||
assertEquals(id, jdbcTemplate.queryForInt("SELECT ID from TESTS where NAME = 'SampleTasklet" + id + "'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJob() throws Exception {
|
||||
assertEquals(BatchStatus.COMPLETED,this.launchJob().getStatus());
|
||||
@@ -56,8 +46,19 @@ public class SampleJobTests extends AbstractSimpleJobTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
public void testStep1Execution() {
|
||||
assertEquals(BatchStatus.COMPLETED, this.launchStep("step1").getStatus());
|
||||
this.verifyTasklet(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStep2Execution() {
|
||||
assertEquals(BatchStatus.COMPLETED, this.launchStep("step2").getStatus());
|
||||
this.verifyTasklet(2);
|
||||
}
|
||||
|
||||
private void verifyTasklet(int id) {
|
||||
assertEquals(id, jdbcTemplate.queryForInt("SELECT ID from TESTS where NAME = 'SampleTasklet" + id + "'"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public class SampleTasklet implements Tasklet {
|
||||
}
|
||||
|
||||
public RepeatStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception {
|
||||
System.err.println("SampleTasklet1.execute()");
|
||||
this.jdbcTemplate.update("insert into TESTS(ID, NAME) values (?, 'SampleTasklet" + id + "')", id);
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
@@ -1,16 +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 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="dataSourceInitializer" class="test.jdbc.datasource.DataSourceInitializer">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="initScripts">
|
||||
<list>
|
||||
<value>${batch.schema.script}</value>
|
||||
<value>${batch.business.schema.script}</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,22 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
|
||||
|
||||
<!-- Initialise the database before every test case: -->
|
||||
<import resource="data-source-context-init.xml" />
|
||||
<bean id="dataSourceInitializer" class="test.jdbc.datasource.DataSourceInitializer">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="initScripts">
|
||||
<list>
|
||||
<value>${batch.schema.script}</value>
|
||||
<value>${batch.business.schema.script}
|
||||
</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
|
||||
<property name="driverClassName" value="${batch.jdbc.driver}" />
|
||||
<property name="url" value="${batch.jdbc.url}" />
|
||||
<property name="username" value="${batch.jdbc.user}" />
|
||||
<property name="password" value="${batch.jdbc.password}" />
|
||||
</bean>
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true">
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
lazy-init="true">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
<!-- Set up or detect a System property called "environment" used to construct a properties file on the classpath. The default is "hsql". -->
|
||||
<bean id="environment" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
|
||||
<!--
|
||||
Set up or detect a System property called "environment" used to
|
||||
construct a properties file on the classpath. The default is "hsql".
|
||||
-->
|
||||
<bean id="environment"
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetClass" value="java.lang.System" />
|
||||
<property name="targetMethod" value="setProperty" />
|
||||
<property name="arguments">
|
||||
@@ -36,7 +54,8 @@
|
||||
</bean>
|
||||
|
||||
<!-- Use this to set additional properties on beans at run time -->
|
||||
<bean id="overrideProperties" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"
|
||||
<bean id="overrideProperties"
|
||||
class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"
|
||||
depends-on="environment">
|
||||
<property name="location" value="classpath:batch-${environment}.properties" />
|
||||
<!-- Allow system properties (-D) to override those from file -->
|
||||
@@ -47,18 +66,14 @@
|
||||
<property name="ignoreInvalidKeys" value="true" />
|
||||
<property name="order" value="2" />
|
||||
</bean>
|
||||
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
|
||||
|
||||
<bean id="placeholderProperties"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
|
||||
depends-on="environment">
|
||||
<property name="location" value="classpath:batch-${environment}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<bean id="lobHandler" class="${batch.lob.handler.class}" />
|
||||
<bean id="incrementerParent" class="${batch.database.incrementer.class}">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="incrementerName" value="ID" />
|
||||
</bean>
|
||||
|
||||
<!--import resource="alt-data-source-context.xml" /-->
|
||||
</beans>
|
||||
@@ -1,66 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<import resource="classpath:/data-source-context.xml" />
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
|
||||
<constructor-arg ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="databaseType" value="hsql" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob" abstract="true">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="restartable" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="itemOrientedStep" class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="int[]">
|
||||
<bean class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="org.springframework.batch.item.file.transform.Range[]">
|
||||
<bean class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="java.util.Date">
|
||||
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<constructor-arg>
|
||||
<bean class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyyMMdd" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg value="false" />
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<import resource="classpath:/data-source-context.xml" />
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
|
||||
<constructor-arg ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="databaseType" value="hsql" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob" abstract="true">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="restartable" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="itemOrientedStep" class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="int[]">
|
||||
<bean class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="org.springframework.batch.item.file.transform.Range[]">
|
||||
<bean class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="java.util.Date">
|
||||
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<constructor-arg>
|
||||
<bean class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyyMMdd" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg value="false" />
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user