Polishing
This commit is contained in:
@@ -57,11 +57,13 @@ import static org.junit.Assert.*;
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
* @author Phillip Webb
|
||||
* @author David Haraburda
|
||||
*/
|
||||
public class GenericConversionServiceTests {
|
||||
|
||||
private GenericConversionService conversionService = new GenericConversionService();
|
||||
|
||||
|
||||
@Test
|
||||
public void canConvert() {
|
||||
assertFalse(conversionService.canConvert(String.class, Integer.class));
|
||||
@@ -749,6 +751,13 @@ public class GenericConversionServiceTests {
|
||||
assertEquals("A", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubclassOfEnumToString() throws Exception {
|
||||
conversionService.addConverter(new EnumToStringConverter(conversionService));
|
||||
String result = conversionService.convert(EnumWithSubclass.FIRST, String.class);
|
||||
assertEquals("FIRST", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumWithInterfaceToStringConversion() {
|
||||
// SPR-9692
|
||||
@@ -850,6 +859,7 @@ public class GenericConversionServiceTests {
|
||||
@ExampleAnnotation
|
||||
public String annotatedString;
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface ExampleAnnotation {
|
||||
}
|
||||
@@ -892,8 +902,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(Object source, TypeDescriptor sourceType,
|
||||
TypeDescriptor targetType) {
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -936,6 +945,7 @@ public class GenericConversionServiceTests {
|
||||
String getCode();
|
||||
}
|
||||
|
||||
|
||||
public static enum MyEnum implements MyEnumInterface {
|
||||
|
||||
A {
|
||||
@@ -947,6 +957,17 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
|
||||
|
||||
public enum EnumWithSubclass {
|
||||
|
||||
FIRST {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1st";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyStringToRawCollectionConverter implements Converter<String, Collection> {
|
||||
|
||||
@Override
|
||||
@@ -955,6 +976,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyStringToGenericCollectionConverter implements Converter<String, Collection<?>> {
|
||||
|
||||
@Override
|
||||
@@ -963,6 +985,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MyEnumInterfaceToStringConverter<T extends MyEnumInterface> implements Converter<T, String> {
|
||||
|
||||
@Override
|
||||
@@ -971,6 +994,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyStringToStringCollectionConverter implements Converter<String, Collection<String>> {
|
||||
|
||||
@Override
|
||||
@@ -979,6 +1003,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyStringToIntegerCollectionConverter implements Converter<String, Collection<Integer>> {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user