fixed failing tests
This commit is contained in:
parent
728a1415d9
commit
dc076ee6fe
|
|
@ -24,7 +24,6 @@ import java.lang.reflect.Field;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
|
||||||
|
|
@ -187,18 +187,19 @@ public class GenericFormatterRegistry implements FormatterRegistry, ApplicationC
|
||||||
if (formattedObjectType != null && !type.isAssignableFrom(formattedObjectType)) {
|
if (formattedObjectType != null && !type.isAssignableFrom(formattedObjectType)) {
|
||||||
if (this.conversionService == null) {
|
if (this.conversionService == null) {
|
||||||
throw new IllegalStateException("Unable to index Formatter " + formatter + " under type ["
|
throw new IllegalStateException("Unable to index Formatter " + formatter + " under type ["
|
||||||
+ type.getName() + "]; unable to convert from [" + formattedObjectType.getName()
|
+ type.getName() + "]; not able to convert from a [" + formattedObjectType.getName()
|
||||||
+ "] parsed by Formatter because this.conversionService is null");
|
+ "] parsed by the Formatter to [" + type.getName()
|
||||||
|
+ "] because this.conversionService is null");
|
||||||
}
|
}
|
||||||
if (!this.conversionService.canConvert(formattedObjectType, type)) {
|
if (!this.conversionService.canConvert(formattedObjectType, type)) {
|
||||||
throw new IllegalArgumentException("Unable to index Formatter " + formatter + " under type ["
|
throw new IllegalArgumentException("Unable to index Formatter " + formatter + " under type ["
|
||||||
+ type.getName() + "]; not able to convert from [" + formattedObjectType.getName()
|
+ type.getName() + "]; not able to convert from a [" + formattedObjectType.getName()
|
||||||
+ "] to parse");
|
+ "] parsed by the Formatter to [" + type.getName() + "]");
|
||||||
}
|
}
|
||||||
if (!this.conversionService.canConvert(type, formattedObjectType)) {
|
if (!this.conversionService.canConvert(type, formattedObjectType)) {
|
||||||
throw new IllegalArgumentException("Unable to index Formatter " + formatter + " under type ["
|
throw new IllegalArgumentException("Unable to index Formatter " + formatter + " under type ["
|
||||||
+ type.getName() + "]; not able to convert to [" + formattedObjectType.getName()
|
+ type.getName() + "]; not able to convert to [" + formattedObjectType.getName()
|
||||||
+ "] to format");
|
+ "] to format a [" + type.getName() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.typeFormatters.put(type, new FormatterHolder(formattedObjectType, formatter));
|
this.typeFormatters.put(type, new FormatterHolder(formattedObjectType, formatter));
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import org.springframework.beans.SimpleTypeConverter;
|
||||||
import org.springframework.beans.TypeConverter;
|
import org.springframework.beans.TypeConverter;
|
||||||
import org.springframework.beans.TypeMismatchException;
|
import org.springframework.beans.TypeMismatchException;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
import org.springframework.ui.format.FormatterRegistry;
|
import org.springframework.ui.format.FormatterRegistry;
|
||||||
import org.springframework.ui.format.support.FormattingConversionServiceAdapter;
|
import org.springframework.ui.format.support.FormattingConversionServiceAdapter;
|
||||||
import org.springframework.ui.format.support.GenericFormatterRegistry;
|
import org.springframework.ui.format.support.GenericFormatterRegistry;
|
||||||
|
|
@ -478,7 +479,9 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||||
*/
|
*/
|
||||||
public FormatterRegistry getFormatterRegistry() {
|
public FormatterRegistry getFormatterRegistry() {
|
||||||
if (this.formatterRegistry == null) {
|
if (this.formatterRegistry == null) {
|
||||||
this.formatterRegistry = new GenericFormatterRegistry();
|
GenericFormatterRegistry registry = new GenericFormatterRegistry();
|
||||||
|
registry.setConversionService(new DefaultConversionService());
|
||||||
|
this.formatterRegistry = registry;
|
||||||
}
|
}
|
||||||
else if (this.formatterRegistry instanceof GenericFormatterRegistry &&
|
else if (this.formatterRegistry instanceof GenericFormatterRegistry &&
|
||||||
((GenericFormatterRegistry) this.formatterRegistry).isShared()) {
|
((GenericFormatterRegistry) this.formatterRegistry).isShared()) {
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,8 @@ public class DataBinderTests extends TestCase {
|
||||||
|
|
||||||
private void doTestBindingWithDefaultFormatter(Object tb) {
|
private void doTestBindingWithDefaultFormatter(Object tb) {
|
||||||
DataBinder binder = new DataBinder(tb);
|
DataBinder binder = new DataBinder(tb);
|
||||||
binder.setFormatterRegistry(new GenericFormatterRegistry());
|
// force formatter registry to be created
|
||||||
|
binder.getFormatterRegistry();
|
||||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||||
pvs.addPropertyValue("number", "1,2");
|
pvs.addPropertyValue("number", "1,2");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue