commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1432295 - in /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined: TestCombinedConfigurationBuilder.java TestCombinedConfigurationBuilderVFS.java
Date Fri, 11 Jan 2013 21:35:08 GMT
Author: oheger
Date: Fri Jan 11 21:35:08 2013
New Revision: 1432295

URL: http://svn.apache.org/viewvc?rev=1432295&view=rev
Log:
Added a test class for CombinedConfigurationBuilder which executes all tests on a VFSFileSystem.

Added:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
  (with props)
Modified:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilder.java

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilder.java?rev=1432295&r1=1432294&r2=1432295&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilder.java
Fri Jan 11 21:35:08 2013
@@ -77,7 +77,7 @@ public class TestCombinedConfigurationBu
     private static final String BUILDER_NAME = "subBuilderName";
 
     /** Stores the object to be tested. */
-    private CombinedConfigurationBuilder builder;
+    protected CombinedConfigurationBuilder builder;
 
     @Before
     public void setUp() throws Exception
@@ -96,7 +96,7 @@ public class TestCombinedConfigurationBu
      * @param defConfig the definition configuration
      * @return the definition builder
      */
-    private static BasicConfigurationBuilder<? extends HierarchicalConfiguration> createDefinitionBuilder(
+    protected static BasicConfigurationBuilder<? extends HierarchicalConfiguration>
createDefinitionBuilder(
             HierarchicalConfiguration defConfig)
     {
         return new ConstantConfigurationBuilder(defConfig);
@@ -111,7 +111,7 @@ public class TestCombinedConfigurationBu
      * @param attrs the attributes of this tag
      * @return the definition configuration
      */
-    private static HierarchicalConfiguration createDefinitionConfig(String tag,
+    protected static HierarchicalConfiguration createDefinitionConfig(String tag,
             Map<String, Object> attrs)
     {
         HierarchicalConfiguration defConfig =

Added: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java?rev=1432295&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
(added)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
Fri Jan 11 21:35:08 2013
@@ -0,0 +1,78 @@
+/*
+ * 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.combined;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationAssert;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.FileSystem;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.VFSFileSystem;
+import org.apache.commons.configuration.builder.BasicConfigurationBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * A specialized test class for {@code CombinedConfigurationBuilder} which uses
+ * a VFS file system for accessing file-based configurations.
+ *
+ * @version $Id$
+ */
+public class TestCombinedConfigurationBuilderVFS extends
+        TestCombinedConfigurationBuilder
+{
+    @Override
+    @Before
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        FileSystem.setDefaultFileSystem(new VFSFileSystem());
+    }
+
+    @After
+    public void tearDown() throws Exception
+    {
+        FileSystem.resetDefaultFileSystem();
+    }
+
+    /**
+     * Tests if the base path is correctly evaluated.
+     */
+    @Test
+    public void testSetConfigurationBasePath() throws ConfigurationException
+    {
+        File deepDir = new File(ConfigurationAssert.TEST_DIR, "config/deep");
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("fileName", "test.properties");
+        BasicConfigurationBuilder<? extends HierarchicalConfiguration> defBuilder =
+                createDefinitionBuilder(createDefinitionConfig("properties",
+                        params));
+        builder.configure(new CombinedBuilderParametersImpl()
+                .setDefinitionBuilder(defBuilder).setBasePath(
+                        deepDir.getAbsolutePath()));
+        Configuration config = builder.getConfiguration();
+        assertEquals("Wrong property value", "somevalue",
+                config.getString("somekey"));
+    }
+}

Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/combined/TestCombinedConfigurationBuilderVFS.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message