Fixed regression with constructing TypeDescriptor from null Class

Issue: SPR-11354
This commit is contained in:
Juergen Hoeller
2014-01-24 13:16:35 +01:00
parent 42db41e007
commit eeae5fba95
2 changed files with 39 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -306,6 +306,28 @@ public class FormattingConversionServiceTests {
TypeDescriptor.valueOf(String.class));
}
@Test
public void testRegisterDefaultValueViaFormatter() {
registerDefaultValue(Date.class, new Date());
}
private <T> void registerDefaultValue(Class<T> clazz, final T defaultValue) {
formattingService.addFormatterForFieldType(clazz, new Formatter<T>() {
@Override
public T parse(String text, Locale locale) throws ParseException {
return defaultValue;
}
@Override
public String print(T t, Locale locale) {
return defaultValue.toString();
}
@Override
public String toString() {
return defaultValue.toString();
}
});
}
public static class ValueBean {