You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/07/13 21:36:29 UTC

svn commit: r1502859 - in /commons/proper/configuration/trunk/src/test: java/org/apache/commons/configuration/TestPropertiesConfiguration.java resources/test.properties

Author: oheger
Date: Sat Jul 13 19:36:29 2013
New Revision: 1502859

URL: http://svn.apache.org/r1502859
Log:
Removed references to old list splitting properties from test class.

Added an improved test for list handling with a specific list delimiter
character.

Modified:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java
    commons/proper/configuration/trunk/src/test/resources/test.properties

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java?rev=1502859&r1=1502858&r2=1502859&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestPropertiesConfiguration.java Sat Jul 13 19:36:29 2013
@@ -478,29 +478,22 @@ public class TestPropertiesConfiguration
         assertEquals("'test.multilines' property", property, conf.getString("test.multilines"));
     }
 
-    @Test
-    public void testChangingDefaultListDelimiter() throws Exception
-    {
-        assertEquals(4, conf.getList("test.mixed.array").size());
-
-        char delimiter = PropertiesConfiguration.getDefaultListDelimiter();
-        PropertiesConfiguration.setDefaultListDelimiter('^');
-        PropertiesConfiguration pc = new PropertiesConfiguration();
-        load(pc, testProperties);
-        assertEquals(2, pc.getList("test.mixed.array").size());
-        PropertiesConfiguration.setDefaultListDelimiter(delimiter);
-    }
-
+    /**
+     * Tests whether another list delimiter character can be set (by using an
+     * alternative list delimiter handler).
+     */
     @Test
     public void testChangingListDelimiter() throws Exception
     {
-        assertEquals(4, conf.getList("test.mixed.array").size());
-
+        assertEquals("Wrong initial string", "a^b^c",
+                conf.getString("test.other.delimiter"));
         PropertiesConfiguration pc2 = new PropertiesConfiguration();
-        pc2.setListDelimiter('^');
+        pc2.setListDelimiterHandler(new DefaultListDelimiterHandler('^'));
         load(pc2, testProperties);
-        assertEquals("Should obtain the first value", "a", pc2.getString("test.mixed.array"));
-        assertEquals(2, pc2.getList("test.mixed.array").size());
+        assertEquals("Should obtain the first value", "a",
+                pc2.getString("test.other.delimiter"));
+        assertEquals("Wrong list size", 3, pc2.getList("test.other.delimiter")
+                .size());
     }
 
     @Test
@@ -509,7 +502,6 @@ public class TestPropertiesConfiguration
         assertEquals(4, conf.getList("test.mixed.array").size());
 
         PropertiesConfiguration pc2 = new PropertiesConfiguration();
-        pc2.setDelimiterParsingDisabled(true);
         load(pc2, testProperties);
         assertEquals(2, pc2.getList("test.mixed.array").size());
     }
@@ -978,7 +970,7 @@ public class TestPropertiesConfiguration
             throws ConfigurationException
     {
         String prop = "delimiterListProp";
-        conf.setDelimiterParsingDisabled(true);
+        conf.setListDelimiterHandler(DisabledListDelimiterHandler.INSTANCE);
         List<String> list = Arrays.asList("val", "val2", "val3");
         conf.setProperty(prop, list);
         saveTestConfig();

Modified: commons/proper/configuration/trunk/src/test/resources/test.properties
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/resources/test.properties?rev=1502859&r1=1502858&r2=1502859&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/resources/test.properties (original)
+++ commons/proper/configuration/trunk/src/test/resources/test.properties Sat Jul 13 19:36:29 2013
@@ -35,6 +35,7 @@ test.empty =
 
 test.mixed.array = a
 test.mixed.array = b, c, d
+test.other.delimiter = a^b^c
 
 test.multilines = This is a value spread out across several adjacent \
                   natural lines by escaping the line terminator with \