felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1751626 - in /felix/sandbox/cziegeler/configurator: ./ src/main/java/org/apache/felix/configurator/impl/ src/main/java/org/apache/felix/configurator/impl/yaml/ src/test/java/org/apache/felix/configurator/impl/
Date Wed, 06 Jul 2016 08:40:49 GMT
Author: cziegeler
Date: Wed Jul  6 08:40:49 2016
New Revision: 1751626

URL: http://svn.apache.org/viewvc?rev=1751626&view=rev
Log:
Update to latest config admin version

Modified:
    felix/sandbox/cziegeler/configurator/pom.xml
    felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
    felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/yaml/YAMLUtil.java
    felix/sandbox/cziegeler/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java

Modified: felix/sandbox/cziegeler/configurator/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/configurator/pom.xml?rev=1751626&r1=1751625&r2=1751626&view=diff
==============================================================================
--- felix/sandbox/cziegeler/configurator/pom.xml (original)
+++ felix/sandbox/cziegeler/configurator/pom.xml Wed Jul  6 08:40:49 2016
@@ -102,7 +102,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.configadmin</artifactId>
-            <version>1.8.9-R7-SNAPSHOT</version>
+            <version>1.8.11-R7-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java?rev=1751626&r1=1751625&r2=1751626&view=diff
==============================================================================
--- felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
(original)
+++ felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
Wed Jul  6 08:40:49 2016
@@ -52,11 +52,10 @@ public class TypeConverter {
      * Convert a value to the given type
      * @param value The value
      * @param typeInfo Optional type info, might be {@code null}
-     * @return The converted value (never returns null)
+     * @return The converted value or {@code null} if the conversion failed.
      * @throws IOException If an error happens
      */
     public Object convert(final Object value,
-            final Object defaultValue,
             final String typeInfo) throws IOException {
         if ( typeInfo == null ) {
             if ( value instanceof String || value instanceof Boolean ) {
@@ -80,16 +79,16 @@ public class TypeConverter {
                 }
                 final Object firstObject = list.get(0);
                 if ( firstObject instanceof String ) {
-                    return getConverter().convert(list).defaultValue(defaultValue).to(String[].class);
+                    return getConverter().convert(list).defaultValue(null).to(String[].class);
                 } else if ( firstObject instanceof Boolean ) {
-                    return getConverter().convert(list).defaultValue(defaultValue).to(Boolean[].class);
+                    return getConverter().convert(list).defaultValue(null).to(Boolean[].class);
                 } else if ( firstObject instanceof Long || firstObject instanceof Integer
) {
-                    return getConverter().convert(list).defaultValue(defaultValue).to(Long[].class);
+                    return getConverter().convert(list).defaultValue(null).to(Long[].class);
                 } else if ( firstObject instanceof Double || firstObject instanceof Float
) {
-                    return getConverter().convert(list).defaultValue(defaultValue).to(Double[].class);
+                    return getConverter().convert(list).defaultValue(null).to(Double[].class);
                 }
             }
-            return defaultValue;
+            return null;
         }
 
         // binary
@@ -134,114 +133,114 @@ public class TypeConverter {
 
         // scalar types and primitive types
         if ( "String".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(String.class);
+            return getConverter().convert(value).defaultValue(null).to(String.class);
 
         } else if ( "Integer".equals(typeInfo) || "int".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Integer.class);
+            return getConverter().convert(value).defaultValue(null).to(Integer.class);
 
         } else if ( "Long".equals(typeInfo) || "long".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Long.class);
+            return getConverter().convert(value).defaultValue(null).to(Long.class);
 
         } else if ( "Float".equals(typeInfo) || "float".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Float.class);
+            return getConverter().convert(value).defaultValue(null).to(Float.class);
 
         } else if ( "Double".equals(typeInfo) || "double".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Double.class);
+            return getConverter().convert(value).defaultValue(null).to(Double.class);
 
         } else if ( "Byte".equals(typeInfo) || "byte".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Byte.class);
+            return getConverter().convert(value).defaultValue(null).to(Byte.class);
 
         } else if ( "Short".equals(typeInfo) || "short".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Short.class);
+            return getConverter().convert(value).defaultValue(null).to(Short.class);
 
         } else if ( "Character".equals(typeInfo) || "char".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Character.class);
+            return getConverter().convert(value).defaultValue(null).to(Character.class);
 
         } else if ( "Boolean".equals(typeInfo) || "boolean".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Boolean.class);
+            return getConverter().convert(value).defaultValue(null).to(Boolean.class);
 
         }
 
         // array of scalar types and primitive types
         if ( "String[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(String[].class);
+            return getConverter().convert(value).defaultValue(null).to(String[].class);
 
         } else if ( "Integer[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Integer[].class);
+            return getConverter().convert(value).defaultValue(null).to(Integer[].class);
 
         } else if ( "int[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(int[].class);
+            return getConverter().convert(value).defaultValue(null).to(int[].class);
 
         } else if ( "Long[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Long[].class);
+            return getConverter().convert(value).defaultValue(null).to(Long[].class);
 
         } else if ( "long[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(long[].class);
+            return getConverter().convert(value).defaultValue(null).to(long[].class);
 
         } else if ( "Float[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Float[].class);
+            return getConverter().convert(value).defaultValue(null).to(Float[].class);
 
         } else if ( "float[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(float[].class);
+            return getConverter().convert(value).defaultValue(null).to(float[].class);
 
         } else if ( "Double[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Double[].class);
+            return getConverter().convert(value).defaultValue(null).to(Double[].class);
 
         } else if ( "double[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(double[].class);
+            return getConverter().convert(value).defaultValue(null).to(double[].class);
 
         } else if ( "Byte[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Byte[].class);
+            return getConverter().convert(value).defaultValue(null).to(Byte[].class);
 
         } else if ( "byte[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(byte[].class);
+            return getConverter().convert(value).defaultValue(null).to(byte[].class);
 
         } else if ( "Short[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Short[].class);
+            return getConverter().convert(value).defaultValue(null).to(Short[].class);
 
         } else if ( "short[]".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(short[].class);
+            return getConverter().convert(value).defaultValue(null).to(short[].class);
 
         } else if ( "Character[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Character[].class);
+            return getConverter().convert(value).defaultValue(null).to(Character[].class);
 
         } else if ( "char[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(char[].class);
+            return getConverter().convert(value).defaultValue(null).to(char[].class);
 
         } else if ( "Boolean[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(Boolean[].class);
+            return getConverter().convert(value).defaultValue(null).to(Boolean[].class);
 
         } else if ( "boolean[]".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(boolean[].class);
+            return getConverter().convert(value).defaultValue(null).to(boolean[].class);
         }
 
         // Collections of scalar types
         if ( "Collection<String>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<String>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<String>>()
{});
 
         } else if ( "Collection<Integer>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Integer>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Integer>>()
{});
 
         } else if ( "Collection<Long>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Long>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Long>>()
{});
 
         } else if ( "Collection<Float>".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Float>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Float>>()
{});
 
         } else if ( "Collection<Double>".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Double>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Double>>()
{});
 
         } else if ( "Collection<Byte>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Byte>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Byte>>()
{});
 
         } else if ( "Collection<Short>".equals(typeInfo)  ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Short>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Short>>()
{});
 
         } else if ( "Collection<Character>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Character>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Character>>()
{});
 
         } else if ( "Collection<Boolean>".equals(typeInfo) ) {
-            return getConverter().convert(value).defaultValue(defaultValue).to(new TypeReference<List<Boolean>>()
{});
+            return getConverter().convert(value).defaultValue(null).to(new TypeReference<List<Boolean>>()
{});
         }
 
         // unknown type - ignore configuration

