commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1410575 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/ test/java/org/apache/commons/configuration/builder/
Date Fri, 16 Nov 2012 21:19:45 GMT
Author: oheger
Date: Fri Nov 16 21:19:44 2012
New Revision: 1410575

URL: http://svn.apache.org/viewvc?rev=1410575&view=rev
Log:
Added support for ignoring exceptions when initializing a new Configuration object to other
derived builder classes.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedConfigurationBuilder.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ReloadingFileBasedConfigurationBuilder.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedConfigurationBuilder.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestReloadingFileBasedConfigurationBuilder.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedConfigurationBuilder.java?rev=1410575&r1=1410574&r2=1410575&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/FileBasedConfigurationBuilder.java
Fri Nov 16 21:19:44 2012
@@ -87,6 +87,22 @@ public class FileBasedConfigurationBuild
     }
 
     /**
+     * Creates a new instance of {@code FileBasedConfigurationBuilder} which
+     * produces result objects of the specified class and sets initialization
+     * parameters and the <em>allowFailOnInit</em> flag.
+     *
+     * @param resCls the result class (must not be <b>null</b>
+     * @param params a map with initialization parameters
+     * @param allowFailOnInit the <em>allowFailOnInit</em> flag
+     * @throws IllegalArgumentException if the result class is <b>null</b>
+     */
+    public FileBasedConfigurationBuilder(Class<T> resCls,
+            Map<String, Object> params, boolean allowFailOnInit)
+    {
+        super(resCls, params, allowFailOnInit);
+    }
+
+    /**
      * Returns the {@code FileHandler} associated with this builder. If already
      * a result object has been created, this {@code FileHandler} can be used to
      * save it. Otherwise, the {@code FileHandler} from the initialization

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ReloadingFileBasedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ReloadingFileBasedConfigurationBuilder.java?rev=1410575&r1=1410574&r2=1410575&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ReloadingFileBasedConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/ReloadingFileBasedConfigurationBuilder.java
Fri Nov 16 21:19:44 2012
@@ -94,6 +94,23 @@ public class ReloadingFileBasedConfigura
 
     /**
      * Creates a new instance of {@code ReloadingFileBasedConfigurationBuilder}
+     * which produces result objects of the specified class and sets
+     * initialization parameters and the <em>allowFailOnInit</em> flag.
+     *
+     * @param resCls the result class (must not be <b>null</b>
+     * @param params a map with initialization parameters
+     * @param allowFailOnInit the <em>allowFailOnInit</em> flag
+     * @throws IllegalArgumentException if the result class is <b>null</b>
+     */
+    public ReloadingFileBasedConfigurationBuilder(Class<T> resCls,
+            Map<String, Object> params, boolean allowFailOnInit)
+    {
+        super(resCls, params, allowFailOnInit);
+        reloadingController = createReloadingController();
+    }
+
+    /**
+     * Creates a new instance of {@code ReloadingFileBasedConfigurationBuilder}
      * which produces result objects of the specified class.
      *
      * @param resCls the result class (must not be <b>null</b>

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedConfigurationBuilder.java?rev=1410575&r1=1410574&r2=1410575&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestFileBasedConfigurationBuilder.java
Fri Nov 16 21:19:44 2012
@@ -206,4 +206,16 @@ public class TestFileBasedConfigurationB
         config = builder.getConfiguration();
         assertEquals("Not read from file 2", 2, config.getInt(PROP));
     }
+
+    /**
+     * Tests whether the allowFailOnInit flag is correctly initialized.
+     */
+    @Test
+    public void testInitAllowFailOnInitFlag()
+    {
+        FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
+                new FileBasedConfigurationBuilder<PropertiesConfiguration>(
+                        PropertiesConfiguration.class, null, true);
+        assertTrue("Flag not set", builder.isAllowFailOnInit());
+    }
 }

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestReloadingFileBasedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestReloadingFileBasedConfigurationBuilder.java?rev=1410575&r1=1410574&r2=1410575&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestReloadingFileBasedConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestReloadingFileBasedConfigurationBuilder.java
Fri Nov 16 21:19:44 2012
@@ -187,6 +187,18 @@ public class TestReloadingFileBasedConfi
     }
 
     /**
+     * Tests whether the allowFailOnInit flag is correctly initialized.
+     */
+    @Test
+    public void testInitAllowFailOnInitFlag()
+    {
+        ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration> builder =
+                new ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration>(
+                        PropertiesConfiguration.class, null, true);
+        assertTrue("Flag not set", builder.isAllowFailOnInit());
+    }
+
+    /**
      * A test builder implementation which allows mocking the underlying
      * reloading detector.
      */



Mime
View raw message