commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1465758 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/fluent/ test/java/org/apache/commons/configuration/builder/fluent/
Date Mon, 08 Apr 2013 19:59:30 GMT
Author: oheger
Date: Mon Apr  8 19:59:30 2013
New Revision: 1465758

URL: http://svn.apache.org/r1465758
Log:
Added a fluent interface for defining the parameters of a database configuration.

Added:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/DatabaseBuilderParameters.java
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/DatabaseBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/DatabaseBuilderParameters.java?rev=1465758&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/DatabaseBuilderParameters.java
(added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/DatabaseBuilderParameters.java
Mon Apr  8 19:59:30 2013
@@ -0,0 +1,36 @@
+/*
+ * 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.DatabaseBuilderProperties;
+
+/**
+ * <p>
+ * Definition of a parameters interface providing a fluent API for setting all
+ * properties for a database configuration.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public interface DatabaseBuilderParameters extends
+        BasicBuilderProperties<DatabaseBuilderParameters>,
+        DatabaseBuilderProperties<DatabaseBuilderParameters>, BuilderParameters
+{
+}

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=1465758&r1=1465757&r2=1465758&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
Mon Apr  8 19:59:30 2013
@@ -22,6 +22,7 @@ import java.lang.reflect.Proxy;
 
 import org.apache.commons.configuration.builder.BasicBuilderParameters;
 import org.apache.commons.configuration.builder.BuilderParameters;
+import org.apache.commons.configuration.builder.DatabaseBuilderParametersImpl;
 import org.apache.commons.configuration.builder.FileBasedBuilderParametersImpl;
 import org.apache.commons.configuration.builder.HierarchicalBuilderParametersImpl;
 import org.apache.commons.configuration.builder.JndiBuilderParametersImpl;
@@ -167,6 +168,18 @@ public final class Parameters
     }
 
     /**
+     * Creates a new instance of a parameters object for database
+     * configurations.
+     *
+     * @return the new parameters object
+     */
+    public static DatabaseBuilderParameters database()
+    {
+        return createParametersProxy(DatabaseBuilderParameters.class,
+                new DatabaseBuilderParametersImpl());
+    }
+
+    /**
      * 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=1465758&r1=1465757&r2=1465758&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
Mon Apr  8 19:59:30 2013
@@ -220,4 +220,23 @@ public class TestParameters
                 params.getManagedBuilderParameters());
         assertEquals("Wrong pattern", pattern, params.getFilePattern());
     }
+
+    /**
+     * Tests whether a parameters object for a database configuration can be
+     * created.
+     */
+    @Test
+    public void testDatabase()
+    {
+        Map<String, Object> map =
+                Parameters.database().setThrowExceptionOnMissing(true)
+                        .setAutoCommit(true).setTable("table")
+                        .setListDelimiter('#').setKeyColumn("keyColumn")
+                        .getParameters();
+        checkBasicProperties(map);
+        assertEquals("Wrong table name", "table", map.get("table"));
+        assertEquals("Wrong key column name", "keyColumn", map.get("keyColumn"));
+        assertEquals("Wrong auto commit flag", Boolean.TRUE,
+                map.get("autoCommit"));
+    }
 }



Mime
View raw message