Modified: felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/yaml/YAMLUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/yaml/YAMLUtil.java?rev=1751626&r1=1751625&r2=1751626&view=diff
==============================================================================
--- felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/yaml/YAMLUtil.java
(original)
+++ felix/sandbox/cziegeler/configurator/src/main/java/org/apache/felix/configurator/impl/yaml/YAMLUtil.java
Wed Jul  6 08:40:49 2016
@@ -196,7 +196,11 @@ public class YAMLUtil {
                                     }
                                 } else {
                                     try {
-                                        properties.put(key, converter.convert(value, createYAML(value),
typeInfo));
+                                        Object convertedVal = converter.convert(value, typeInfo);
+                                        if ( convertedVal == null ) {
+                                            convertedVal = createYAML(value);
+                                        }
+                                        properties.put(key, convertedVal);
                                     } catch ( final IOException io ) {
                                         SystemLogger.error("Invalid value/type for configuration
in '" + identifier + "' : " + pid + " - " + entry.getKey());
                                         valid = false;

Modified: felix/sandbox/cziegeler/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java?rev=1751626&r1=1751625&r2=1751626&view=diff
==============================================================================
--- felix/sandbox/cziegeler/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
(original)
+++ felix/sandbox/cziegeler/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
Wed Jul  6 08:40:49 2016
@@ -18,6 +18,11 @@
  */
 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;
@@ -27,16 +32,12 @@ import org.apache.felix.configurator.imp
 import org.apache.felix.configurator.impl.yaml.YAMLUtilTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 public class TypeConverterTest {
 
     @Test public void testStringConversionNoTypeInfo() throws IOException {
         final String v_String = "world";
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_String, null, null);
+        final Object result = converter.convert(v_String, null);
         assertTrue(result instanceof String);
         assertEquals(v_String, result);
     }
@@ -44,7 +45,7 @@ public class TypeConverterTest {
     @Test public void testLongConversionNoTypeInfo() throws IOException {
         final long v_long = 3;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_long, null, null);
+        final Object result = converter.convert(v_long, null);
         assertTrue(result instanceof Long);
         assertEquals(v_long, result);
     }
@@ -52,7 +53,7 @@ public class TypeConverterTest {
     @Test public void testIntegerConversionNoTypeInfo() throws IOException {
         final int v_int = 3;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_int, null, null);
+        final Object result = converter.convert(v_int, null);
         assertTrue(result instanceof Long);
         assertEquals(3L, result);
     }
@@ -60,7 +61,7 @@ public class TypeConverterTest {
     @Test public void testShortConversionNoTypeInfo() throws IOException {
         final short v_short = 3;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_short, null, null);
+        final Object result = converter.convert(v_short, null);
         assertTrue(result instanceof Long);
         assertEquals(3L, result);
     }
@@ -68,7 +69,7 @@ public class TypeConverterTest {
     @Test public void testByteConversionNoTypeInfo() throws IOException {
         final byte v_byte = 3;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_byte, null, null);
+        final Object result = converter.convert(v_byte, null);
         assertTrue(result instanceof Long);
         assertEquals(3L, result);
     }
@@ -76,30 +77,26 @@ public class TypeConverterTest {
     @Test public void testCharConversionNoTypeInfo() throws IOException {
         final char v_char = 'a';
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_char, "a", null);
-        assertTrue(result instanceof String);
-        assertEquals("a", result);
+        assertNull(converter.convert(v_char, null));
     }
 
     @Test public void testCharacterConversionNoTypeInfo() throws IOException {
         final Character v_Character = new Character('a');
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_Character, "a", null);
-        assertTrue(result instanceof String);
-        assertEquals("a", result);
+        assertNull(converter.convert(v_Character, null));
     }
 
     @Test public void testFloatConversionNoTypeInfo() throws IOException {
         final float v_float = 3.1f;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_float, null, null);
+        final Object result = converter.convert(v_float, null);
         assertTrue(result instanceof Double);
     }
 
     @Test public void testDoubleConversionNoTypeInfo() throws IOException {
         final double v_double = 3.0;
         final TypeConverter converter = new TypeConverter(null);
-        final Object result = converter.convert(v_double, null, null);
+        final Object result = converter.convert(v_double, null);
         assertTrue(result instanceof Double);
         assertEquals(v_double, result);
     }
@@ -113,27 +110,27 @@ public class TypeConverterTest {
         @SuppressWarnings("unchecked")
         final Map<String, Object> properties = (Map<String, Object>)config.get("config");
 
-        assertTrue(converter.convert(properties.get("string"), null, null) instanceof String);
-        assertTrue(converter.convert(properties.get("boolean"), null, null) instanceof Boolean);
-        assertTrue(converter.convert(properties.get("number"), null, null) instanceof Long);
-        assertTrue(converter.convert(properties.get("float"), null, null) instanceof Double);
+        assertTrue(converter.convert(properties.get("string"), null) instanceof String);
+        assertTrue(converter.convert(properties.get("boolean"), null) instanceof Boolean);
+        assertTrue(converter.convert(properties.get("number"), null) instanceof Long);
+        assertTrue(converter.convert(properties.get("float"), null) instanceof Double);
 
         // arrays
-        assertTrue(converter.convert(properties.get("string.array"), null, null).getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, null),
0) instanceof String);
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, null),
1) instanceof String);
-
-        assertTrue(converter.convert(properties.get("boolean.array"), null, null).getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null, null),
0) instanceof Boolean);
-        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null, null),
1) instanceof Boolean);
-
-        assertTrue(converter.convert(properties.get("number.array"), null, null).getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, null),
0) instanceof Long);
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, null),
1) instanceof Long);
-
-        assertTrue(converter.convert(properties.get("float.array"), null, null).getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, null),
0) instanceof Double);
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, null),
1) instanceof Double);
+        assertTrue(converter.convert(properties.get("string.array"), null).getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("string.array"), null), 0)
instanceof String);
+        assertTrue(Array.get(converter.convert(properties.get("string.array"), null), 1)
instanceof String);
+
+        assertTrue(converter.convert(properties.get("boolean.array"), null).getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null), 0)
instanceof Boolean);
+        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null), 1)
instanceof Boolean);
+
+        assertTrue(converter.convert(properties.get("number.array"), null).getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), null), 0)
instanceof Long);
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), null), 1)
instanceof Long);
+
+        assertTrue(converter.convert(properties.get("float.array"), null).getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), null), 0) instanceof
Double);
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), null), 1) instanceof
Double);
     }
 
     @Test public void testSimpleTypeConversionsWithTypeHint() throws Exception {
@@ -145,78 +142,78 @@ public class TypeConverterTest {
         @SuppressWarnings("unchecked")
         final Map<String, Object> properties = (Map<String, Object>)config.get("config");
 
-        assertTrue(converter.convert(properties.get("string"), null, "String") instanceof
String);
-        assertTrue(converter.convert(properties.get("boolean"), null, "Boolean") instanceof
Boolean);
-        assertTrue(converter.convert(properties.get("boolean"), null, "boolean") instanceof
Boolean);
-        assertTrue(converter.convert(properties.get("number"), null, "Integer") instanceof
Integer);
-        assertTrue(converter.convert(properties.get("number"), null, "int") instanceof Integer);
-        assertTrue(converter.convert(properties.get("number"), null, "Long") instanceof Long);
-        assertTrue(converter.convert(properties.get("number"), null, "long") instanceof Long);
-        assertTrue(converter.convert(properties.get("float"), null, "Double") instanceof
Double);
-        assertTrue(converter.convert(properties.get("float"), null, "double") instanceof
Double);
-        assertTrue(converter.convert(properties.get("float"), null, "Float") instanceof Float);
-        assertTrue(converter.convert(properties.get("float"), null, "float") instanceof Float);
-        assertTrue(converter.convert(properties.get("number"), null, "Byte") instanceof Byte);
-        assertTrue(converter.convert(properties.get("number"), null, "byte") instanceof Byte);
-        assertTrue(converter.convert(properties.get("number"), null, "Short") instanceof
Short);
-        assertTrue(converter.convert(properties.get("number"), null, "short") instanceof
Short);
-        assertTrue(converter.convert(properties.get("string"), null, "Character") instanceof
Character);
-        assertTrue(converter.convert(properties.get("string"), null, "char") instanceof Character);
+        assertTrue(converter.convert(properties.get("string"), "String") instanceof String);
+        assertTrue(converter.convert(properties.get("boolean"), "Boolean") instanceof Boolean);
+        assertTrue(converter.convert(properties.get("boolean"), "boolean") instanceof Boolean);
+        assertTrue(converter.convert(properties.get("number"), "Integer") instanceof Integer);
+        assertTrue(converter.convert(properties.get("number"), "int") instanceof Integer);
+        assertTrue(converter.convert(properties.get("number"), "Long") instanceof Long);
+        assertTrue(converter.convert(properties.get("number"), "long") instanceof Long);
+        assertTrue(converter.convert(properties.get("float"), "Double") instanceof Double);
+        assertTrue(converter.convert(properties.get("float"), "double") instanceof Double);
+        assertTrue(converter.convert(properties.get("float"), "Float") instanceof Float);
+        assertTrue(converter.convert(properties.get("float"), "float") instanceof Float);
+        assertTrue(converter.convert(properties.get("number"), "Byte") instanceof Byte);
+        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);
+        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"), null, "String[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, "String[]"),
0) instanceof String);
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, "String[]"),
1) instanceof String);
-
-        assertTrue(converter.convert(properties.get("boolean.array"), null, "Boolean[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null, "Boolean[]"),
0) instanceof Boolean);
-        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), null, "Boolean[]"),
1) instanceof Boolean);
+        assertTrue(converter.convert(properties.get("string.array"), "String[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("string.array"), "String[]"),
0) instanceof String);
+        assertTrue(Array.get(converter.convert(properties.get("string.array"), "String[]"),
1) instanceof String);
+
+        assertTrue(converter.convert(properties.get("boolean.array"), "Boolean[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), "Boolean[]"),
0) instanceof Boolean);
+        assertTrue(Array.get(converter.convert(properties.get("boolean.array"), "Boolean[]"),
1) instanceof Boolean);
 
         // the following would throw class cast exceptions
