GenericConversionService.getConversionExecutor() now uses isAssignableFrom to detect situations where no conversion is necessary (SWF-264).

This commit is contained in:
Erwin Vervaet
2007-03-21 19:58:25 +00:00
parent 544ddbcda5
commit b1d2487d5a
2 changed files with 20 additions and 1 deletions

View File

@@ -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");