Diff of /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java
Parent Directory
| Revision Log
| Patch
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java 2005/06/04 15:21:40 179998
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java 2005/06/04 15:54:12 179999
@@ -304,4 +304,55 @@ public class TestFileConfiguration exten
}
}
}
+
+ /**
+ * Tests loading and saving a configuration file with a complicated path
+ * name including spaces. (related to issue 35210)
+ */
+ public void testPathWithSpaces() throws Exception
+ {
+ File path = new File(TARGET_DIR, "path with spaces");
+ File confFile = new File(path, "config-test.properties");
+ PrintWriter out = null;
+
+ try
+ {
+ if (!path.exists())
+ {
+ assertTrue(path.mkdir());
+ }
+ out = new PrintWriter(new FileWriter(confFile));
+ out.println("saved = false");
+ out.close();
+ out = null;
+
+ URL url = new URL(TARGET_DIR.toURL()
+ + "path%20with%20spaces/config-test.properties");
+ PropertiesConfiguration config = new PropertiesConfiguration(url);
+ config.load();
+ assertFalse(config.getBoolean("saved"));
+
+ config.setProperty("saved", Boolean.TRUE);
+ config.save();
+ config = new PropertiesConfiguration();
+ config.setFile(confFile);
+ config.load();
+ assertTrue(config.getBoolean("saved"));
+ }
+ finally
+ {
+ if (out != null)
+ {
+ out.close();
+ }
+ if (confFile.exists())
+ {
+ assertTrue(confFile.delete());
+ }
+ if (path.exists())
+ {
+ assertTrue(path.delete());
+ }
+ }
+ }
}
\ No newline at end of file