diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loopFlow/LimitDecider.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loopFlow/LimitDecider.java index 1663fa6a2..c50b28b04 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loopFlow/LimitDecider.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loopFlow/LimitDecider.java @@ -30,17 +30,12 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; public class LimitDecider implements JobExecutionDecider { private int count = 0; + private int limit = 1; - /* - * (non-Javadoc) - * - * @see org.springframework.batch.core.job.flow.support.state.JobExecutionDecider#decide(org.springframework.batch.core.JobExecution, - * org.springframework.batch.core.StepExecution) - */ public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (++count >= limit) { - return new FlowExecutionStatus("COMPLETE"); + return new FlowExecutionStatus("COMPLETED"); } else { return new FlowExecutionStatus("CONTINUE"); diff --git a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml index 5b4c5cb76..e426a2f95 100644 --- a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml @@ -25,7 +25,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -102,17 +102,6 @@ - - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml index 081aa8f46..5e98b2e03 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml @@ -76,7 +76,7 @@ - + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java index 5b9ea2619..612116148 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java @@ -18,7 +18,9 @@ package org.springframework.batch.sample; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Test; +import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; @@ -38,20 +40,19 @@ import org.springframework.context.ApplicationContextAware; */ public abstract class AbstractBatchLauncherTests implements ApplicationContextAware { - /** Logger */ + /** Logger */ protected final Log logger = LogFactory.getLog(getClass()); protected ApplicationContext applicationContext; private JobLauncher launcher; - + private JobExecution jobExecution; private Job job; private JobParameters jobParameters = new JobParameters(); - public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @@ -65,7 +66,7 @@ public abstract class AbstractBatchLauncherTests implements ApplicationContextAw public void setJob(Job job) { this.job = job; } - + public JobExecution getJobExecution() { return jobExecution; } @@ -84,7 +85,8 @@ public abstract class AbstractBatchLauncherTests implements ApplicationContextAw @Test public void testLaunchJob() throws Exception { - jobExecution = getLauncher().run(job, jobParameters); + jobExecution = getLauncher().run(job, jobParameters); + Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); } /** diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java index a70f7e4ce..5d1c26019 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java @@ -31,7 +31,6 @@ import javax.sql.DataSource; import org.junit.After; import org.junit.Before; -import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +39,6 @@ import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration() public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTests { @@ -74,15 +72,8 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest simpleJdbcTemplate.update("delete from TRADE"); } - @Test - public void testLaunchJob() throws Exception{ - super.testLaunchJob(); - } - protected void validatePostConditions() { - // assertTrue(((Resource)applicationContext.getBean("customerFileLocator")).exists()); - customers = Arrays.asList(new Customer("customer1", (credits.get("customer1") - 98.34)), new Customer("customer2", (credits.get("customer2") - 18.12 - 12.78)), new Customer("customer3", (credits.get("customer3") - 109.25)), @@ -126,9 +117,6 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest // check content of the output file } - protected void validatePreConditions() { - } - private static class Customer { private String name; private double credit; @@ -166,9 +154,7 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest this.name = name; } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ + @Override public int hashCode() { final int PRIME = 31; int result = 1; @@ -179,9 +165,7 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ + @Override public boolean equals(Object obj) { if (this == obj) return true;