From 3bb17974d84a300f6e7fac6f0d37eacccf089e6e Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Fri, 7 Jan 2011 15:27:29 +0000 Subject: [PATCH] empty collection test refinements --- .../GenericConversionServiceTests.java | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/org.springframework.core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/org.springframework.core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index 9f8c61dc97..cbe398d945 100644 --- a/org.springframework.core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/org.springframework.core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -270,26 +270,6 @@ public class GenericConversionServiceTests { assertNotNull(service.convert(list, String.class)); } - @Test - public void testEmptyList() { - GenericConversionService service = ConversionServiceFactory.createDefaultConversionService(); - List list = Collections.emptyList(); - List result = service.convert(list, List.class); - assertSame(list, result); - result = service.convert(list, list.getClass()); - assertSame(list, result); - } - - @Test - public void testEmptyMap() { - GenericConversionService service = ConversionServiceFactory.createDefaultConversionService(); - Map map = Collections.emptyMap(); - Map result = service.convert(map, Map.class); - assertSame(map, result); - result = service.convert(map, map.getClass()); - assertSame(map, result); - } - @Test public void testStringToString() { GenericConversionService service = ConversionServiceFactory.createDefaultConversionService(); @@ -407,7 +387,9 @@ public class GenericConversionServiceTests { TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListDifferentTarget")); assertTrue(conversionService.canConvert(sourceType, targetType)); - assertEquals(LinkedList.class, conversionService.convert(list, sourceType, targetType).getClass()); + LinkedList result = (LinkedList) conversionService.convert(list, sourceType, targetType); + assertEquals(LinkedList.class, result.getClass()); + assertTrue(result.isEmpty()); } public LinkedList emptyListDifferentTarget; @@ -455,10 +437,12 @@ public class GenericConversionServiceTests { TypeDescriptor sourceType = TypeDescriptor.forObject(map); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapDifferentTarget")); assertTrue(conversionService.canConvert(sourceType, targetType)); - assertEquals(map, conversionService.convert(map, sourceType, targetType)); + LinkedHashMap result = (LinkedHashMap) conversionService.convert(map, sourceType, targetType); + assertEquals(map, result); + assertEquals(LinkedHashMap.class, result.getClass()); } - public Map emptyMapDifferentTarget; + public LinkedHashMap emptyMapDifferentTarget; private interface MyBaseInterface {