commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r155763 - jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
Date Tue, 01 Mar 2005 10:04:50 GMT
Author: oheger
Date: Tue Mar  1 02:04:49 2005
New Revision: 155763

URL: http://svn.apache.org/viewcvs?view=rev&rev=155763
Log:
Added test for ConfigurationFactory which checks usage of absolute paths

Modified:
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java?view=diff&r1=155762&r2=155763
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
Tue Mar  1 02:04:49 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Copyright 2001-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 package org.apache.commons.configuration;
 
 import java.io.File;
+import java.io.FileWriter;
 import java.util.Collection;
 import java.net.URL;
 
@@ -53,6 +54,9 @@
     private File testDigesterBadXML = new File("conf/testDigesterBadXML.xml");
 
     private String testBasePath = new File("conf").getAbsolutePath();
+    
+    private File testProperties = new File("conf/test.properties");
+    private File testAbsConfig = new File("target/testAbsConfig.xml");
 
     private Configuration configuration;
     private CompositeConfiguration compositeConfiguration;
@@ -271,6 +275,43 @@
         catch(ConfigurationException cex)
         {
             // fine
+        }
+    }
+    
+    // Checks if a file with an absolute path can be loaded
+    public void testLoadAbsolutePath() throws Exception
+    {
+        try
+        {
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(testAbsConfig);
+                out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>");
+                out.write("<configuration>");
+                out.write("<properties fileName=\"");
+                out.write(testProperties.getAbsolutePath());
+                out.write("\"/>");
+                out.write("</configuration>");
+            }
+            finally
+            {
+                if (out != null)
+                {
+                    out.close();
+                }
+            }
+
+            factory.setConfigurationFileName(testAbsConfig.toString());
+            Configuration config = factory.getConfiguration();
+            assertTrue(config.getBoolean("configuration.loaded"));
+        }
+        finally
+        {
+            if (testAbsConfig.exists())
+            {
+                testAbsConfig.delete();
+            }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message