commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1515447 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/convert/PropertyConverter.java test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java
Date Mon, 19 Aug 2013 14:33:49 GMT
Author: oheger
Date: Mon Aug 19 14:33:48 2013
New Revision: 1515447

URL: http://svn.apache.org/r1515447
Log:
Added a missing toString conversion.

The to() method of PropertyConverter was lacking a trivial conversion to a
string. This feature is now available based to the toString() method.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java?rev=1515447&r1=1515446&r2=1515447&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
Mon Aug 19 14:33:48 2013
@@ -96,6 +96,10 @@ public final class PropertyConverter
             return value; // no conversion needed
         }
 
+        if (String.class.equals(cls))
+        {
+            return String.valueOf(value);
+        }
         if (Boolean.class.equals(cls) || Boolean.TYPE.equals(cls))
         {
             return toBoolean(value);

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java?rev=1515447&r1=1515446&r2=1515447&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/convert/TestPropertyConverter.java
Mon Aug 19 14:33:48 2013
@@ -202,4 +202,15 @@ public class TestPropertyConverter
     {
         PropertyConverter.to(Character.TYPE, "FF", null);
     }
+
+    /**
+     * Tests a conversion to a string.
+     */
+    @Test
+    public void testToStringConversion()
+    {
+        Integer src = 42;
+        Object result = PropertyConverter.to(String.class, src, null);
+        assertEquals("Wrong resulting string", "42", result);
+    }
 }



Mime
View raw message