BindingPoint to ConversionPoint, javadoc
This commit is contained in:
@@ -26,7 +26,7 @@ import org.junit.Test;
|
||||
/**
|
||||
* @author Andy Clement
|
||||
*/
|
||||
public class TypeDescriptorTests {
|
||||
public class ConversionPointTests {
|
||||
|
||||
List<String> listOfString;
|
||||
int[] intArray;
|
||||
@@ -34,13 +34,13 @@ public class TypeDescriptorTests {
|
||||
|
||||
@Test
|
||||
public void testWrapperType() {
|
||||
BindingPoint desc = BindingPoint.valueOf(int.class);
|
||||
ConversionPoint desc = ConversionPoint.valueOf(int.class);
|
||||
assertEquals(Integer.class, desc.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listDescriptors() throws Exception {
|
||||
BindingPoint typeDescriptor = new BindingPoint(TypeDescriptorTests.class.getDeclaredField("listOfString"));
|
||||
ConversionPoint typeDescriptor = new ConversionPoint(ConversionPointTests.class.getDeclaredField("listOfString"));
|
||||
assertFalse(typeDescriptor.isArray());
|
||||
assertEquals(List.class,typeDescriptor.getType());
|
||||
assertEquals(String.class,typeDescriptor.getElementType());
|
||||
@@ -50,7 +50,7 @@ public class TypeDescriptorTests {
|
||||
|
||||
@Test
|
||||
public void arrayTypeDescriptors() throws Exception {
|
||||
BindingPoint typeDescriptor = new BindingPoint(TypeDescriptorTests.class.getDeclaredField("intArray"));
|
||||
ConversionPoint typeDescriptor = new ConversionPoint(ConversionPointTests.class.getDeclaredField("intArray"));
|
||||
assertTrue(typeDescriptor.isArray());
|
||||
assertEquals(Integer.TYPE,typeDescriptor.getElementType());
|
||||
assertEquals("int[]",typeDescriptor.asString());
|
||||
@@ -58,14 +58,14 @@ public class TypeDescriptorTests {
|
||||
|
||||
@Test
|
||||
public void buildingArrayTypeDescriptors() throws Exception {
|
||||
BindingPoint typeDescriptor = new BindingPoint(new int[0].getClass());
|
||||
ConversionPoint typeDescriptor = new ConversionPoint(new int[0].getClass());
|
||||
assertTrue(typeDescriptor.isArray());
|
||||
assertEquals(Integer.TYPE,typeDescriptor.getElementType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complexTypeDescriptors() throws Exception {
|
||||
BindingPoint typeDescriptor = new BindingPoint(TypeDescriptorTests.class.getDeclaredField("arrayOfListOfString"));
|
||||
ConversionPoint typeDescriptor = new ConversionPoint(ConversionPointTests.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
|
||||
@@ -3,7 +3,7 @@ package org.springframework.core.convert.support;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.support.ArrayToArray;
|
||||
import org.springframework.core.convert.support.DefaultTypeConverter;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ArrayToArrayTests {
|
||||
@Test
|
||||
public void testArrayToArrayConversion() {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToArray c = new ArrayToArray(BindingPoint.valueOf(String[].class), BindingPoint.valueOf(Integer[].class), service);
|
||||
ArrayToArray c = new ArrayToArray(ConversionPoint.valueOf(String[].class), ConversionPoint.valueOf(Integer[].class), service);
|
||||
Integer[] result = (Integer[]) c.execute(new String[] { "1", "2", "3" });
|
||||
assertEquals(new Integer(1), result[0]);
|
||||
assertEquals(new Integer(2), result[1]);
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.support.ArrayToCollection;
|
||||
import org.springframework.core.convert.support.DefaultTypeConverter;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ArrayToCollectionTests {
|
||||
@Test
|
||||
public void testArrayToCollectionConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToCollection c = new ArrayToCollection(BindingPoint.valueOf(String[].class), new BindingPoint(getClass().getField("bindTarget")), service);
|
||||
ArrayToCollection c = new ArrayToCollection(ConversionPoint.valueOf(String[].class), new ConversionPoint(getClass().getField("bindTarget")), service);
|
||||
List result = (List) c.execute(new String[] { "1", "2", "3" });
|
||||
assertEquals(new Integer(1), result.get(0));
|
||||
assertEquals(new Integer(2), result.get(1));
|
||||
@@ -28,7 +28,7 @@ public class ArrayToCollectionTests {
|
||||
@Test
|
||||
public void testArrayToSetConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToCollection c = new ArrayToCollection(BindingPoint.valueOf(String[].class), new BindingPoint(getClass().getField("setTarget")), service);
|
||||
ArrayToCollection c = new ArrayToCollection(ConversionPoint.valueOf(String[].class), new ConversionPoint(getClass().getField("setTarget")), service);
|
||||
Set result = (Set) c.execute(new String[] { "1" });
|
||||
assertEquals("1", result.iterator().next());
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class ArrayToCollectionTests {
|
||||
@Test
|
||||
public void testArrayToSortedSetConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToCollection c = new ArrayToCollection(BindingPoint.valueOf(String[].class), new BindingPoint(getClass().getField("sortedSetTarget")), service);
|
||||
ArrayToCollection c = new ArrayToCollection(ConversionPoint.valueOf(String[].class), new ConversionPoint(getClass().getField("sortedSetTarget")), service);
|
||||
SortedSet result = (SortedSet) c.execute(new String[] { "1" });
|
||||
assertEquals(new Integer(1), result.iterator().next());
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class ArrayToCollectionTests {
|
||||
@Test
|
||||
public void testArrayToCollectionImplConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToCollection c = new ArrayToCollection(BindingPoint.valueOf(String[].class), new BindingPoint(getClass().getField("implTarget")), service);
|
||||
ArrayToCollection c = new ArrayToCollection(ConversionPoint.valueOf(String[].class), new ConversionPoint(getClass().getField("implTarget")), service);
|
||||
LinkedList result = (LinkedList) c.execute(new String[] { "1" });
|
||||
assertEquals("1", result.iterator().next());
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class ArrayToCollectionTests {
|
||||
@Test
|
||||
public void testArrayToNonGenericCollectionConversionNullElement() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
ArrayToCollection c = new ArrayToCollection(BindingPoint.valueOf(String[].class), new BindingPoint(getClass().getField("listTarget")), service);
|
||||
ArrayToCollection c = new ArrayToCollection(ConversionPoint.valueOf(String[].class), new ConversionPoint(getClass().getField("listTarget")), service);
|
||||
List result = (List) c.execute(new Integer[] { null, new Integer(1) });
|
||||
assertEquals(null, result.get(0));
|
||||
assertEquals(new Integer(1), result.get(1));
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.support.CollectionToArray;
|
||||
import org.springframework.core.convert.support.DefaultTypeConverter;
|
||||
|
||||
@@ -15,8 +15,8 @@ public class CollectionToArrayTests {
|
||||
@Test
|
||||
public void testCollectionToArrayConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToArray c = new CollectionToArray(new BindingPoint(getClass().getField("bindTarget")),
|
||||
BindingPoint.valueOf(Integer[].class), service);
|
||||
CollectionToArray c = new CollectionToArray(new ConversionPoint(getClass().getField("bindTarget")),
|
||||
ConversionPoint.valueOf(Integer[].class), service);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
bindTarget.add("3");
|
||||
@@ -29,7 +29,7 @@ public class CollectionToArrayTests {
|
||||
@Test
|
||||
public void testCollectionToArrayConversionNoGenericInfo() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToArray c = new CollectionToArray(BindingPoint.valueOf(Collection.class), BindingPoint
|
||||
CollectionToArray c = new CollectionToArray(ConversionPoint.valueOf(Collection.class), ConversionPoint
|
||||
.valueOf(Integer[].class), service);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
@@ -43,7 +43,7 @@ public class CollectionToArrayTests {
|
||||
@Test
|
||||
public void testCollectionToArrayConversionNoGenericInfoNullElement() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToArray c = new CollectionToArray(BindingPoint.valueOf(Collection.class), BindingPoint
|
||||
CollectionToArray c = new CollectionToArray(ConversionPoint.valueOf(Collection.class), ConversionPoint
|
||||
.valueOf(Integer[].class), service);
|
||||
bindTarget.add(null);
|
||||
bindTarget.add("1");
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.support.CollectionToCollection;
|
||||
import org.springframework.core.convert.support.DefaultTypeConverter;
|
||||
|
||||
@@ -17,8 +17,8 @@ public class CollectionToCollectionTests {
|
||||
@Test
|
||||
public void testCollectionToCollectionConversion() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToCollection c = new CollectionToCollection(new BindingPoint(getClass().getField("bindTarget")),
|
||||
new BindingPoint(getClass().getField("integerTarget")), service);
|
||||
CollectionToCollection c = new CollectionToCollection(new ConversionPoint(getClass().getField("bindTarget")),
|
||||
new ConversionPoint(getClass().getField("integerTarget")), service);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
bindTarget.add("3");
|
||||
@@ -31,8 +31,8 @@ public class CollectionToCollectionTests {
|
||||
@Test
|
||||
public void testCollectionToCollectionConversionNoGenericInfo() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToCollection c = new CollectionToCollection(BindingPoint.valueOf(Collection.class),
|
||||
BindingPoint.valueOf(List.class), service);
|
||||
CollectionToCollection c = new CollectionToCollection(ConversionPoint.valueOf(Collection.class),
|
||||
ConversionPoint.valueOf(List.class), service);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
bindTarget.add("3");
|
||||
@@ -45,8 +45,8 @@ public class CollectionToCollectionTests {
|
||||
@Test
|
||||
public void testCollectionToCollectionConversionNoGenericInfoSource() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToCollection c = new CollectionToCollection(BindingPoint.valueOf(Collection.class),
|
||||
new BindingPoint(getClass().getField("integerTarget")), service);
|
||||
CollectionToCollection c = new CollectionToCollection(ConversionPoint.valueOf(Collection.class),
|
||||
new ConversionPoint(getClass().getField("integerTarget")), service);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
bindTarget.add("3");
|
||||
@@ -59,8 +59,8 @@ public class CollectionToCollectionTests {
|
||||
@Test
|
||||
public void testCollectionToCollectionConversionNoGenericInfoSourceNullValues() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToCollection c = new CollectionToCollection(BindingPoint.valueOf(Collection.class),
|
||||
new BindingPoint(getClass().getField("integerTarget")), service);
|
||||
CollectionToCollection c = new CollectionToCollection(ConversionPoint.valueOf(Collection.class),
|
||||
new ConversionPoint(getClass().getField("integerTarget")), service);
|
||||
bindTarget.add(null);
|
||||
bindTarget.add("1");
|
||||
bindTarget.add("2");
|
||||
@@ -77,8 +77,8 @@ public class CollectionToCollectionTests {
|
||||
@Test
|
||||
public void testCollectionToCollectionConversionNoGenericInfoSourceEmpty() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
CollectionToCollection c = new CollectionToCollection(BindingPoint.valueOf(Collection.class),
|
||||
new BindingPoint(getClass().getField("integerTarget")), service);
|
||||
CollectionToCollection c = new CollectionToCollection(ConversionPoint.valueOf(Collection.class),
|
||||
new ConversionPoint(getClass().getField("integerTarget")), service);
|
||||
List result = (List) c.execute(bindTarget);
|
||||
assertTrue(result.isEmpty());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConverterNotFoundException;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
@@ -156,7 +156,7 @@ public class GenericTypeConverterTests {
|
||||
@Test
|
||||
public void convertArrayToListGenericTypeConversion() throws Exception {
|
||||
converter.addConverter(new StringToInteger());
|
||||
List<Integer> result = converter.convert(new String[] { "1", "2", "3" }, new BindingPoint<List<Integer>>(getClass().getDeclaredField("genericList")));
|
||||
List<Integer> result = converter.convert(new String[] { "1", "2", "3" }, new ConversionPoint<List<Integer>>(getClass().getDeclaredField("genericList")));
|
||||
assertEquals(new Integer("1"), result.get(0));
|
||||
assertEquals(new Integer("2"), result.get(1));
|
||||
assertEquals(new Integer("3"), result.get(2));
|
||||
@@ -214,7 +214,7 @@ public class GenericTypeConverterTests {
|
||||
foo.put("2", "BAZ");
|
||||
converter.addConverter(new StringToInteger());
|
||||
converter.addConverter(new StringToEnumFactory().getConverter(FooEnum.class));
|
||||
Map<String, FooEnum> map = converter.convert(foo, new BindingPoint<Map<String, FooEnum>>(getClass().getField("genericMap")));
|
||||
Map<String, FooEnum> map = converter.convert(foo, new ConversionPoint<Map<String, FooEnum>>(getClass().getField("genericMap")));
|
||||
assertEquals(map.get(1), FooEnum.BAR);
|
||||
assertEquals(map.get(2), FooEnum.BAZ);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.BindingPoint;
|
||||
import org.springframework.core.convert.ConversionPoint;
|
||||
import org.springframework.core.convert.support.DefaultTypeConverter;
|
||||
import org.springframework.core.convert.support.MapToMap;
|
||||
|
||||
@@ -15,8 +15,8 @@ public class MapToMapTests {
|
||||
@Test
|
||||
public void testMapToMapConversion() throws Exception {
|
||||
DefaultTypeConverter converter = new DefaultTypeConverter();
|
||||
MapToMap c = new MapToMap(new BindingPoint<Map<String, String>>(getClass().getField("source")),
|
||||
new BindingPoint<Map<String, FooEnum>>(getClass().getField("bindTarget")), converter);
|
||||
MapToMap c = new MapToMap(new ConversionPoint<Map<String, String>>(getClass().getField("source")),
|
||||
new ConversionPoint<Map<String, FooEnum>>(getClass().getField("bindTarget")), converter);
|
||||
source.put("1", "BAR");
|
||||
source.put("2", "BAZ");
|
||||
Map<String, FooEnum> result = (Map<String, FooEnum>) c.execute(source);
|
||||
@@ -27,8 +27,8 @@ public class MapToMapTests {
|
||||
@Test
|
||||
public void testMapToMapConversionNoGenericInfoOnSource() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
MapToMap c = new MapToMap(BindingPoint.valueOf(Map.class),
|
||||
new BindingPoint(getClass().getField("bindTarget")), service);
|
||||
MapToMap c = new MapToMap(ConversionPoint.valueOf(Map.class),
|
||||
new ConversionPoint(getClass().getField("bindTarget")), service);
|
||||
source.put("1", "BAR");
|
||||
source.put("2", "BAZ");
|
||||
Map result = (Map) c.execute(source);
|
||||
@@ -39,8 +39,8 @@ public class MapToMapTests {
|
||||
@Test
|
||||
public void testMapToMapConversionNoGenericInfo() throws Exception {
|
||||
DefaultTypeConverter service = new DefaultTypeConverter();
|
||||
MapToMap c = new MapToMap(BindingPoint.valueOf(Map.class),
|
||||
BindingPoint.valueOf(Map.class), service);
|
||||
MapToMap c = new MapToMap(ConversionPoint.valueOf(Map.class),
|
||||
ConversionPoint.valueOf(Map.class), service);
|
||||
source.put("1", "BAR");
|
||||
source.put("2", "BAZ");
|
||||
Map result = (Map) c.execute(source);
|
||||
|
||||
Reference in New Issue
Block a user