Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3883 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
4 changed files with 78 additions and 6 deletions
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
package org.springframework.core.convert.support; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.Vector; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.springframework.core.convert.TypeDescriptor; |
||||
|
||||
public class Spr7728Tests |
||||
{ |
||||
private CollectionToCollectionConverter theConverter; |
||||
private Vector<String> theSrcVector; |
||||
private TypeDescriptor theSrcType; |
||||
private TypeDescriptor theTargetType; |
||||
|
||||
@Before |
||||
public void setup() |
||||
{ |
||||
theSrcVector = new Vector<String>(); |
||||
theSrcType = TypeDescriptor.forObject(theSrcVector); |
||||
theTargetType = TypeDescriptor.forObject(new ArrayList()); |
||||
theConverter = new CollectionToCollectionConverter(new GenericConversionService()); |
||||
} |
||||
|
||||
@Test |
||||
public void convertEmptyVector_shouldReturnEmptyArrayList() |
||||
throws Exception |
||||
{ |
||||
theSrcVector.add("Element"); |
||||
|
||||
testCollectionConversionToArrayList(theSrcVector); |
||||
} |
||||
|
||||
@Test |
||||
public void convertNonEmptyVector_shouldReturnNonEmptyArrayList() |
||||
throws Exception |
||||
{ |
||||
testCollectionConversionToArrayList(theSrcVector); |
||||
} |
||||
|
||||
private void testCollectionConversionToArrayList(Collection<String> aSource) |
||||
{ |
||||
Object myConverted = theConverter.convert(aSource, theSrcType, theTargetType); |
||||
|
||||
Assert.assertTrue(myConverted instanceof ArrayList<?>); |
||||
Assert.assertEquals(aSource.size(), ((ArrayList<?>) myConverted).size()); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue