BATCH-1313 & BATCH-1314:

*Added assertion to AbstractBatchLauncherTests to ensure that the job's status is COMPLETED.
 *Fixed broken tests.
This commit is contained in:
dhgarrette
2009-06-28 16:12:50 +00:00
parent a7751c9d01
commit b06a6d86d6
5 changed files with 14 additions and 44 deletions

View File

@@ -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());
}
/**

View File

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