Author: oheger Date: Sat Sep 28 19:42:43 2013 New Revision: 1527240 URL: http://svn.apache.org/r1527240 Log: Added a test case for configuration of the file system.
This test demonstrates that for each configuration source defined in the definition file for a CombinedConfigurationBuilder a FileSystem can be defined. Added: commons/proper/configuration/trunk/src/test/resources/testCCFileSystemSubConfig.xml 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=1527240&r1=1527239&r2=1527240&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 Sat Sep 28 19:42:43 2013 @@ -758,13 +758,14 @@ public class TestCombinedConfigurationBu } /** - * Tests whether a default file system can be configured in the definition - * file. + * Helper method for testing whether the file system can be customized in + * the configuration definition file. + * + * @param fsFile the file to be processed + * @throws ConfigurationException if an error occurs */ - @Test - public void testCustomFileSystem() throws ConfigurationException + private void checkFileSystem(File fsFile) throws ConfigurationException { - File fsFile = ConfigurationAssert.getTestFile("testCCFileSystem.xml"); builder.configure(new FileBasedBuilderParametersImpl().setFile(fsFile)); builder.getConfiguration(); FileBasedConfigurationBuilder<? extends Configuration> xmlBuilder = @@ -776,6 +777,28 @@ public class TestCombinedConfigurationBu } /** + * Tests whether a default file system can be configured in the definition + * file. + */ + @Test + public void testCustomFileSystem() throws ConfigurationException + { + checkFileSystem(ConfigurationAssert.getTestFile("testCCFileSystem.xml")); + } + + /** + * Tests whether a specific file system can be applied to a sub + * configuration. + */ + @Test + public void testCustomFileSystemForSubConfig() + throws ConfigurationException + { + checkFileSystem(ConfigurationAssert + .getTestFile("testCCFileSystemSubConfig.xml")); + } + + /** * Tests whether a default base path for all file-based child configurations * can be set in the builder parameters. */ Added: commons/proper/configuration/trunk/src/test/resources/testCCFileSystemSubConfig.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/resources/testCCFileSystemSubConfig.xml?rev=1527240&view=auto ============================================================================== --- commons/proper/configuration/trunk/src/test/resources/testCCFileSystemSubConfig.xml (added) +++ commons/proper/configuration/trunk/src/test/resources/testCCFileSystemSubConfig.xml Sat Sep 28 19:42:43 2013 @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- + 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. +--> +<!-- Test configuration definition file that contains a declaration of a + custom file system to be applied to a sub configuration. + $Id$ +--> + +<configuration> + <header> + <fileSystem + config-class="org.apache.commons.configuration.io.DefaultFileSystem"/> + </header> + <xml fileName="test.xml" config-name="xml"> + <fileSystem + config-class="org.apache.commons.configuration.builder.combined.TestCombinedConfigurationBuilder$FileSystemTestImpl"/> + </xml> +</configuration>