ebourg 2004/09/23 04:47:57
Modified: configuration/src/test/org/apache/commons/configuration
TestPropertiesConfiguration.java
Log:
More tests:
- for the new constructor PropertiesConfiguration(File)
- for a file loaded from a jar
- for setInclude()
Revision Changes Path
1.14 +35 -1
jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
Index: TestPropertiesConfiguration.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TestPropertiesConfiguration.java 22 Sep 2004 17:17:30 -0000 1.13
+++ TestPropertiesConfiguration.java 23 Sep 2004 11:47:57 -0000 1.14
@@ -79,6 +79,21 @@
assertEquals("true", loaded);
}
+ public void testSetInclude() throws Exception
+ {
+ // change the include key
+ PropertiesConfiguration.setInclude("import");
+
+ // load the configuration
+ PropertiesConfiguration conf = new PropertiesConfiguration();
+ conf.load("conf/test.properties");
+
+ // restore the previous value for the other tests
+ PropertiesConfiguration.setInclude("include");
+
+ assertNull(conf.getString("include.loaded"));
+ }
+
/**
* Tests <code>List</code> parsing.
*/
@@ -183,6 +198,25 @@
pc.load();
assertTrue("Make sure we have multiple keys",
pc.getBoolean("test.boolean"));
+ }
+
+ public void testLoadFromJAR() throws Exception
+ {
+ conf = new PropertiesConfiguration();
+ conf.setIncludesAllowed(true);
+ conf.setFileName("test-jar.properties");
+ conf.load();
+
+ assertEquals("jar", conf.getProperty("configuration.location"));
+ assertEquals("property in an included file", "jar",
conf.getProperty("include.location"));
+ }
+
+ public void testLoadFromFile() throws Exception
+ {
+ File file = new File("conf/test.properties");
+ conf = new PropertiesConfiguration(file);
+
+ assertEquals("true", conf.getString("configuration.loaded"));
}
public void testGetStringWithEscapedChars()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]