commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1730382 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java
Date Sun, 14 Feb 2016 19:03:56 GMT
Author: oheger
Date: Sun Feb 14 19:03:55 2016
New Revision: 1730382

URL: http://svn.apache.org/viewvc?rev=1730382&view=rev
Log:
[CONFIGURATION-619] Implemented inheritFrom() in PropertiesBuilderParametersImpl.

Here some more properties are taken into account.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java?rev=1730382&r1=1730381&r2=1730382&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/PropertiesBuilderParametersImpl.java
Sun Feb 14 19:03:55 2016
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.configuration2.builder;
 
+import java.util.Map;
+
 import org.apache.commons.configuration2.PropertiesConfiguration.IOFactory;
 import org.apache.commons.configuration2.PropertiesConfigurationLayout;
 
@@ -59,6 +61,17 @@ public class PropertiesBuilderParameters
         return this;
     }
 
+    /**
+     * {@inheritDoc} This implementation takes some more properties into account
+     * that are defined in this class.
+     */
+    @Override
+    public void inheritFrom(Map<String, ?> source)
+    {
+        super.inheritFrom(source);
+        copyPropertiesFrom(source, PROP_INCLUDES_ALLOWED, PROP_IO_FACTORY);
+    }
+
     @Override
     public PropertiesBuilderParametersImpl setLayout(
             PropertiesConfigurationLayout layout)

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java?rev=1730382&r1=1730381&r2=1730382&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestPropertiesBuilderParametersImpl.java
Sun Feb 14 19:03:55 2016
@@ -17,6 +17,7 @@
 package org.apache.commons.configuration2.builder;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
 import java.util.Map;
@@ -103,4 +104,28 @@ public class TestPropertiesBuilderParame
         assertSame("Factory not set", factory,
                 params.getParameters().get("iOFactory"));
     }
+
+    /**
+     * Tests whether properties can be inherited.
+     */
+    @Test
+    public void testInheritFrom()
+    {
+        PropertiesConfiguration.IOFactory factory =
+                EasyMock.createMock(PropertiesConfiguration.IOFactory.class);
+        params.setIOFactory(factory).setIncludesAllowed(false)
+                .setLayout(new PropertiesConfigurationLayout());
+        params.setThrowExceptionOnMissing(true);
+        PropertiesBuilderParametersImpl params2 =
+                new PropertiesBuilderParametersImpl();
+
+        params2.inheritFrom(params.getParameters());
+        Map<String, Object> parameters = params2.getParameters();
+        assertEquals("Exception flag not set", Boolean.TRUE,
+                parameters.get("throwExceptionOnMissing"));
+        assertEquals("IOFactory not set", factory, parameters.get("iOFactory"));
+        assertEquals("Include flag not set", Boolean.FALSE,
+                parameters.get("includesAllowed"));
+        assertNull("Layout was copied", parameters.get("layout"));
+    }
 }



Mime
View raw message