-        boolean[] a0 = (boolean[])converter.convert(properties.get("boolean.array"), null,
"boolean[]");
+        boolean[] a0 = (boolean[])converter.convert(properties.get("boolean.array"), "boolean[]");
         assertNotNull(a0);
-        int[] a1 = (int[])converter.convert(properties.get("number.array"), null, "int[]");
+        int[] a1 = (int[])converter.convert(properties.get("number.array"), "int[]");
         assertNotNull(a1);
-        long[] a2 = (long[])converter.convert(properties.get("number.array"), null, "long[]");
+        long[] a2 = (long[])converter.convert(properties.get("number.array"), "long[]");
         assertNotNull(a2);
-        double[] a3 = (double[])converter.convert(properties.get("float.array"), null, "double[]");
+        double[] a3 = (double[])converter.convert(properties.get("float.array"), "double[]");
         assertNotNull(a3);
-        float[] a4 = (float[])converter.convert(properties.get("float.array"), null, "float[]");
+        float[] a4 = (float[])converter.convert(properties.get("float.array"), "float[]");
         assertNotNull(a4);
-        byte[] a5 = (byte[])converter.convert(properties.get("number.array"), null, "byte[]");
+        byte[] a5 = (byte[])converter.convert(properties.get("number.array"), "byte[]");
         assertNotNull(a5);
