Author: oheger
Date: Fri Jul 11 20:14:23 2014
New Revision: 1609788

URL: http://svn.apache.org/r1609788
Log:
Added new event type constants for basic update events.

A new test class was added to check whether the types are correctly set up.

Added:
    
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
Modified:
    
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
    
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java

Modified: 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java?rev=1609788&r1=1609787&r2=1609788&view=diff
==============================================================================
--- 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
 (original)
+++ 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
 Fri Jul 11 20:14:23 2014
@@ -106,24 +106,28 @@ public abstract class AbstractConfigurat
     /**
      * Constant for the add property event type.
      * @since 1.3
+     * @deprecated Use the event type constants in {@code ConfigurationEvent}
      */
     public static final int EVENT_ADD_PROPERTY = 1;
 
     /**
      * Constant for the clear property event type.
      * @since 1.3
+     * @deprecated Use the event type constants in {@code ConfigurationEvent}
      */
     public static final int EVENT_CLEAR_PROPERTY = 2;
 
     /**
      * Constant for the set property event type.
      * @since 1.3
+     * @deprecated Use the event type constants in {@code ConfigurationEvent}
      */
     public static final int EVENT_SET_PROPERTY = 3;
 
     /**
      * Constant for the clear configuration event type.
      * @since 1.3
+     * @deprecated Use the event type constants in {@code ConfigurationEvent}
      */
     public static final int EVENT_CLEAR = 4;
 

Modified: 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java?rev=1609788&r1=1609787&r2=1609788&view=diff
==============================================================================
--- 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java
 (original)
+++ 
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java
 Fri Jul 11 20:14:23 2014
@@ -77,10 +77,46 @@ public class ConfigurationEvent extends 
      */
     private static final long serialVersionUID = 20140703L;
 
-    /** Constant for the common super type of all configuration update events. 
*/
+    /**
+     * Constant for the common super type of all configuration update events.
+     *
+     * @since 2.0
+     */
     public static final EventType<ConfigurationEvent> ANY =
             new EventType<ConfigurationEvent>(Event.ANY, 
"CONFIGURATION_UPDATE");
 
+    /**
+     * Constant for the event type for an add property operation.
+     *
+     * @since 2.0
+     */
+    public static final EventType<ConfigurationEvent> ADD_PROPERTY =
+            new EventType<ConfigurationEvent>(ANY, "ADD_PROPERTY");
+
+    /**
+     * Constant for the event type for a set property operation.
+     *
+     * @since 2.0
+     */
+    public static final EventType<ConfigurationEvent> SET_PROPERTY =
+            new EventType<ConfigurationEvent>(ANY, "SET_PROPERTY");
+
+    /**
+     * Constant for the event type for a clear property operation.
+     *
+     * @since 2.0
+     */
+    public static final EventType<ConfigurationEvent> CLEAR_PROPERTY =
+            new EventType<ConfigurationEvent>(ANY, "CLEAR_PROPERTY");
+
+    /**
+     * Constant for the event type for a clear operation.
+     *
+     * @since 2.0
+     */
+    public static final EventType<ConfigurationEvent> CLEAR =
+            new EventType<ConfigurationEvent>(ANY, "CLEAR");
+
     /** The legacy event type. */
     private final int type;
 

Added: 
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java?rev=1609788&view=auto
==============================================================================
--- 
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
 (added)
+++ 
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
 Fri Jul 11 20:14:23 2014
@@ -0,0 +1,88 @@
+/*
+ * 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.event;
+
+import static org.junit.Assert.assertSame;
+
+import org.junit.Test;
+
+/**
+ * A test class which tests whether the types of basic configuration events are
+ * correctly defined.
+ *
+ * @version $Id$
+ */
+public class TestConfigurationEventTypes
+{
+    /**
+     * Tests the base event type for configuration events.
+     */
+    @Test
+    public void testConfigurationEventType()
+    {
+        assertSame("Wrong super type", Event.ANY,
+                ConfigurationEvent.ANY.getSuperType());
+    }
+
+    /**
+     * Helper method for checking the relevant properties of a given event type
+     * representing a configuration update event.
+     *
+     * @param eventType the event type to check
+     */
+    private void checkUpdateEvent(EventType<ConfigurationEvent> eventType)
+    {
+        assertSame("Wrong super type for " + eventType, ConfigurationEvent.ANY,
+                eventType.getSuperType());
+    }
+
+    /**
+     * Tests the event type for adding a property.
+     */
+    @Test
+    public void testAddPropertyEventType()
+    {
+        checkUpdateEvent(ConfigurationEvent.ADD_PROPERTY);
+    }
+
+    /**
+     * Tests the event type for setting a property.
+     */
+    @Test
+    public void testSetPropertyEventType()
+    {
+        checkUpdateEvent(ConfigurationEvent.SET_PROPERTY);
+    }
+
+    /**
+     * Tests the event type for clearing a property.
+     */
+    @Test
+    public void testClearPropertyEventType()
+    {
+        checkUpdateEvent(ConfigurationEvent.CLEAR_PROPERTY);
+    }
+
+    /**
+     * Tests the event type for clearing a whole configuration.
+     */
+    @Test
+    public void testClearEventType()
+    {
+        checkUpdateEvent(ConfigurationEvent.CLEAR);
+    }
+}


Reply via email to