commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r711140 - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ExtendedProperties.java test/org/apache/commons/collections/TestExtendedProperties.java
Date Tue, 04 Nov 2008 00:15:36 GMT
Author: bayard
Date: Mon Nov  3 16:15:36 2008
New Revision: 711140

URL: http://svn.apache.org/viewvc?rev=711140&view=rev
Log:
Adding a test for COLLECTIONS-299 and a fix. Fixes by not adding any non-String values as
per java.util.Properties; also adding to the javadoc

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java?rev=711140&r1=711139&r2=711140&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
Mon Nov  3 16:15:36 2008
@@ -1708,6 +1708,10 @@
      * <p>
      * NOTE: From Commons Collections 3.2 this method will pick up
      * any default parent Properties of the specified input object.
+     * <p>
+     * As with java.util.Properties(Properties), any non-String 
+     * values will not be passed on in the new ExtendedProperties 
+     * object.
      *
      * @param props  the properties object to convert
      * @return new ExtendedProperties created from props
@@ -1717,7 +1721,10 @@
 
         for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
             String s = (String) e.nextElement();
-            c.setProperty(s, props.getProperty(s));
+            String value = props.getProperty(s);
+            if(value != null) {
+                c.setProperty(s, value);
+            }
         }
 
         return c;

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java?rev=711140&r1=711139&r2=711140&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java
(original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java
Mon Nov  3 16:15:36 2008
@@ -428,4 +428,20 @@
         assertEquals(3, props.size());
     }
 
+    public void testCollections299() {
+        Properties defaults = new Properties();
+        defaults.put("objectTrue", Boolean.TRUE);
+
+        Properties properties = new Properties(defaults);
+        properties.put("objectFalse", Boolean.FALSE);
+
+        ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
+
+        assertNull(extended.getString("objectTrue"));
+        assertNull(extended.getString("objectFalse"));
+
+        assertNull(extended.get("objectTrue"));
+        assertNull(extended.get("objectFalse"));
+    }
+
 }



Mime
View raw message