You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2005/03/01 13:05:03 UTC
svn commit: r155770 -
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java
Author: ebourg
Date: Tue Mar 1 04:04:59 2005
New Revision: 155770
URL: http://svn.apache.org/viewcvs?view=rev&rev=155770
Log:
Improved test coverage for FileChangedReloadingStrategy
Modified:
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java?view=diff&r1=155769&r2=155770
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java Tue Mar 1 04:04:59 2005
@@ -48,10 +48,12 @@
// load the configuration
PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties");
- config.setReloadingStrategy(new FileChangedReloadingStrategy());
+ FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
+ strategy.setRefreshDelay(500);
+ config.setReloadingStrategy(strategy);
assertEquals("Initial value", "value1", config.getString("string"));
- Thread.sleep(5000);
+ Thread.sleep(2000);
// change the file
out = new FileWriter(file);
@@ -61,6 +63,43 @@
// test the automatic reloading
assertEquals("Modified value with enabled reloading", "value2", config.getString("string"));
+ }
+
+ public void testNewFileReloading() throws Exception
+ {
+ // create a new configuration
+ File file = new File("target/testReload.properties");
+
+ if (file.exists())
+ {
+ file.delete();
+ }
+
+ PropertiesConfiguration config = new PropertiesConfiguration();
+ config.setFile(file);
+ FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
+ strategy.setRefreshDelay(500);
+ config.setReloadingStrategy(strategy);
+
+ assertNull("Initial value", config.getString("string"));
+
+ // change the file
+ FileWriter out = new FileWriter(file);
+ out.write("string=value1");
+ out.flush();
+ out.close();
+
+ Thread.sleep(2000);
+
+ // test the automatic reloading
+ assertEquals("Modified value with enabled reloading", "value1", config.getString("string"));
+ }
+
+ public void testGetRefreshDelay()
+ {
+ FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
+ strategy.setRefreshDelay(500);
+ assertEquals("refresh delay", 500, strategy.getRefreshDelay());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org