SPR-6350
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.format.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
@@ -99,6 +100,39 @@ public class FormattingConversionServiceTests {
|
||||
new TypeDescriptor(Model.class.getField("date"))));
|
||||
assertEquals(new LocalDate(2009, 10, 31), date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrintNull() throws ParseException {
|
||||
formattingService.addFormatterForFieldType(Number.class, new NumberFormatter());
|
||||
assertEquals("", formattingService.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseNull() throws ParseException {
|
||||
formattingService.addFormatterForFieldType(Number.class, new NumberFormatter());
|
||||
assertNull(formattingService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseEmptyString() throws ParseException {
|
||||
formattingService.addFormatterForFieldType(Number.class, new NumberFormatter());
|
||||
assertNull(formattingService.convert("", TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrintNullDefault() throws ParseException {
|
||||
assertEquals(null, formattingService.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseNullDefault() throws ParseException {
|
||||
assertNull(formattingService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseEmptyStringDefault() throws ParseException {
|
||||
assertNull(formattingService.convert("", TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
|
||||
}
|
||||
|
||||
private static class Model {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user