489688:  BlueprintCustomCollectionEditor fails to convert non-collection values

Adapted the behavior of the BlueprintCustomCollectionEditor to
match the behavior of the super class, the default
CustomCollectionEditor. Adapted test cases to reflect
the desired behavior.
(cherry picked from commit a717f4b)
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java
index 51273cb..abd031e 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java
@@ -32,7 +32,7 @@
 import org.springframework.core.convert.TypeDescriptor;

 

 /**

- * OSGi 4.2 Blueprint converter adapter as an Spring 3.0 ConverterService.

+ * OSGi 4.2 Blueprint converter adapter as an Spring 4.0 ConverterService.

  * 

  * @author Costin Leau

  */

diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintEditorRegistrar.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintEditorRegistrar.java
index 0c5e586..05621f5 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintEditorRegistrar.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintEditorRegistrar.java
@@ -63,15 +63,6 @@
 			super(collectionType);

 		}

 

-		@Override

-		public void setValue(Object value) {

-			if (value != null && (!(value instanceof Collection)) && (!value.getClass().isArray())) {

-				throw new IllegalArgumentException("Cannot create collection from type " + value.getClass()

-						+ " of instance " + value);

-			}

-			super.setValue(value);

-		}

-

 		@SuppressWarnings("unchecked")

 		@Override

 		protected Collection createCollection(Class collectionType, int initialCapacity) {

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/blueprint/config/TypeConverterTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/blueprint/config/TypeConverterTest.java
index 6a18d56..e90c358 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/blueprint/config/TypeConverterTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/blueprint/config/TypeConverterTest.java
@@ -29,6 +29,11 @@
 import org.springframework.core.io.ClassPathResource;

 import org.springframework.util.ObjectUtils;

 

+import java.util.Collection;

+import java.util.List;

+

+import static org.fest.assertions.Assertions.assertThat;

+

 /**

  * @author Costin Leau

  * 

@@ -102,19 +107,17 @@
 		assertNotNull(comp.getServiceReference());

 	}

 

-	public void testInvalidInjection1() throws Exception {

-		try {

-			TestComponent comp = (TestComponent) context.getBean("invalidInjection1");

-			fail("expected exception");

-		} catch (Exception ex) {

-		}

+	public void testObjectToCollectionConversion1() throws Exception {

+		TestComponent comp = (TestComponent) context.getBean("objectToCollectionConversion1");

+		Object propA = comp.getPropA();

+		assertThat(propA).isInstanceOf(List.class);

+		assertThat((List) propA).hasSize(1);

 	}

 

-	public void testInvalidInjection2() throws Exception {

-		try {

-			TestComponent comp = (TestComponent) context.getBean("invalidInjection2");

-			fail("expected exception");

-		} catch (Exception ex) {

-		}

+	public void testObjectToCollectionConversion2() throws Exception {

+		TestComponent comp = (TestComponent) context.getBean("objectToCollectionConversion2");

+		Object propA = comp.getPropA();

+		assertThat(propA).isInstanceOf(List.class);

+		assertThat((List) propA).hasSize(1);

 	}

 }
\ No newline at end of file
diff --git a/core/src/test/resources/org/eclipse/gemini/blueprint/blueprint/config/type-converters.xml b/core/src/test/resources/org/eclipse/gemini/blueprint/blueprint/config/type-converters.xml
index e148bfd..3fafbc7 100644
--- a/core/src/test/resources/org/eclipse/gemini/blueprint/blueprint/config/type-converters.xml
+++ b/core/src/test/resources/org/eclipse/gemini/blueprint/blueprint/config/type-converters.xml
@@ -59,7 +59,7 @@
 	

 	<bean id="referenceFactory" class="org.eclipse.gemini.blueprint.blueprint.ReferenceDelegateFactory"/>

 	

-	<bean id="invalidInjection1" class="org.eclipse.gemini.blueprint.blueprint.TestComponent" activation="lazy">

+	<bean id="objectToCollectionConversion1" class="org.eclipse.gemini.blueprint.blueprint.TestComponent" activation="lazy">

 		<property name="list">

 			<map>

 				<entry key="foo">

@@ -69,7 +69,7 @@
 		</property>

 	</bean>

 

-	<bean id="invalidInjection2" class="org.eclipse.gemini.blueprint.blueprint.TestComponent" activation="lazy">

+	<bean id="objectToCollectionConversion2" class="org.eclipse.gemini.blueprint.blueprint.TestComponent" activation="lazy">

 		<property name="collection">

 			<ref component-id="referenceFactory"/>

 		</property>