OPEN - issue BATCH-398: That old stateful / stateless thing again....
http://jira.springframework.org/browse/BATCH-398 New XML configuration convention for samples tests (similar to JUnit 4 support in Spring 2.5). This enables us to keep the job configurations separate.
This commit is contained in:
@@ -19,9 +19,8 @@ package org.springframework.batch.sample;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.execution.launch.JobLauncher;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Abstract unit test for running functional tests by getting context locations
|
||||
@@ -41,21 +40,20 @@ public abstract class AbstractBatchLauncherTests extends
|
||||
setDependencyCheck(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.test.AbstractSingleSpringContextTests#getConfigLocations()
|
||||
*/
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { ClassUtils.addResourcePathToPackagePath(getClass(), ClassUtils.getShortName(getClass())
|
||||
+ "-context.xml") };
|
||||
}
|
||||
|
||||
JobLauncher launcher;
|
||||
private Job job;
|
||||
|
||||
private JobParameters jobParameters = new JobParameters();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.test.AbstractSingleSpringContextTests#createApplicationContext(java.lang.String[])
|
||||
*/
|
||||
protected ConfigurableApplicationContext createApplicationContext(
|
||||
String[] locations) {
|
||||
return new ClassPathXmlApplicationContext(locations);
|
||||
}
|
||||
|
||||
public void setLauncher(JobLauncher bootstrap) {
|
||||
this.launcher = bootstrap;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ package org.springframework.batch.sample;
|
||||
|
||||
public class BeanWrapperMapperSampleJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"jobs/beanWrapperMapperSampleJob.xml"};
|
||||
}
|
||||
|
||||
protected void validatePostConditions() {
|
||||
// nothing to check, the job writes no output
|
||||
}
|
||||
|
||||
@@ -33,11 +33,6 @@ public class CompositeProcessorSampleFunctionalTests extends AbstractValidatingB
|
||||
|
||||
private int before;
|
||||
|
||||
// @Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"jobs/compositeProcessorSampleJob.xml"};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.sample.AbstractLifecycleSpringContextTests#validatePreConditions()
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,6 @@ public class DelegatingJobFunctionalTests extends AbstractValidatingBatchLaunche
|
||||
|
||||
private PersonService personService;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/delegatingJob.xml"};
|
||||
}
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
assertTrue(personService.getReturnedCount() > 0);
|
||||
assertEquals(personService.getReturnedCount(), personService.getReceivedCount());
|
||||
|
||||
@@ -52,10 +52,6 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch
|
||||
inputSource.setResource(fileLocator);
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/fixedLengthImportJob.xml"};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that records have been correctly written to database
|
||||
* @throws Exception
|
||||
|
||||
@@ -14,10 +14,6 @@ public class FootballJobFunctionalTests extends
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "jobs/footballJob.xml" };
|
||||
}
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
int count = jdbcTemplate.queryForInt("SELECT COUNT(*) from PLAYER_SUMMARY");
|
||||
assertTrue(count>0);
|
||||
|
||||
@@ -29,10 +29,6 @@ import org.springframework.batch.core.domain.JobParameters;
|
||||
*/
|
||||
public class GracefulShutdownFunctionalTests extends AbstractBatchLauncherTests {
|
||||
|
||||
protected String[] getConfigLocations(){
|
||||
return new String[] {"jobs/infiniteLoopJob.xml"};
|
||||
}
|
||||
|
||||
public void testLaunchJob() throws Exception {
|
||||
|
||||
final JobParameters jobParameters = new JobParameters();
|
||||
|
||||
@@ -40,10 +40,6 @@ public class HibernateFailureJobFunctionalTests extends
|
||||
writer.setFailOnFlush(-1);
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "jobs/hibernateJob.xml" };
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -7,7 +7,4 @@ package org.springframework.batch.sample;
|
||||
*/
|
||||
public class HibernateJobFunctionalTests extends AbstractCustomerCreditIncreaseTests {
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/hibernateJob.xml"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,4 @@ package org.springframework.batch.sample;
|
||||
*/
|
||||
public class IbatisJobFunctionalTests extends AbstractCustomerCreditIncreaseTests{
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/ibatisJob.xml"};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,6 @@ public class MultilineJobFunctionalTests extends AbstractValidatingBatchLauncher
|
||||
|
||||
private Resource output = new FileSystemResource("target/test-outputs/20070122.testStream.multilineStep.txt");
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "jobs/multilineJob.xml" };
|
||||
}
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
assertEquals(EXPECTED_RESULT, StringUtils.replace(IOUtils.toString(output.getInputStream()), System
|
||||
.getProperty("line.separator"), ""));
|
||||
|
||||
@@ -48,11 +48,6 @@ public class MultilineOrderJobFunctionalTests extends AbstractValidatingBatchLau
|
||||
|
||||
private Resource fileOutputLocator = new FileSystemResource("target/test-outputs/20070122.teststream.multilineOrderStep.TEMP.txt");
|
||||
|
||||
// @Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/multilineOrderJob.xml"};
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the output file and compare it with expected string
|
||||
* @throws IOException
|
||||
|
||||
@@ -15,10 +15,6 @@ public class ParallelJobFunctionalTests extends
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "jobs/parallelJob.xml" };
|
||||
}
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
int count;
|
||||
count = jdbcTemplate.queryForInt(
|
||||
|
||||
@@ -28,8 +28,6 @@ import org.springframework.jdbc.core.JdbcOperations;
|
||||
*/
|
||||
public class RestartFunctionalTests extends AbstractBatchLauncherTests {
|
||||
|
||||
private static final String JOB_FILE = "jobs/restartSample.xml";
|
||||
|
||||
//auto-injected attributes
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
@@ -42,10 +40,6 @@ public class RestartFunctionalTests extends AbstractBatchLauncherTests {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations(){
|
||||
return new String[]{JOB_FILE};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.test.AbstractSingleSpringContextTests#onTearDown()
|
||||
*/
|
||||
|
||||
@@ -14,10 +14,6 @@ public class RetrySampleFunctionalTests extends AbstractValidatingBatchLauncherT
|
||||
|
||||
private RetrySampleItemWriter itemProcessor;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/retrySample.xml"};
|
||||
}
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
//items processed = items read + 2 exceptions
|
||||
assertEquals(itemGenerator.getLimit()+2, itemProcessor.getCounter());
|
||||
|
||||
@@ -19,10 +19,6 @@ public class RollbackJobFunctionalTests extends AbstractValidatingBatchLauncherT
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/rollbackJob.xml"};
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
before = jdbcTemplate.queryForInt("SELECT COUNT(*) from TRADE");
|
||||
}
|
||||
|
||||
@@ -21,9 +21,5 @@ package org.springframework.batch.sample;
|
||||
* the test is reused, only the job config location is overridden
|
||||
*/
|
||||
public class SimpleJobFunctionalTests extends FixedLengthImportJobFunctionalTests {
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"jobs/simpleJob.xml"};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,10 +52,6 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {"jobs/tradeJob.xml"};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.test.AbstractSingleSpringContextTests#onSetUp()
|
||||
*/
|
||||
|
||||
@@ -26,11 +26,6 @@ public class XmlStaxJobFunctionalTests extends AbstractValidatingBatchLauncherTe
|
||||
|
||||
private static final String OUTPUT_FILE = "target/test-outputs/20070918.testStream.xmlFileStep.output.xml";
|
||||
private static final String EXPECTED_OUTPUT_FILE = "src/main/resources/data/staxJob/output/expected-output.xml";
|
||||
|
||||
// @Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"jobs/xmlStaxJob.xml"};
|
||||
}
|
||||
|
||||
/**
|
||||
* Output should be the same as input
|
||||
|
||||
Reference in New Issue
Block a user