revised wrapper type handling

This commit is contained in:
Juergen Hoeller
2009-08-09 06:36:16 +00:00
parent d41344eb1f
commit 2d7c2d6fff
12 changed files with 111 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.core.convert;
import static junit.framework.Assert.assertEquals;
@@ -32,12 +33,6 @@ public class TypeDescriptorTests {
int[] intArray;
List<String>[] arrayOfListOfString;
@Test
public void testWrapperType() {
TypeDescriptor desc = TypeDescriptor.valueOf(int.class);
assertEquals(Integer.class, desc.getType());
}
@Test
public void listDescriptors() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfString"));

View File

@@ -136,7 +136,7 @@ public class GenericConversionServiceTests {
@Test
public void convertArrayToPrimitiveArray() {
converter.add(new StringToInteger());
int[] result = (int[]) converter.convert(new String[] { "1", "2", "3" }, int[].class);
int[] result = converter.convert(new String[] { "1", "2", "3" }, int[].class);
assertEquals(1, result[0]);
assertEquals(2, result[1]);
assertEquals(3, result[2]);
@@ -184,7 +184,7 @@ public class GenericConversionServiceTests {
list.add("1");
list.add("2");
list.add("3");
String[] result = (String[]) converter.convert(list, String[].class);
String[] result = converter.convert(list, String[].class);
assertEquals("1", result[0]);
assertEquals("2", result[1]);
assertEquals("3", result[2]);
@@ -229,15 +229,17 @@ public class GenericConversionServiceTests {
@Test
public void convertStringToArrayWithElementConversion() {
converter.add(new StringToInteger());
Integer[] result = (Integer[]) converter.convert("1,2,3", Integer[].class);
Integer[] result = converter.convert("1,2,3", Integer[].class);
assertEquals(3, result.length);
assertEquals(new Integer(1), result[0]);
assertEquals(new Integer(2), result[1]);
assertEquals(new Integer(3), result[2]);
}
public static enum FooEnum {
BAR, BAZ
}
}
}