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 2011/04/08 20:01:13 UTC

svn commit: r1090370 - in /commons/proper/configuration/branches/configuration2_experimental/src: changes/changes.xml test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java

Author: oheger
Date: Fri Apr  8 18:01:12 2011
New Revision: 1090370

URL: http://svn.apache.org/viewvc?rev=1090370&view=rev
Log:
[CONFIGURATION-439] Ported changes to configuration2 branch.

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

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=1090370&r1=1090369&r2=1090370&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml Fri Apr  8 18:01:12 2011
@@ -79,6 +79,13 @@
     </release>
 
     <release version="1.7" date="in SVN" description="">
+      <action dev="oheger" type="update" issue="CONFIGURATION-439">
+        Child configuration builders created for a &lt;configuration&gt; element
+        in a configuration definition file now inherit the configuration and
+        error listeners from the original DefaultConfigurationBuilder. This
+        makes it possible to suppress log output created for optional
+        configurations.
+      </action>
       <action dev="oheger" type="update" issue="CONFIGURATION-438" due-to="Mike Noordermeer">
         JNDIConfiguration.getKeys() no more logs an exception if the prefix does
         not exist.

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=1090370&r1=1090369&r2=1090370&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 Fri Apr  8 18:01:12 2011
@@ -19,6 +19,9 @@ package org.apache.commons.configuration
 import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.net.URL;
 import java.util.Collection;
 import java.util.HashMap;
@@ -601,6 +604,41 @@ public class TestDefaultConfigurationBui
     }
 
     /**
+     * Tests whether the error log message caused by an optional configuration
+     * can be suppressed if a child builder is involved.
+     */
+    public void testLoadOptionalChildBuilderSuppressErrorLog()
+            throws ConfigurationException
+    {
+        factory.addProperty("override.configuration[@fileName]",
+                OPTIONAL_FILE.getAbsolutePath());
+        // a special invocation handler which checks that the warn() method of
+        // a logger is not called
+        InvocationHandler handler = new InvocationHandler()
+        {
+            public Object invoke(Object proxy, Method method, Object[] args)
+                    throws Throwable
+            {
+                String methodName = method.getName();
+                if (methodName.startsWith("is"))
+                {
+                    return Boolean.TRUE;
+                }
+                if ("warn".equals(methodName))
+                {
+                    fail("Unexpected log output!");
+                }
+                return null;
+            }
+        };
+        factory.setLogger((Log) Proxy.newProxyInstance(getClass()
+                .getClassLoader(), new Class<?>[] {
+            Log.class
+        }, handler));
+        factory.getConfiguration(false);
+    }
+
+    /**
      * Tests loading a definition file with multiple different sources.
      */
     public void testLoadDifferentSources() throws ConfigurationException