commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1463669 - /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/io/TestFileHandler.java
Date Tue, 02 Apr 2013 18:58:00 GMT
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)



Mime
View raw message