-        short[] a6 = (short[])converter.convert(properties.get("number.array"), null, "short[]");
+        short[] a6 = (short[])converter.convert(properties.get("number.array"), "short[]");
         assertNotNull(a6);
-        char[] a7 = (char[])converter.convert(properties.get("string.array"), null, "char[]");
+        char[] a7 = (char[])converter.convert(properties.get("string.array"), "char[]");
         assertNotNull(a7);
 
-        assertTrue(converter.convert(properties.get("number.array"), null, "Integer[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Integer[]"),
0) instanceof Integer);
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Integer[]"),
1) instanceof Integer);
-
-        assertTrue(converter.convert(properties.get("number.array"), null, "Long[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Long[]"),
0) instanceof Long);
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Long[]"),
1) instanceof Long);
-
-        assertTrue(converter.convert(properties.get("number.array"), null, "Byte[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Byte[]"),
0) instanceof Byte);
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Byte[]"),
1) instanceof Byte);
-
-        assertTrue(converter.convert(properties.get("number.array"), null, "Short[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Short[]"),
0) instanceof Short);
-        assertTrue(Array.get(converter.convert(properties.get("number.array"), null, "Short[]"),
1) instanceof Short);
-
-        assertTrue(converter.convert(properties.get("float.array"), null, "Float[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, "Float[]"),
0) instanceof Float);
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, "Float[]"),
1) instanceof Float);
-
-        assertTrue(converter.convert(properties.get("float.array"), null, "Double[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, "Double[]"),
0) instanceof Double);
-        assertTrue(Array.get(converter.convert(properties.get("float.array"), null, "Double[]"),
1) instanceof Double);
-
-        assertTrue(converter.convert(properties.get("string.array"), null, "Character[]").getClass().isArray());
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, "Character[]"),
0) instanceof Character);
-        assertTrue(Array.get(converter.convert(properties.get("string.array"), null, "Character[]"),
1) instanceof Character);
+        assertTrue(converter.convert(properties.get("number.array"), "Integer[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Integer[]"),
0) instanceof Integer);
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Integer[]"),
1) instanceof Integer);
+
+        assertTrue(converter.convert(properties.get("number.array"), "Long[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Long[]"),
0) instanceof Long);
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Long[]"),
1) instanceof Long);
+
+        assertTrue(converter.convert(properties.get("number.array"), "Byte[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Byte[]"),
0) instanceof Byte);
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Byte[]"),
1) instanceof Byte);
+
+        assertTrue(converter.convert(properties.get("number.array"), "Short[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Short[]"),
0) instanceof Short);
+        assertTrue(Array.get(converter.convert(properties.get("number.array"), "Short[]"),
1) instanceof Short);
+
+        assertTrue(converter.convert(properties.get("float.array"), "Float[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), "Float[]"),
0) instanceof Float);
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), "Float[]"),
1) instanceof Float);
+
+        assertTrue(converter.convert(properties.get("float.array"), "Double[]").getClass().isArray());
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), "Double[]"),
0) instanceof Double);
+        assertTrue(Array.get(converter.convert(properties.get("float.array"), "Double[]"),
1) instanceof Double);
+
+        assertTrue(converter.convert(properties.get("string.array"), "Character[]").getClass().isArray());
+        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")
@@ -226,31 +223,31 @@ public class TypeConverterTest {
         final Map<String, Object> config = (Map<String, Object>)obj;
         final Map<String, Object> properties = (Map<String, Object>)config.get("config");
 
-        assertTrue(converter.convert(properties.get("string.array"), null, "Collection<String>")
instanceof Collection<?>);
-        assertTrue(((Collection<String>)converter.convert(properties.get("string.array"),
null, "Collection<String>")).iterator().next() instanceof String);
+        assertTrue(converter.convert(properties.get("string.array"), "Collection<String>")
instanceof Collection<?>);
+        assertTrue(((Collection<String>)converter.convert(properties.get("string.array"),
"Collection<String>")).iterator().next() instanceof String);
 
-        assertTrue(converter.convert(properties.get("number.array"), null, "Collection<Integer>")
instanceof Collection<?>);
-        assertTrue(((Collection<Integer>)converter.convert(properties.get("number.array"),
null, "Collection<Integer>")).iterator().next() instanceof Integer);
+        assertTrue(converter.convert(properties.get("number.array"), "Collection<Integer>")
instanceof Collection<?>);
+        assertTrue(((Collection<Integer>)converter.convert(properties.get("number.array"),
"Collection<Integer>")).iterator().next() instanceof Integer);
 
-        assertTrue(converter.convert(properties.get("number.array"), null, "Collection<Long>")
instanceof Collection<?>);
-        assertTrue(((Collection<Long>)converter.convert(properties.get("number.array"),
null, "Collection<Long>")).iterator().next() instanceof Long);
+        assertTrue(converter.convert(properties.get("number.array"), "Collection<Long>")
instanceof Collection<?>);
+        assertTrue(((Collection<Long>)converter.convert(properties.get("number.array"),
"Collection<Long>")).iterator().next() instanceof Long);
 
-        assertTrue(converter.convert(properties.get("float.array"), null, "Collection<Float>")
instanceof Collection<?>);
-        assertTrue(((Collection<Float>)converter.convert(properties.get("float.array"),
null, "Collection<Float>")).iterator().next() instanceof Float);
+        assertTrue(converter.convert(properties.get("float.array"), "Collection<Float>")
instanceof Collection<?>);
+        assertTrue(((Collection<Float>)converter.convert(properties.get("float.array"),
"Collection<Float>")).iterator().next() instanceof Float);
 
-        assertTrue(converter.convert(properties.get("float.array"), null, "Collection<Double>")
instanceof Collection<?>);
-        assertTrue(((Collection<Double>)converter.convert(properties.get("float.array"),
null, "Collection<Double>")).iterator().next() instanceof Double);
+        assertTrue(converter.convert(properties.get("float.array"), "Collection<Double>")
instanceof Collection<?>);
+        assertTrue(((Collection<Double>)converter.convert(properties.get("float.array"),
"Collection<Double>")).iterator().next() instanceof Double);
 
-        assertTrue(converter.convert(properties.get("number.array"), null, "Collection<Short>")
instanceof Collection<?>);
-        assertTrue(((Collection<Short>)converter.convert(properties.get("number.array"),
null, "Collection<Short>")).iterator().next() instanceof Short);
+        assertTrue(converter.convert(properties.get("number.array"), "Collection<Short>")
instanceof Collection<?>);
+        assertTrue(((Collection<Short>)converter.convert(properties.get("number.array"),
"Collection<Short>")).iterator().next() instanceof Short);
 
-        assertTrue(converter.convert(properties.get("number.array"), null, "Collection<Byte>")
instanceof Collection<?>);
-        assertTrue(((Collection<Byte>)converter.convert(properties.get("number.array"),
null, "Collection<Byte>")).iterator().next() instanceof Byte);
+        assertTrue(converter.convert(properties.get("number.array"), "Collection<Byte>")
instanceof Collection<?>);
+        assertTrue(((Collection<Byte>)converter.convert(properties.get("number.array"),
"Collection<Byte>")).iterator().next() instanceof Byte);
 
-        assertTrue(converter.convert(properties.get("string.array"), null, "Collection<Character>")
instanceof Collection<?>);
-        assertTrue(((Collection<Character>)converter.convert(properties.get("string.array"),
null, "Collection<Character>")).iterator().next() instanceof Character);
+        assertTrue(converter.convert(properties.get("string.array"), "Collection<Character>")
instanceof Collection<?>);
+        assertTrue(((Collection<Character>)converter.convert(properties.get("string.array"),
"Collection<Character>")).iterator().next() instanceof Character);
 
-        assertTrue(converter.convert(properties.get("boolean.array"), null, "Collection<Boolean>")
instanceof Collection<?>);
-        assertTrue(((Collection<Boolean>)converter.convert(properties.get("boolean.array"),
null, "Collection<Boolean>")).iterator().next() instanceof Boolean);
+        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);
     }
 }




Mime
View raw message