RESOLVED - BATCH-618: DefaultJobParametersConverter does not parse parameters of type double

This commit is contained in:
robokaso
2008-05-14 13:15:15 +00:00
parent b8cfd7339d
commit a2d92a7db0
2 changed files with 81 additions and 27 deletions

View File

@@ -101,7 +101,7 @@ public class DefaultJobParametersConverterTests extends TestCase {
}
}
public void testGetParametersWithDouble() throws Exception {
public void testGetParametersWithDoubleValueDeclaredAsLong() throws Exception {
String[] args = new String[] { "value(long)=1.03" };
factory.setNumberFormat(new DecimalFormat("#.#"));
@@ -114,6 +114,28 @@ public class DefaultJobParametersConverterTests extends TestCase {
assertTrue("Message should contain 'decimal': " + message, contains(message, "decimal"));
}
}
public void testGetParametersWithBogusDouble() throws Exception {
String[] args = new String[] { "value(double)=foo" };
try {
factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
} catch (IllegalArgumentException e) {
String message = e.getMessage();
assertTrue("Message should contain wrong number: " + message, contains(message, "foo"));
assertTrue("Message should contain format: " + message, contains(message, "#"));
}
}
public void testGetParametersWithDouble() throws Exception {
String[] args = new String[] { "value(double)=1.38" };
JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
assertNotNull(props);
assertEquals(1.38, props.getDouble("value").doubleValue(), Double.MIN_VALUE);
}
public void testGetProperties() throws Exception {