commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1157982 - in /commons/proper/configuration/branches/configuration2_experimental/src: changes/ main/java/org/apache/commons/configuration2/ test/java/org/apache/commons/configuration2/ test/resources/
Date Mon, 15 Aug 2011 20:19:25 GMT
Author: oheger
Date: Mon Aug 15 20:19:25 2011
New Revision: 1157982

URL: http://svn.apache.org/viewvc?rev=1157982&view=rev
Log:
[CONFIGURATION-460] Ported fix to configuration2 branch.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml

Modified: commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml?rev=1157982&r1=1157981&r2=1157982&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
Mon Aug 15 20:19:25 2011
@@ -79,6 +79,11 @@
     </release>
 
     <release version="1.7" date="in SVN" description="">
+      <action dev="oheger" type="fix" issue="CONFIGURATION-460">
+        Reloading now also works for configuration sources declared in the
+        additional section of a configuration definition file for
+        DefaultConfigurationBuilder.
+      </action>
       <action dev="oheger" type="add" issue="CONFIGURATION-458">
         HierarchicalConfiguration now provides a specific implementation of the
         clear() method. This is more efficient and also solves some other

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java?rev=1157982&r1=1157981&r2=1157982&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
Mon Aug 15 20:19:25 2011
@@ -616,7 +616,7 @@ public class DefaultConfigurationBuilder
         List<SubConfiguration<ConfigurationNode>> additionals = fetchChildConfigs(KEY_UNION);
         if (!additionals.isEmpty())
         {
-            CombinedConfiguration addConfig = new CombinedConfiguration(new UnionCombiner());
+            CombinedConfiguration addConfig = createAdditionalsConfiguration(result);
             result.addConfiguration(addConfig, ADDITIONAL_NAME);
             initCombinedConfiguration(addConfig, additionals, KEY_ADDITIONAL_LIST);
         }
@@ -653,6 +653,32 @@ public class DefaultConfigurationBuilder
     }
 
     /**
+     * Creates the <code>CombinedConfiguration</code> for the configuration
+     * sources in the <code>&lt;additional&gt;</code> section. This method
is
+     * called when the builder constructs the final configuration. It creates a
+     * new <code>CombinedConfiguration</code> and initializes some properties
+     * from the result configuration.
+     *
+     * @param resultConfig the result configuration (this is the configuration
+     *        that will be returned by the builder)
+     * @return the <code>CombinedConfiguration</code> for the additional
+     *         configuration sources
+     * @since 1.7
+     */
+    protected CombinedConfiguration createAdditionalsConfiguration(
+            CombinedConfiguration resultConfig)
+    {
+        CombinedConfiguration addConfig =
+                new CombinedConfiguration(new UnionCombiner());
+        addConfig.setDelimiterParsingDisabled(resultConfig
+                .isDelimiterParsingDisabled());
+        addConfig.setForceReloadCheck(resultConfig.isForceReloadCheck());
+        addConfig.setIgnoreReloadExceptions(resultConfig
+                .isIgnoreReloadExceptions());
+        return addConfig;
+    }
+
+    /**
      * Initializes a combined configuration for the configurations of a specific
      * section. This method is called for the override and for the additional
      * section (if it exists).

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java?rev=1157982&r1=1157981&r2=1157982&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
Mon Aug 15 20:19:25 2011
@@ -741,7 +741,7 @@ public class TestDefaultConfigurationBui
     /**
      * Tests if the returned combined configuration has the expected structure.
      */
-    public void testCombinedConfiguration() throws ConfigurationException
+    public void testCombinedConfigurationStructure() throws ConfigurationException
     {
         factory.setFile(INIT_FILE);
         CombinedConfiguration cc = (CombinedConfiguration) factory
@@ -763,6 +763,35 @@ public class TestDefaultConfigurationBui
     }
 
     /**
+     * Helper method for testing the attributes of a combined configuration
+     * created by the builder.
+     *
+     * @param cc the configuration to be checked
+     */
+    private void checkCombinedConfigAttrs(CombinedConfiguration cc)
+    {
+        assertTrue("Wrong delimiter parsing flag",
+                cc.isDelimiterParsingDisabled());
+        assertTrue("Wrong reload check", cc.isForceReloadCheck());
+        assertTrue("Wrong ignore reload ex flag", cc.isIgnoreReloadExceptions());
+    }
+
+    /**
+     * Tests whether attributes are correctly set on the combined configurations
+     * for the override and additional sections.
+     */
+    public void testCombinedConfigurationAttributes() throws ConfigurationException
+    {
+        factory.setFile(INIT_FILE);
+        CombinedConfiguration cc = (CombinedConfiguration) factory
+                .getConfiguration();
+        checkCombinedConfigAttrs(cc);
+        CombinedConfiguration cc2 = (CombinedConfiguration) cc
+                .getConfiguration(DefaultConfigurationBuilder.ADDITIONAL_NAME);
+        checkCombinedConfigAttrs(cc2);
+    }
+
+    /**
      * Tests the structure of the returned combined configuration if there is no
      * additional section.
      */

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml?rev=1157982&r1=1157981&r2=1157982&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml
Mon Aug 15 20:19:25 2011
@@ -2,7 +2,8 @@
 <!-- Test configuration definition file that demonstrates complex initialization -->
 <configuration>
   <header>
-    <result delimiterParsingDisabled="true">
+    <result delimiterParsingDisabled="true" forceReloadCheck="true"
+      ignoreReloadExceptions="true">
       <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/>
       <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/>
     </result>



Mime
View raw message