From 4a7f7bb24aaf641296c5f1c4cb79b611280bbca7 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 8 Apr 2009 04:48:35 +0000 Subject: [PATCH] more tests --- .../core/convert/TypeDescriptorTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/org.springframework.core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java b/org.springframework.core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java index a7574369d6..3408a4497c 100644 --- a/org.springframework.core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java +++ b/org.springframework.core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java @@ -24,20 +24,33 @@ import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; +import static org.junit.Assert.assertFalse; /** * @author Andy Clement */ public class TypeDescriptorTests { + List listOfString; int[] intArray; List[] arrayOfListOfString; + + @Test + public void listDescriptors() throws Exception { + TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfString")); + assertFalse(typeDescriptor.isArray()); + assertEquals(List.class,typeDescriptor.getType()); + assertEquals(String.class,typeDescriptor.getElementType()); + // TODO caught shorten these names but it is OK that they are fully qualified for now + assertEquals("java.util.List",typeDescriptor.asString()); + } @Test public void arrayTypeDescriptors() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("intArray")); assertTrue(typeDescriptor.isArray()); assertEquals(Integer.TYPE,typeDescriptor.getElementType()); + assertEquals("int[]",typeDescriptor.asString()); } @Test @@ -52,6 +65,8 @@ public class TypeDescriptorTests { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("arrayOfListOfString")); assertTrue(typeDescriptor.isArray()); assertEquals(List.class,typeDescriptor.getElementType()); + // TODO asc notice that the type of the list elements is lost: typeDescriptor.getElementType() should return a TypeDescriptor + assertEquals("java.util.List[]",typeDescriptor.asString()); } }