You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oh...@apache.org on 2006/12/02 19:43:14 UTC
svn commit: r481599 - in /jakarta/commons/proper/configuration/trunk:
src/java/org/apache/commons/configuration/CompositeConfiguration.java
src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
xdocs/changes.xml
Author: oheger
Date: Sat Dec 2 10:43:13 2006
New Revision: 481599
URL: http://svn.apache.org/viewvc?view=rev&rev=481599
Log:
CompositeConfiguration now overrides clearPropertyDirect() instead of clearProperty(). This ensures that correct update events are generated. Fix for CONFIGURATION-241
Modified:
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java?view=diff&rev=481599&r1=481598&r2=481599
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java Sat Dec 2 10:43:13 2006
@@ -271,7 +271,7 @@
/**
* {@inheritDoc}
*/
- public void clearProperty(String key)
+ protected void clearPropertyDirect(String key)
{
for (Iterator i = configList.iterator(); i.hasNext();)
{
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java?view=diff&rev=481599&r1=481598&r2=481599
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java Sat Dec 2 10:43:13 2006
@@ -440,7 +440,7 @@
assertEquals("2nd element", "foo.bar2", array[1]);
assertEquals("3rd element", "foo.bar3", array[2]);
}
-
+
/**
* Tests whether global interpolation works with lists.
*/
@@ -515,15 +515,61 @@
*/
public void testCloneEventListener()
{
- cc.addConfigurationListener(new ConfigurationListener()
- {
- public void configurationChanged(ConfigurationEvent event)
- {
- // Just a dummy
- }
- });
+ cc.addConfigurationListener(new TestEventListenerImpl());
CompositeConfiguration cc2 = (CompositeConfiguration) cc.clone();
assertTrue("Listeners have been cloned", cc2
.getConfigurationListeners().isEmpty());
+ }
+
+ /**
+ * Tests whether add property events are triggered.
+ */
+ public void testEventAddProperty()
+ {
+ TestEventListenerImpl l = new TestEventListenerImpl();
+ cc.addConfigurationListener(l);
+ cc.addProperty("test", "value");
+ assertEquals("No add events received", 2, l.eventCount);
+ }
+
+ /**
+ * Tests whether set property events are triggered.
+ */
+ public void testEventSetProperty()
+ {
+ TestEventListenerImpl l = new TestEventListenerImpl();
+ cc.addConfigurationListener(l);
+ cc.setProperty("test", "value");
+ assertEquals("No set events received", 2, l.eventCount);
+ }
+
+ /**
+ * Tests whether clear property events are triggered.
+ */
+ public void testEventClearProperty()
+ {
+ cc.addConfiguration(conf1);
+ assertTrue("Wrong value for property", cc
+ .getBoolean("configuration.loaded"));
+ TestEventListenerImpl l = new TestEventListenerImpl();
+ cc.addConfigurationListener(l);
+ cc.clearProperty("configuration.loaded");
+ assertFalse("Key still present", cc.containsKey("configuration.loaded"));
+ assertEquals("No clear events received", 2, l.eventCount);
+ }
+
+ /**
+ * A test configuration event listener that counts the number of received
+ * events. Used for testing the event facilities.
+ */
+ static class TestEventListenerImpl implements ConfigurationListener
+ {
+ /** The number of received events.*/
+ int eventCount;
+
+ public void configurationChanged(ConfigurationEvent event)
+ {
+ eventCount++;
+ }
}
}
Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&rev=481599&r1=481598&r2=481599
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Sat Dec 2 10:43:13 2006
@@ -23,6 +23,10 @@
<body>
<release version="1.4-dev" date="in SVN">
+ <action dev="oheger" type="update" issue="CONFIGURATION-241">
+ CompositeConfiguration.clearProperty() now generates the correct
+ update events.
+ </action>
<action dev="oheger" type="update" issue="CONFIGURATION-242">
The configuration returned by HierarchicalConfiguration.subset()
performed variable interpolation only in the keys that belong to the
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org