commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1527242 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/ test/java/org/apache/commons/configuration/builder/
Date Sat, 28 Sep 2013 19:43:50 GMT
Author: oheger
Date: Sat Sep 28 19:43:50 2013
New Revision: 1527242

URL: http://svn.apache.org/r1527242
Log:
Extended properties for file-based builders by FileLocationStrategy property.

The FileLocationStrategy to be used for resolving the file to be loaded can now
be specified in the builder's parameters object.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderParametersImpl.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderProperties.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedBuilderParameters.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderParametersImpl.java?rev=1527242&r1=1527241&r2=1527242&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderParametersImpl.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderParametersImpl.java
Sat Sep 28 19:43:50 2013
@@ -21,6 +21,7 @@ import java.net.URL;
 import java.util.Map;
 
 import org.apache.commons.configuration.io.FileHandler;
+import org.apache.commons.configuration.io.FileLocationStrategy;
 import org.apache.commons.configuration.io.FileSystem;
 
 /**
@@ -206,6 +207,13 @@ public class FileBasedBuilderParametersI
         return this;
     }
 
+    public FileBasedBuilderParametersImpl setLocationStrategy(
+            FileLocationStrategy strategy)
+    {
+        getFileHandler().setLocationStrategy(strategy);
+        return this;
+    }
+
     public FileBasedBuilderParametersImpl setEncoding(String enc)
     {
         getFileHandler().setEncoding(enc);

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderProperties.java?rev=1527242&r1=1527241&r2=1527242&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderProperties.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedBuilderProperties.java
Sat Sep 28 19:43:50 2013
@@ -19,6 +19,7 @@ package org.apache.commons.configuration
 import java.io.File;
 import java.net.URL;
 
+import org.apache.commons.configuration.io.FileLocationStrategy;
 import org.apache.commons.configuration.io.FileSystem;
 
 /**
@@ -106,6 +107,14 @@ public interface FileBasedBuilderPropert
     T setFileSystem(FileSystem fs);
 
     /**
+     * Sets the {@code FileLocationStrategy} for resolving the referenced file.
+     *
+     * @param strategy the {@code FileLocationStrategy}
+     * @return a reference to this object for method chaining
+     */
+    T setLocationStrategy(FileLocationStrategy strategy);
+
+    /**
      * Sets the encoding of the associated {@code FileHandler}.
      *
      * @param enc the encoding

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedBuilderParameters.java?rev=1527242&r1=1527241&r2=1527242&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedBuilderParameters.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedBuilderParameters.java
Sat Sep 28 19:43:50 2013
@@ -32,6 +32,7 @@ import org.apache.commons.beanutils.Prop
 import org.apache.commons.configuration.ConfigurationAssert;
 import org.apache.commons.configuration.io.FileBased;
 import org.apache.commons.configuration.io.FileHandler;
+import org.apache.commons.configuration.io.FileLocationStrategy;
 import org.apache.commons.configuration.io.FileSystem;
 import org.easymock.EasyMock;
 import org.junit.Test;
@@ -180,6 +181,22 @@ public class TestFileBasedBuilderParamet
     }
 
     /**
+     * Tests whether a location strategy can be set.
+     */
+    @Test
+    public void testSetLocationStrategy()
+    {
+        FileLocationStrategy strat =
+                EasyMock.createMock(FileLocationStrategy.class);
+        EasyMock.replay(strat);
+        FileBasedBuilderParametersImpl params =
+                new FileBasedBuilderParametersImpl();
+        assertSame("Wrong result", params, params.setLocationStrategy(strat));
+        assertSame("Wrong location strategy", strat, params.getFileHandler()
+                .getLocationStrategy());
+    }
+
+    /**
      * Tests whether an encoding can be set.
      */
     @Test



Mime
View raw message