BATCH-2179: Updated to add unidentifying flag to properties as they are returned if applicable
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -180,7 +180,10 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
|
||||
|
||||
/**
|
||||
* Use the same suffixes to create properties (omitting the string suffix
|
||||
* because it is the default).
|
||||
* because it is the default). Non-identifying parameters will be prefixed
|
||||
* with the {@link #NON_IDENTIFYING_FLAG}. However, since parameters are
|
||||
* identifying by default, they will <em>not</em> be prefixed with the
|
||||
* {@link #IDENTIFYING_FLAG}.
|
||||
*
|
||||
* @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
@@ -199,6 +202,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
|
||||
JobParameter jobParameter = entry.getValue();
|
||||
Object value = jobParameter.getValue();
|
||||
if (value != null) {
|
||||
key = (!jobParameter.isIdentifying()? NON_IDENTIFYING_FLAG : "") + key;
|
||||
if (jobParameter.getType() == ParameterType.DATE) {
|
||||
synchronized (dateFormat) {
|
||||
result.setProperty(key + DATE_TYPE, dateFormat.format(value));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -281,6 +281,22 @@ public class DefaultJobParametersConverterTests {
|
||||
assertEquals("1.23", props.getProperty("double.key(double)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundTripWithIdentifyingAndNonIdentifying() throws Exception {
|
||||
|
||||
String[] args = new String[] { "schedule.date(date)=2008/01/23", "+job.key=myKey", "-vendor.id(long)=33243243",
|
||||
"double.key(double)=1.23" };
|
||||
|
||||
JobParameters parameters = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
|
||||
|
||||
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("1.23", props.getProperty("double.key(double)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundTripWithNumberFormat() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user