commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1432741 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/fluent/ test/java/org/apache/commons/configuration/builder/fluent/
Date Sun, 13 Jan 2013 21:14:30 GMT
Author: oheger
Date: Sun Jan 13 21:14:29 2013
New Revision: 1432741

URL: http://svn.apache.org/viewvc?rev=1432741&view=rev
Log:
Parameters now supports the creation of a MultiFileBuilderParameters object.

Added:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
  (with props)
Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java

Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java?rev=1432741&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
(added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
Sun Jan 13 21:14:29 2013
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration.builder.fluent;
+
+import org.apache.commons.configuration.builder.BasicBuilderProperties;
+import org.apache.commons.configuration.builder.BuilderParameters;
+import org.apache.commons.configuration.builder.combined.MultiFileBuilderProperties;
+
+/**
+ * <p>
+ * Definition of a parameters interface providing a fluent API for setting all
+ * properties of a builder managing multiple file-based configurations.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public interface MultiFileBuilderParameters extends
+        BasicBuilderProperties<MultiFileBuilderParameters>,
+        MultiFileBuilderProperties<MultiFileBuilderParameters>,
+        BuilderParameters
+{
+}

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/MultiFileBuilderParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java?rev=1432741&r1=1432740&r2=1432741&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
Sun Jan 13 21:14:29 2013
@@ -27,6 +27,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.builder.JndiBuilderParametersImpl;
 import org.apache.commons.configuration.builder.XMLBuilderParametersImpl;
 import org.apache.commons.configuration.builder.combined.CombinedBuilderParametersImpl;
+import org.apache.commons.configuration.builder.combined.MultiFileBuilderParametersImpl;
 
 /**
  * <p>
@@ -141,6 +142,18 @@ public final class Parameters
     }
 
     /**
+     * Creates a new instance of a parameters object for a builder for multiple
+     * file-based configurations.
+     *
+     * @return the new parameters object
+     */
+    public static MultiFileBuilderParameters multiFile()
+    {
+        return createParametersProxy(MultiFileBuilderParameters.class,
+                new MultiFileBuilderParametersImpl());
+    }
+
+    /**
      * Creates a proxy object for a given parameters interface based on the
      * given implementation object.
      *

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java?rev=1432741&r1=1432740&r2=1432741&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java
Sun Jan 13 21:14:29 2013
@@ -18,19 +18,22 @@ package org.apache.commons.configuration
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
 
 import org.apache.commons.configuration.builder.BasicBuilderParameters;
+import org.apache.commons.configuration.builder.BuilderParameters;
 import org.apache.commons.configuration.builder.FileBasedBuilderParametersImpl;
 import org.apache.commons.configuration.builder.combined.CombinedBuilderParametersImpl;
+import org.apache.commons.configuration.builder.combined.MultiFileBuilderParametersImpl;
 import org.apache.commons.configuration.tree.ExpressionEngine;
 import org.easymock.EasyMock;
 import org.junit.Test;
 
 /**
- * Test class for parameters.
+ * Test class for {@code Parameters}.
  *
  * @version $Id$
  */
@@ -172,4 +175,24 @@ public class TestParameters
         assertEquals("Wrong expression engine", engine,
                 map.get("expressionEngine"));
     }
+
+    /**
+     * Tests whether a {@code MultiFileBuilderParameters} object can be created.
+     */
+    @Test
+    public void testMultiFile()
+    {
+        BuilderParameters bp = EasyMock.createMock(BuilderParameters.class);
+        String pattern = "a pattern";
+        Map<String, Object> map =
+                Parameters.multiFile().setThrowExceptionOnMissing(true)
+                        .setFilePattern(pattern).setListDelimiter('#')
+                        .setManagedBuilderParameters(bp).getParameters();
+        checkBasicProperties(map);
+        MultiFileBuilderParametersImpl params =
+                MultiFileBuilderParametersImpl.fromParameters(map);
+        assertSame("Wrong builder parameters", bp,
+                params.getManagedBuilderParameters());
+        assertEquals("Wrong pattern", pattern, params.getFilePattern());
+    }
 }



Mime
View raw message