BATCH-220: Rationalise the exception classifiers so they can be used in a retry

This commit is contained in:
dsyer
2008-08-29 14:09:11 +00:00
parent f25fbb5c15
commit 2ea0fe68cf
41 changed files with 925 additions and 781 deletions

View File

@@ -54,7 +54,7 @@
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="sql"
value="SELECT id, quantity, price, customer from TRADE" />
value="SELECT isin, quantity, price, customer from TRADE" />
<property name="mapper">
<bean
class="org.springframework.batch.sample.domain.trade.internal.TradeRowMapper" />

View File

@@ -28,7 +28,7 @@ log4j.logger.org.springframework=info
#log4j.logger.org.springframework.orm=debug
### debug your specific package or classes with the following example
log4j.logger.org.springframework.batch=info
log4j.logger.org.springframework.batch=debug
log4j.logger.org.springframework.batch.sample=debug
log4j.logger.org.springframework.batch.sample.module.OrderDataProvider=debug
log4j.logger.org.springframework.batch.container.common.module.process.support.DefaultXmlDataProvider=debug

View File

@@ -42,7 +42,7 @@ public abstract class AbstractBatchLauncherTests implements ApplicationContextAw
protected ApplicationContext applicationContext;
protected JobLauncher launcher;
private JobLauncher launcher;
private Job job;
@@ -77,6 +77,14 @@ public abstract class AbstractBatchLauncherTests implements ApplicationContextAw
@Test
public void testLaunchJob() throws Exception {
launcher.run(job, jobParameters);
getLauncher().run(job, jobParameters);
}
/**
* Public getter for the launcher.
* @return the launcher
*/
protected JobLauncher getLauncher() {
return launcher;
}
}

View File

@@ -46,7 +46,7 @@ public class DatabaseShutdownFunctionalTests extends AbstractBatchLauncherTests
final JobParameters jobParameters = new JobParameters();
JobExecution jobExecution = launcher.run(getJob(), jobParameters);
JobExecution jobExecution = getLauncher().run(getJob(), jobParameters);
Thread.sleep(1000);

View File

@@ -45,7 +45,7 @@ public class GracefulShutdownFunctionalTests extends AbstractBatchLauncherTests
final JobParameters jobParameters = new JobParameters();
JobExecution jobExecution = launcher.run(getJob(), jobParameters);
JobExecution jobExecution = getLauncher().run(getJob(), jobParameters);
Thread.sleep(1000);

View File

@@ -94,7 +94,7 @@ public class RestartFunctionalTests extends AbstractBatchLauncherTests {
private void runJobForRestartTest() throws Exception {
// The second time we run the job it needs to be a new instance so we
// need to make the parameters unique...
launcher.run(getJob(), new DefaultJobParametersConverter().getJobParameters(PropertiesConverter
getLauncher().run(getJob(), new DefaultJobParametersConverter().getJobParameters(PropertiesConverter
.stringToProperties("force.new.job.parameters=true")));
}

View File

@@ -1,14 +1,16 @@
package org.springframework.batch.sample;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;
/**
* Deletes files in the given directory.
@@ -19,13 +21,13 @@ import org.springframework.util.Assert;
@ContextConfiguration()
public class TaskletJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
private Resource directory = new FileSystemResource("target/test-outputs/test-dir");
private static Resource directory = new FileSystemResource("target/test-outputs/test-dir");
/*
* Create the directory and some files in it.
*/
@Before
public void onSetUp() throws Exception {
@BeforeClass
public static void onSetUp() throws Exception {
File dir = directory.getFile();
dir.mkdirs();
new File(dir, "file1").createNewFile();
@@ -37,8 +39,8 @@ public class TaskletJobFunctionalTests extends AbstractValidatingBatchLauncherTe
*/
@Override
protected void validatePreConditions() throws Exception {
Assert.state(directory.getFile().isDirectory());
Assert.state(directory.getFile().listFiles().length > 0);
assertTrue(directory.getFile().isDirectory());
assertTrue(directory.getFile().listFiles().length > 0);
}
/**
@@ -46,8 +48,8 @@ public class TaskletJobFunctionalTests extends AbstractValidatingBatchLauncherTe
*/
@Override
protected void validatePostConditions() throws Exception {
Assert.state(directory.getFile().isDirectory());
Assert.state(directory.getFile().listFiles().length == 0);
assertTrue(directory.getFile().isDirectory());
assertEquals(0, directory.getFile().listFiles().length);
}
}

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -80,16 +80,16 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
// assertTrue(((Resource)applicationContext.getBean("customerFileLocator")).exists());
customers = new ArrayList<Customer>() {{add(new Customer("customer1", (credits.get("customer1") - 98.34)));
add(new Customer("customer2", (credits.get("customer2") - 18.12 - 12.78)));
add(new Customer("customer3", (credits.get("customer3") - 109.25)));
add(new Customer("customer4", credits.get("customer4") - 123.39));}};
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)),
new Customer("customer4", credits.get("customer4") - 123.39));
trades = new ArrayList<Trade>() {{add(new Trade("UK21341EAH45", 978, new BigDecimal("98.34"), "customer1"));
add(new Trade("UK21341EAH46", 112, new BigDecimal("18.12"), "customer2"));
add(new Trade("UK21341EAH47", 245, new BigDecimal("12.78"), "customer2"));
add(new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"));
add(new Trade("UK21341EAH49", 854, new BigDecimal("123.39"), "customer4"));}};
trades = Arrays.asList(new Trade("UK21341EAH45", 978, new BigDecimal("98.34"), "customer1"),
new Trade("UK21341EAH46", 112, new BigDecimal("18.12"), "customer2"),
new Trade("UK21341EAH47", 245, new BigDecimal("12.78"), "customer2"),
new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"),
new Trade("UK21341EAH49", 854, new BigDecimal("123.39"), "customer4"));
// check content of the trade table
simpleJdbcTemplate.getJdbcOperations().query(GET_TRADES, new RowCallbackHandler() {