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:28:57 UTC

svn commit: r1502848 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/CompositeConfiguration.java test/java/org/apache/commons/configuration/TestCompositeConfiguration.java

Author: oheger
Date: Sat Jul 13 19:28:57 2013
New Revision: 1502848

URL: http://svn.apache.org/r1502848
Log:
CompositeConfiguration no longer supports the properties for the list delimiter character and for disabling list delimiter parsing.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java?rev=1502848&r1=1502847&r2=1502848&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java Sat Jul 13 19:28:57 2013
@@ -263,14 +263,13 @@ implements Cloneable
         // recreate the in memory configuration
         inMemoryConfiguration = new BaseConfiguration();
         ((BaseConfiguration) inMemoryConfiguration).setThrowExceptionOnMissing(isThrowExceptionOnMissing());
-        ((BaseConfiguration) inMemoryConfiguration).setListDelimiter(getListDelimiter());
-        ((BaseConfiguration) inMemoryConfiguration).setDelimiterParsingDisabled(isDelimiterParsingDisabled());
+        ((BaseConfiguration) inMemoryConfiguration).setListDelimiterHandler(getListDelimiterHandler());
         configList.add(inMemoryConfiguration);
         inMemoryConfigIsChild = false;
     }
 
     /**
-     * Add this property to the inmemory Configuration.
+     * Add this property to the in-memory Configuration.
      *
      * @param key The Key to add the property to.
      * @param token The Value to add.
@@ -507,40 +506,19 @@ implements Cloneable
     }
 
     /**
-     * Sets a flag whether added values for string properties should be checked
-     * for the list delimiter. This implementation ensures that the in memory
+     * {@inheritDoc} This implementation ensures that the in memory
      * configuration is correctly initialized.
-     *
-     * @param delimiterParsingDisabled the new value of the flag
-     * @since 1.4
-     */
-    @Override
-    public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
-    {
-        if (inMemoryConfiguration instanceof AbstractConfiguration)
-        {
-            ((AbstractConfiguration) inMemoryConfiguration)
-                    .setDelimiterParsingDisabled(delimiterParsingDisabled);
-        }
-        super.setDelimiterParsingDisabled(delimiterParsingDisabled);
-    }
-
-    /**
-     * Sets the character that is used as list delimiter. This implementation
-     * ensures that the in memory configuration is correctly initialized.
-     *
-     * @param listDelimiter the new list delimiter character
-     * @since 1.4
      */
     @Override
-    public void setListDelimiter(char listDelimiter)
+    public void setListDelimiterHandler(
+            ListDelimiterHandler listDelimiterHandler)
     {
         if (inMemoryConfiguration instanceof AbstractConfiguration)
         {
             ((AbstractConfiguration) inMemoryConfiguration)
-                    .setListDelimiter(listDelimiter);
+                    .setListDelimiterHandler(listDelimiterHandler);
         }
-        super.setListDelimiter(listDelimiter);
+        super.setListDelimiterHandler(listDelimiterHandler);
     }
 
     /**

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java?rev=1502848&r1=1502847&r2=1502848&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestCompositeConfiguration.java Sat Jul 13 19:28:57 2013
@@ -39,7 +39,6 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.io.FileHandler;
 import org.easymock.EasyMock;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -615,31 +614,32 @@ public class TestCompositeConfiguration
     }
 
     /**
-     * Tests changing the list delimiter character.
+     * Tests changing the list delimiter handler.
      */
-    @Test @Ignore // TODO enable after list delimiter handler is fully integrated
+    @Test
     public void testSetListDelimiter()
     {
-        cc.setListDelimiter('/');
-        checkSetListDelimiter();
+        cc.setListDelimiterHandler(new DefaultListDelimiterHandler('/'));
+        checkSetListDelimiterHandler();
     }
 
     /**
-     * Tests whether the correct list delimiter is set after a clear operation.
+     * Tests whether the correct list delimiter handler is set after a clear
+     * operation.
      */
-    @Test @Ignore // TODO enable after list delimiter handler is fully integrated
+    @Test
     public void testSetListDelimiterAfterClear()
     {
-        cc.setListDelimiter('/');
+        cc.setListDelimiterHandler(new DefaultListDelimiterHandler('/'));
         cc.clear();
-        checkSetListDelimiter();
+        checkSetListDelimiterHandler();
     }
 
     /**
      * Helper method for testing whether the list delimiter is correctly
      * handled.
      */
-    private void checkSetListDelimiter()
+    private void checkSetListDelimiterHandler()
     {
         cc.addProperty("test.list", "a/b/c");
         cc.addProperty("test.property", "a,b,c");
@@ -647,39 +647,12 @@ public class TestCompositeConfiguration
                 .getList("test.list").size());
         assertEquals("Wrong value of property", "a,b,c", cc
                 .getString("test.property"));
-    }
-
-    /**
-     * Tests whether list splitting can be disabled.
-     */
-    @Test
-    public void testSetDelimiterParsingDisabled()
-    {
-        cc.setDelimiterParsingDisabled(true);
-        checkSetListDelimiterParsingDisabled();
-    }
-
-    /**
-     * Tests whether the list parsing flag is correctly handled after a clear()
-     * operation.
-     */
-    @Test
-    public void testSetDelimiterParsingDisabledAfterClear()
-    {
-        cc.setDelimiterParsingDisabled(true);
-        cc.clear();
-        checkSetListDelimiterParsingDisabled();
-    }
 
-    /**
-     * Helper method for checking whether the list parsing flag is correctly
-     * handled.
-     */
-    private void checkSetListDelimiterParsingDisabled()
-    {
-        cc.addProperty("test.property", "a,b,c");
-        assertEquals("Wrong value of property", "a,b,c", cc
-                .getString("test.property"));
+        AbstractConfiguration config =
+                (AbstractConfiguration) cc.getInMemoryConfiguration();
+        DefaultListDelimiterHandler listHandler =
+                (DefaultListDelimiterHandler) config.getListDelimiterHandler();
+        assertEquals("Wrong list delimiter", '/', listHandler.getDelimiter());
     }
 
     /**
@@ -811,7 +784,7 @@ public class TestCompositeConfiguration
     }
 
     /**
-     * Tests the behavior of setListDelimiter() if the in-memory configuration
+     * Tests the behavior of setListDelimiterHandler() if the in-memory configuration
      * is not derived from BaseConfiguration. This test is related to
      * CONFIGURATION-476.
      */
@@ -821,21 +794,7 @@ public class TestCompositeConfiguration
         Configuration inMemoryConfig = EasyMock.createMock(Configuration.class);
         EasyMock.replay(inMemoryConfig);
         cc = new CompositeConfiguration(inMemoryConfig);
-        cc.setListDelimiter(';');
-    }
-
-    /**
-     * Tests the behavior of setDelimiterParsingDisabled() if the in-memory
-     * configuration is not derived from BaseConfiguration. This test is related
-     * to CONFIGURATION-476.
-     */
-    @Test
-    public void testSetDelimiterParsingDisabledInMemoryConfigNonBaseConfig()
-    {
-        Configuration inMemoryConfig = EasyMock.createMock(Configuration.class);
-        EasyMock.replay(inMemoryConfig);
-        cc = new CompositeConfiguration(inMemoryConfig);
-        cc.setDelimiterParsingDisabled(true);
+        cc.setListDelimiterHandler(new DefaultListDelimiterHandler(';'));
     }
 
     /**