[BATCH-383] Fixes to make Spring Batch 1.4 runtime compliant.
This commit is contained in:
@@ -199,7 +199,7 @@ public class JobParametersTests extends TestCase {
|
||||
public void testToStringOrder() {
|
||||
|
||||
Map props = parameters.getParameters();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuffer stringBuilder = new StringBuffer();
|
||||
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
|
||||
Entry entry = (Entry) it.next();
|
||||
stringBuilder.append(entry.toString() + ";");
|
||||
@@ -226,7 +226,7 @@ public class JobParametersTests extends TestCase {
|
||||
JobParameters testProps = new JobParameters(stringMap, longMap, doubleMap, dateMap);
|
||||
|
||||
props = testProps.getParameters();
|
||||
stringBuilder = new StringBuilder();
|
||||
stringBuilder = new StringBuffer();
|
||||
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
|
||||
Entry entry = (Entry) it.next();
|
||||
stringBuilder.append(entry.toString() + ";");
|
||||
|
||||
@@ -17,11 +17,10 @@ package org.springframework.batch.core.job;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -31,8 +30,7 @@ public class AbstractJobTests extends TestCase {
|
||||
JobSupport job = new JobSupport("job");
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#JobConfiguration()}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#JobConfiguration()}.
|
||||
*/
|
||||
public void testJobConfiguration() {
|
||||
job = new JobSupport();
|
||||
@@ -40,8 +38,7 @@ public class AbstractJobTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#setBeanName(java.lang.String)}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanName() {
|
||||
job.setBeanName("foo");
|
||||
@@ -49,8 +46,7 @@ public class AbstractJobTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#setBeanName(java.lang.String)}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanNameWithNullName() {
|
||||
job = new JobSupport(null);
|
||||
@@ -60,8 +56,7 @@ public class AbstractJobTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#setStepNames(java.util.List)}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setStepNames(java.util.List)}.
|
||||
*/
|
||||
public void testSetSteps() {
|
||||
job.setSteps(Collections.singletonList(new StepSupport("step")));
|
||||
@@ -78,8 +73,7 @@ public class AbstractJobTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#setStartLimit(int)}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setStartLimit(int)}.
|
||||
*/
|
||||
public void testSetStartLimit() {
|
||||
assertEquals(Integer.MAX_VALUE, job.getStartLimit());
|
||||
@@ -88,28 +82,30 @@ public class AbstractJobTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.job.AbstractJob#setRestartable(boolean)}.
|
||||
* Test method for {@link org.springframework.batch.core.job.AbstractJob#setRestartable(boolean)}.
|
||||
*/
|
||||
public void testSetRestartable() {
|
||||
assertFalse(job.isRestartable());
|
||||
job.setRestartable(true);
|
||||
assertTrue(job.isRestartable());
|
||||
}
|
||||
|
||||
|
||||
public void testToString() throws Exception {
|
||||
String value = job.toString();
|
||||
assertTrue("Should contain name: "+value, value.indexOf("name=")>=0);
|
||||
assertTrue("Should contain name: " + value, value.indexOf("name=") >= 0);
|
||||
}
|
||||
|
||||
|
||||
public void testRunNotSupported() throws Exception {
|
||||
try {
|
||||
job.execute(null);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain JobSupport: "+message, message.contains("JobSupport"));
|
||||
assertTrue("Message should contain JobSupport: " + message, contains(message, "JobSupport"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
try {
|
||||
testRun();
|
||||
fail("Expected RuntimeException");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
assertEquals("foo", e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -114,8 +113,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
try {
|
||||
testRun();
|
||||
fail("Expected Error");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
assertEquals("foo", e.getCause().getMessage());
|
||||
}
|
||||
}
|
||||
@@ -124,11 +122,10 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
try {
|
||||
new SimpleJobLauncher().afterPropertiesSet();
|
||||
fail("Expected IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
} catch (IllegalStateException e) {
|
||||
// expected
|
||||
assertTrue("Message did not contain repository: " + e.getMessage(), e.getMessage().toLowerCase().contains(
|
||||
"repository"));
|
||||
assertTrue("Message did not contain repository: " + e.getMessage(), contains(e.getMessage().toLowerCase(),
|
||||
"repository"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,4 +134,8 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
jobLauncher.setJobRepository(jobRepository);
|
||||
jobLauncher.afterPropertiesSet(); // no error
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
public void testGetProperties() throws Exception {
|
||||
|
||||
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008"))
|
||||
.addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters();
|
||||
.addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters();
|
||||
|
||||
Properties props = factory.getProperties(parameters);
|
||||
assertNotNull(props);
|
||||
@@ -76,12 +76,12 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
JobParameters props = factory.getJobParameters(new Properties());
|
||||
assertTrue(props.getParameters().isEmpty());
|
||||
}
|
||||
|
||||
public void testNullArgs(){
|
||||
|
||||
public void testNullArgs() {
|
||||
assertEquals(new JobParameters(), factory.getJobParameters(null));
|
||||
assertEquals(new Properties(), factory.getProperties(null));
|
||||
}
|
||||
|
||||
|
||||
public void testGetParametersWithDateFormat() throws Exception {
|
||||
|
||||
String[] args = new String[] { "schedule.date=2008/23/01" };
|
||||
@@ -101,8 +101,11 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain wrong date: "+message, message.contains("20080123"));
|
||||
assertTrue("Message should contain wrong date: " + message, contains(message, "20080123"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
private SimpleExportedJobLauncher launcher = new SimpleExportedJobLauncher();
|
||||
|
||||
private MapJobRegistry jobLocator;
|
||||
|
||||
|
||||
private List list = new ArrayList();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@@ -55,7 +55,8 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException {
|
||||
JobExecution result = new JobExecution(null);
|
||||
StepExecution stepExecution = result.createStepExecution(new StepSupport("stepName"));
|
||||
stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar")));
|
||||
stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter
|
||||
.stringToProperties("foo=bar")));
|
||||
list.add(jobParameters);
|
||||
return result;
|
||||
}
|
||||
@@ -67,6 +68,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAfterPropertiesSet() throws Exception {
|
||||
@@ -74,16 +76,16 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
try {
|
||||
launcher.afterPropertiesSet();
|
||||
fail("Expected IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message does not contain 'launcher': " + message, message.toLowerCase().contains("joblauncher"));
|
||||
assertTrue("Message does not contain 'launcher': " + message, contains(message.toLowerCase(), "joblauncher"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAfterPropertiesSetWithLauncher() throws Exception {
|
||||
@@ -96,16 +98,14 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
try {
|
||||
launcher.afterPropertiesSet();
|
||||
fail("Expected IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message does not contain 'locator': " + message, message.toLowerCase().contains("joblocator"));
|
||||
assertTrue("Message does not contain 'locator': " + message, contains(message.toLowerCase(), "joblocator"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}.
|
||||
* Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}.
|
||||
*/
|
||||
public void testGetStatistics() {
|
||||
Properties props = launcher.getStatistics();
|
||||
@@ -114,8 +114,8 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}.
|
||||
* Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetStatisticsWithContent() throws Exception {
|
||||
@@ -127,8 +127,8 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}.
|
||||
* Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testIsRunning() throws Exception {
|
||||
@@ -138,8 +138,8 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}.
|
||||
* Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAlreadyRunning() throws Exception {
|
||||
@@ -150,7 +150,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
}
|
||||
});
|
||||
String value = launcher.run("foo");
|
||||
assertTrue("Return value was not an exception: " + value, value.contains("JobExecutionAlreadyRunningException"));
|
||||
assertTrue("Return value was not an exception: " + value, contains(value, "JobExecutionAlreadyRunningException"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,25 +159,27 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
*/
|
||||
public void testRunNonExistentJob() {
|
||||
String value = launcher.run("foo");
|
||||
assertTrue("Return value was not an exception: " + value, value.contains("NoSuchJobException"));
|
||||
assertTrue("Return value was not an exception: " + value, contains(value, "NoSuchJobException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)}.
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRunJobWithParameters() throws Exception {
|
||||
jobLocator.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
String value = launcher.run("foo", "bar=spam,bucket=crap");
|
||||
assertTrue(launcher.isRunning());
|
||||
assertTrue("Return value was not a JobExecution: " + value, value.contains("JobExecution"));
|
||||
assertTrue("Return value was not a JobExecution: " + value, contains(value, "JobExecution"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)}.
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRunJobWithParametersAndFactory() throws Exception {
|
||||
jobLocator.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
@@ -185,6 +187,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
public JobParameters getJobParameters(Properties properties) {
|
||||
return new JobParametersBuilder().addString("foo", "spam").toJobParameters();
|
||||
}
|
||||
|
||||
public Properties getProperties(JobParameters params) {
|
||||
return null;
|
||||
}
|
||||
@@ -195,9 +198,9 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#stop()}.
|
||||
* @throws Exception
|
||||
* Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#stop()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testStop() throws Exception {
|
||||
jobLocator.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
@@ -207,4 +210,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
assertFalse(launcher.isRunning());
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,8 +503,8 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
} catch (JobInterruptedException ex) {
|
||||
assertEquals(BatchStatus.STOPPED, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertTrue("Message does not contain JobInterruptedException: " + msg, msg
|
||||
.contains("JobInterruptedException"));
|
||||
assertTrue("Message does not contain JobInterruptedException: " + msg, contains(msg,
|
||||
"JobInterruptedException"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
} catch (UnexpectedJobExecutionException ex) {
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertTrue("Message does not contain ResetFailedException: " + msg, msg.contains("ResetFailedException"));
|
||||
assertTrue("Message does not contain ResetFailedException: " + msg, contains(msg, "ResetFailedException"));
|
||||
// The original rollback was caused by this one:
|
||||
assertEquals("Bar", ex.getCause().getMessage());
|
||||
}
|
||||
@@ -591,7 +591,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertEquals("", msg);
|
||||
msg = ex.getMessage();
|
||||
assertTrue("Message does not contain 'saving': " + msg, msg.contains("saving"));
|
||||
assertTrue("Message does not contain 'saving': " + msg, contains(msg, "saving"));
|
||||
// The original rollback was caused by this one:
|
||||
assertEquals("Bar", ex.getCause().getMessage());
|
||||
}
|
||||
@@ -620,7 +620,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertEquals("", msg);
|
||||
msg = ex.getMessage();
|
||||
assertTrue("Message does not contain 'final': " + msg, msg.contains("final"));
|
||||
assertTrue("Message does not contain 'final': " + msg, contains(msg, "final"));
|
||||
// The original rollback was caused by this one:
|
||||
assertEquals("Bar", ex.getCause().getMessage());
|
||||
}
|
||||
@@ -648,17 +648,21 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
fail("Expected InfrastructureException");
|
||||
} catch (UnexpectedJobExecutionException ex) {
|
||||
// The job actually completeed, but the streams couldn't be closed.
|
||||
// The job actually completed, but the streams couldn't be closed.
|
||||
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertEquals("", msg);
|
||||
msg = ex.getMessage();
|
||||
assertTrue("Message does not contain 'close': " + msg, msg.contains("close"));
|
||||
assertTrue("Message does not contain 'close': " + msg, contains(msg, "close"));
|
||||
// The original rollback was caused by this one:
|
||||
assertEquals("Bar", ex.getCause().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
|
||||
private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, StepListener {
|
||||
|
||||
private boolean getExecutionAttributesCalled = false;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TaskletStepTests extends TestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
stepExecution = new StepExecution(new StepSupport("stepName"), new JobExecution(new JobInstance(new Long(0L),
|
||||
new JobParameters(), new JobSupport("testJob")), new Long(12)));
|
||||
new JobParameters(), new JobSupport("testJob")), new Long(12)));
|
||||
}
|
||||
|
||||
public void testTaskletMandatory() throws Exception {
|
||||
@@ -35,10 +35,9 @@ public class TaskletStepTests extends TestCase {
|
||||
step.setJobRepository(new JobRepositorySupport());
|
||||
try {
|
||||
step.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain 'tasklet': " + message, message.toLowerCase().contains("tasklet"));
|
||||
assertTrue("Message should contain 'tasklet': " + message, contains(message.toLowerCase(), "tasklet"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +45,9 @@ public class TaskletStepTests extends TestCase {
|
||||
TaskletStep step = new TaskletStep();
|
||||
try {
|
||||
step.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain 'tasklet': " + message, message.toLowerCase().contains("tasklet"));
|
||||
assertTrue("Message should contain 'tasklet': " + message, contains(message.toLowerCase(), "tasklet"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +88,7 @@ public class TaskletStepTests extends TestCase {
|
||||
try {
|
||||
step.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (UnexpectedJobExecutionException e) {
|
||||
} catch (UnexpectedJobExecutionException e) {
|
||||
assertEquals("foo", e.getCause().getMessage());
|
||||
}
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
@@ -126,31 +123,27 @@ public class TaskletStepTests extends TestCase {
|
||||
try {
|
||||
step.execute(stepExecution);
|
||||
fail();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
assertNotNull(stepExecution.getStartTime());
|
||||
assertEquals(ExitStatus.FAILED, stepExecution.getExitStatus());
|
||||
assertNotNull(stepExecution.getEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When job is interrupted the {@link JobInterruptedException} should be propagated up.
|
||||
*/
|
||||
public void testJobInterrupted() throws Exception {
|
||||
TaskletStep step = new TaskletStep(
|
||||
new Tasklet(){
|
||||
public ExitStatus execute() throws Exception {
|
||||
throw new JobInterruptedException("Interrupted while executing tasklet");
|
||||
}
|
||||
},
|
||||
new JobRepositorySupport());
|
||||
|
||||
TaskletStep step = new TaskletStep(new Tasklet() {
|
||||
public ExitStatus execute() throws Exception {
|
||||
throw new JobInterruptedException("Interrupted while executing tasklet");
|
||||
}
|
||||
}, new JobRepositorySupport());
|
||||
|
||||
try {
|
||||
step.execute(stepExecution);
|
||||
fail();
|
||||
}
|
||||
catch (JobInterruptedException expected) {
|
||||
} catch (JobInterruptedException expected) {
|
||||
assertEquals("Interrupted while executing tasklet", expected.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -197,4 +190,7 @@ public class TaskletStepTests extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ public class DefaultJobParametersConverterTests extends TestCase {
|
||||
factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain wrong date: "+message, message.contains("20080123"));
|
||||
assertTrue("Message should contain format: "+message, message.contains("yyyy/MM/dd"));
|
||||
assertTrue("Message should contain wrong date: " + message, contains(message, "20080123"));
|
||||
assertTrue("Message should contain format: " + message, contains(message, "yyyy/MM/dd"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class DefaultJobParametersConverterTests extends TestCase {
|
||||
factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain wrong number: "+message, message.contains("foo"));
|
||||
assertTrue("Message should contain format: "+message, message.contains("#"));
|
||||
assertTrue("Message should contain wrong number: " + message, contains(message, "foo"));
|
||||
assertTrue("Message should contain format: " + message, contains(message, "#"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,15 +110,15 @@ public class DefaultJobParametersConverterTests extends TestCase {
|
||||
factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
|
||||
} catch (IllegalArgumentException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message should contain wrong number: "+message, message.contains("1.03"));
|
||||
assertTrue("Message should contain 'decimal': "+message, message.contains("decimal"));
|
||||
assertTrue("Message should contain wrong number: " + message, contains(message, "1.03"));
|
||||
assertTrue("Message should contain 'decimal': " + message, contains(message, "decimal"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetProperties() throws Exception {
|
||||
|
||||
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008"))
|
||||
.addString("job.key", "myKey").addLong("vendor.id", new Long(33243243)).toJobParameters();
|
||||
.addString("job.key", "myKey").addLong("vendor.id", new Long(33243243)).toJobParameters();
|
||||
|
||||
Properties props = factory.getProperties(parameters);
|
||||
assertNotNull(props);
|
||||
@@ -132,9 +132,13 @@ public class DefaultJobParametersConverterTests extends TestCase {
|
||||
JobParameters props = factory.getJobParameters(new Properties());
|
||||
assertTrue(props.getParameters().isEmpty());
|
||||
}
|
||||
|
||||
public void testNullArgs(){
|
||||
|
||||
public void testNullArgs() {
|
||||
assertEquals(new JobParameters(), factory.getJobParameters(null));
|
||||
assertEquals(new Properties(), factory.getProperties(null));
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user