You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/04/02 20:58:00 UTC

svn commit: r1463669 - /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java

Author: oheger
Date: Tue Apr  2 18:57:59 2013
New Revision: 1463669

URL: http://svn.apache.org/r1463669
Log:
Copied a test from XMLConfiguration for setting file names to TestFileHandler.

Modified:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java?rev=1463669&r1=1463668&r2=1463669&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java Tue Apr  2 18:57:59 2013
@@ -297,6 +297,35 @@ public class TestFileHandler
     }
 
     /**
+     * Additional tests for setting file names in various ways. (Copied from the
+     * test for XMLConfiguration)
+     */
+    @Test
+    public void testSettingFileNames()
+    {
+        String testProperties =
+                ConfigurationAssert.getTestFile("test.xml").getAbsolutePath();
+        String testBasePath = ConfigurationAssert.TEST_DIR.getAbsolutePath();
+
+        FileHandler handler = new FileHandler();
+        handler.setFileName(testProperties);
+        assertEquals(testProperties.toString(), handler.getFileName());
+
+        handler.setBasePath(testBasePath);
+        handler.setFileName("hello.xml");
+        assertEquals("hello.xml", handler.getFileName());
+        assertEquals(testBasePath.toString(), handler.getBasePath());
+        assertEquals(new File(testBasePath, "hello.xml"), handler.getFile());
+
+        handler.setBasePath(testBasePath);
+        handler.setFileName("subdir/hello.xml");
+        assertEquals("subdir/hello.xml", handler.getFileName());
+        assertEquals(testBasePath.toString(), handler.getBasePath());
+        assertEquals(new File(testBasePath, "subdir/hello.xml"),
+                handler.getFile());
+    }
+
+    /**
      * Tries to call a load() method if no content object is available.
      */
     @Test(expected = ConfigurationException.class)