GenericConversionService.getConversionExecutor() now uses isAssignableFrom to detect situations where no conversion is necessary (SWF-264).
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.springframework.binding.convert.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -31,6 +33,23 @@ import org.springframework.core.enums.ShortCodedLabeledEnum;
|
||||
*/
|
||||
public class DefaultConversionServiceTests extends TestCase {
|
||||
|
||||
public void testConvertCompatibleTypes() {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addAlias("list", List.class);
|
||||
|
||||
List lst = new ArrayList();
|
||||
assertSame(lst, service.getConversionExecutor(ArrayList.class, List.class).execute(lst));
|
||||
assertSame(lst, service.getConversionExecutorByTargetAlias(ArrayList.class, "list").execute(lst));
|
||||
|
||||
try {
|
||||
service.getConversionExecutor(List.class, ArrayList.class);
|
||||
fail();
|
||||
}
|
||||
catch (ConversionException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testOverrideConverter() {
|
||||
Converter customConverter = new TextToBoolean("ja", "nee");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user