OPEN - issue BATCH-812: StepExecutionResourceProxy should use a different JobParametersConverter
http://jira.springframework.org/browse/BATCH-812 Long and Date parameters now work in StepExecutionResourceProxy without requiring a type after the key.
This commit is contained in:
@@ -159,10 +159,10 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Date) {
|
||||
result.setProperty(key + DATE_TYPE, dateFormat.format(value));
|
||||
result.setProperty(key, dateFormat.format(value));
|
||||
}
|
||||
else if (value instanceof Long) {
|
||||
result.setProperty(key + LONG_TYPE, numberFormat.format(value));
|
||||
result.setProperty(key, numberFormat.format(value));
|
||||
}
|
||||
else {
|
||||
result.setProperty(key, "" + value);
|
||||
|
||||
@@ -145,8 +145,8 @@ public class DefaultJobParametersConverterTests extends TestCase {
|
||||
Properties props = factory.getProperties(parameters);
|
||||
assertNotNull(props);
|
||||
assertEquals("myKey", props.getProperty("job.key"));
|
||||
assertEquals("33243243", props.getProperty("vendor.id(long)"));
|
||||
assertEquals("2008/01/23", props.getProperty("schedule.date(date)"));
|
||||
assertEquals("33243243", props.getProperty("vendor.id"));
|
||||
assertEquals("2008/01/23", props.getProperty("schedule.date"));
|
||||
}
|
||||
|
||||
public void testEmptyArgs() {
|
||||
|
||||
@@ -157,6 +157,17 @@ public class StepExecutionResourceProxyTests extends TestCase {
|
||||
//expected, if there isn't a JobParameter for that key, it should throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
public void testLongJobParameter() throws Exception {
|
||||
|
||||
resource.setFilePattern("foo/data/%JOB_NAME%/%job.key%-foo");
|
||||
jobInstance = new JobInstance(new Long(0), new JobParametersBuilder().addLong("job.key", new Long(123))
|
||||
.toJobParameters(), "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
resource.beforeStep(jobExecution.createStepExecution(step));
|
||||
doTestPathName("123-foo", "foo" + pathsep + "data" + pathsep);
|
||||
}
|
||||
|
||||
private void doTestPathName(String filename, String path) throws Exception, IOException {
|
||||
String returnedPath = resource.getFile().getAbsolutePath();
|
||||
|
||||
Reference in New Issue
Block a user