Author: davidb Date: Fri Jul 29 01:08:41 2016 New Revision: 1754473 URL: http://svn.apache.org/viewvc?rev=1754473&view=rev Log: Use standard ConverterFactory.standardConverter() to obtain converter instance.
This fixes a number of failing tests which I have now uncommented. Modified: felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java Modified: felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java URL: http://svn.apache.org/viewvc/felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java?rev=1754473&r1=1754472&r2=1754473&view=diff ============================================================================== --- felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java (original) +++ felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java Fri Jul 29 01:08:41 2016 @@ -18,11 +18,6 @@ */ package org.apache.felix.configurator.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.lang.reflect.Array; import java.util.Collection; @@ -30,14 +25,19 @@ import java.util.Map; import org.apache.felix.configurator.impl.yaml.YAMLUtil; import org.apache.felix.configurator.impl.yaml.YAMLUtilTest; -import org.apache.felix.converter.impl.ConverterImpl; import org.junit.Before; import org.junit.Test; +import org.osgi.service.converter.util.ConverterFactory; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class TypeConverterTest { @Before public void setup() { - TypeConverter.setConverter(new ConverterImpl()); + TypeConverter.setConverter(ConverterFactory.standardConverter()); } @Test public void testStringConversionNoTypeInfo() throws IOException { @@ -163,9 +163,8 @@ public class TypeConverterTest { assertTrue(converter.convert(properties.get("number"), "byte") instanceof Byte); assertTrue(converter.convert(properties.get("number"), "Short") instanceof Short); assertTrue(converter.convert(properties.get("number"), "short") instanceof Short); -// TODO - wait for converter fix -// assertTrue(converter.convert(properties.get("string"), "Character") instanceof Character); -// assertTrue(converter.convert(properties.get("string"), "char") instanceof Character); + assertTrue(converter.convert(properties.get("string"), "Character") instanceof Character); + assertTrue(converter.convert(properties.get("string"), "char") instanceof Character); // arrays assertTrue(converter.convert(properties.get("string.array"), "String[]").getClass().isArray()); @@ -191,9 +190,8 @@ public class TypeConverterTest { assertNotNull(a5); short[] a6 = (short[])converter.convert(properties.get("number.array"), "short[]"); assertNotNull(a6); -// TODO - wait for converter fix -// char[] a7 = (char[])converter.convert(properties.get("string.array"), "char[]"); -// assertNotNull(a7); + char[] a7 = (char[])converter.convert(properties.get("string.array"), "char[]"); + assertNotNull(a7); assertTrue(converter.convert(properties.get("number.array"), "Integer[]").getClass().isArray()); assertTrue(Array.get(converter.convert(properties.get("number.array"), "Integer[]"), 0) instanceof Integer); @@ -220,9 +218,8 @@ public class TypeConverterTest { assertTrue(Array.get(converter.convert(properties.get("float.array"), "Double[]"), 1) instanceof Double); assertTrue(converter.convert(properties.get("string.array"), "Character[]").getClass().isArray()); -// TODO - wait for converter fix -// assertTrue(Array.get(converter.convert(properties.get("string.array"), "Character[]"), 0) instanceof Character); -// assertTrue(Array.get(converter.convert(properties.get("string.array"), "Character[]"), 1) instanceof Character); + assertTrue(Array.get(converter.convert(properties.get("string.array"), "Character[]"), 0) instanceof Character); + assertTrue(Array.get(converter.convert(properties.get("string.array"), "Character[]"), 1) instanceof Character); } @SuppressWarnings("unchecked") @@ -254,8 +251,7 @@ public class TypeConverterTest { assertTrue(((Collection<Byte>)converter.convert(properties.get("number.array"), "Collection<Byte>")).iterator().next() instanceof Byte); assertTrue(converter.convert(properties.get("string.array"), "Collection<Character>") instanceof Collection<?>); -// TODO - wait for converter fix -// assertTrue(((Collection<Character>)converter.convert(properties.get("string.array"), "Collection<Character>")).iterator().next() instanceof Character); + assertTrue(((Collection<Character>)converter.convert(properties.get("string.array"), "Collection<Character>")).iterator().next() instanceof Character); assertTrue(converter.convert(properties.get("boolean.array"), "Collection<Boolean>") instanceof Collection<?>); assertTrue(((Collection<Boolean>)converter.convert(properties.get("boolean.array"), "Collection<Boolean>")).iterator().next() instanceof Boolean);