Author: oheger Date: Sat Apr 21 08:23:08 2007 New Revision: 531047 URL: http://svn.apache.org/viewvc?view=rev&rev=531047 Log: Reviewed event handling in plist configurations; added new test classes
Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java (with props) jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java (with props) jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java (with props) Modified: jakarta/commons/proper/configuration/trunk/build.xml jakarta/commons/proper/configuration/trunk/project.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/event/AbstractTestConfigurationEvents.java Modified: jakarta/commons/proper/configuration/trunk/build.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/build.xml?view=diff&rev=531047&r1=531046&r2=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/build.xml (original) +++ jakarta/commons/proper/configuration/trunk/build.xml Sat Apr 21 08:23:08 2007 @@ -164,6 +164,7 @@ <exclude name="**/AbstractCombinerTest.java"/> <exclude name="**/AbstractTestConfigurationEvents.java"/> <exclude name="**/AbstractTestFileConfigurationEvents.java"/> + <exclude name="**/AbstractTestPListEvents.java"/> </fileset> </batchtest> </junit> Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.xml?view=diff&rev=531047&r1=531046&r2=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Sat Apr 21 08:23:08 2007 @@ -524,6 +524,7 @@ <exclude>**/AbstractCombinerTest.java</exclude> <exclude>**/AbstractTestConfigurationEvents.java</exclude> <exclude>**/AbstractTestFileConfigurationEvents.java</exclude> + <exclude>**/AbstractTestPListEvents.java</exclude> </excludes> <resources> <resource> Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?view=diff&rev=531047&r1=531046&r2=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java Sat Apr 21 08:23:08 2007 @@ -146,8 +146,18 @@ // special case for byte arrays, they must be stored as is in the configuration if (value instanceof byte[]) { - clearProperty(key); - addPropertyDirect(key, value); + fireEvent(EVENT_SET_PROPERTY, key, value, true); + setDetailEvents(false); + try + { + clearProperty(key); + addPropertyDirect(key, value); + } + finally + { + setDetailEvents(true); + } + fireEvent(EVENT_SET_PROPERTY, key, value, false); } else { @@ -165,7 +175,7 @@ } else { - super.setProperty(key, value); + super.addProperty(key, value); } } Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?view=diff&rev=531047&r1=531046&r2=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java Sat Apr 21 08:23:08 2007 @@ -186,8 +186,18 @@ // special case for byte arrays, they must be stored as is in the configuration if (value instanceof byte[]) { - clearProperty(key); - addPropertyDirect(key, value); + fireEvent(EVENT_SET_PROPERTY, key, value, true); + setDetailEvents(false); + try + { + clearProperty(key); + addPropertyDirect(key, value); + } + finally + { + setDetailEvents(true); + } + fireEvent(EVENT_SET_PROPERTY, key, value, false); } else { @@ -205,7 +215,7 @@ } else { - super.setProperty(key, value); + super.addProperty(key, value); } } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/event/AbstractTestConfigurationEvents.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/event/AbstractTestConfigurationEvents.java?view=diff&rev=531047&r1=531046&r2=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/event/AbstractTestConfigurationEvents.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/event/AbstractTestConfigurationEvents.java Sat Apr 21 08:23:08 2007 @@ -186,7 +186,7 @@ * A test event listener class used for testing events generated by the * configuration. */ - class TestConfigurationListener implements ConfigurationListener + protected class TestConfigurationListener implements ConfigurationListener { /** Stores the received events. */ private LinkedList events = new LinkedList(); Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java?view=auto&rev=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java (added) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java Sat Apr 21 08:23:08 2007 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.configuration.plist; + +import org.apache.commons.configuration.AbstractConfiguration; +import org.apache.commons.configuration.event.AbstractTestConfigurationEvents; + +/** + * A base test class for testing the events generated by the plist + * configurations. This class especially checks events related to the special + * handling of byte arrays. + * + * @version $Id$ + */ +public abstract class AbstractTestPListEvents extends + AbstractTestConfigurationEvents +{ + /** Constant for the name of the byte array property. */ + private static final String TEST_PROPBYTE = "byteData"; + + /** Constant for the test byte array used for testing. */ + private static final byte[] TEST_DATA = + { 1, 2, 3 }; + + /** + * Tests the events generated by an added byte array property. + */ + public void testAddByteArrayPropertyEvent() + { + config.addProperty(TEST_PROPBYTE, TEST_DATA); + l.checkEvent(AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_PROPBYTE, + TEST_DATA, true); + l.checkEvent(AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_PROPBYTE, + TEST_DATA, false); + l.done(); + } + + /** + * Tests the events generated by setting a byte array property. + */ + public void testSetByteArrayPropertyEvent() + { + config.setProperty(TEST_PROPBYTE, TEST_DATA); + l.checkEvent(AbstractConfiguration.EVENT_SET_PROPERTY, TEST_PROPBYTE, + TEST_DATA, true); + l.checkEvent(AbstractConfiguration.EVENT_SET_PROPERTY, TEST_PROPBYTE, + TEST_DATA, false); + l.done(); + } +} Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/AbstractTestPListEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java?view=auto&rev=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java (added) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java Sat Apr 21 08:23:08 2007 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.configuration.plist; + +import java.io.File; + +import org.apache.commons.configuration.AbstractConfiguration; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.ConfigurationRuntimeException; + +/** + * Test class for the events generated by PropertyListConfiguration. + * + * @version $Id$ + */ +public class TestPropertyListConfigurationEvents extends + AbstractTestPListEvents +{ + /** Constant for the test file that will be loaded. */ + private static final File TEST_FILE = new File("conf/test.plist"); + + protected AbstractConfiguration createConfiguration() + { + try + { + return new PropertyListConfiguration(TEST_FILE); + } + catch (ConfigurationException cex) + { + throw new ConfigurationRuntimeException(cex); + } + } + +} Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java?view=auto&rev=531047 ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java (added) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java Sat Apr 21 08:23:08 2007 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.configuration.plist; + +import java.io.File; + +import org.apache.commons.configuration.AbstractConfiguration; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.ConfigurationRuntimeException; + +/** + * Test class for the events generated by XMLPropertyListConfiguration. + * + * @version $Id$ + */ +public class TestXMLPropertyListConfigurationEvents extends + AbstractTestPListEvents +{ + /** Constant for the test file that will be loaded. */ + private static final File TEST_FILE = new File("conf/test.plist.xml"); + + protected AbstractConfiguration createConfiguration() + { + try + { + return new XMLPropertyListConfiguration(TEST_FILE); + } + catch (ConfigurationException cex) + { + throw new ConfigurationRuntimeException(cex); + } + } +} Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfigurationEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]