commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1643918 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration2/AbstractConfiguration.java test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java
Date Mon, 08 Dec 2014 21:02:57 GMT
Author: oheger
Date: Mon Dec  8 21:02:57 2014
New Revision: 1643918

URL: http://svn.apache.org/r1643918
Log:
[CONFIGURATION-200] Implemented synchronization for size() method.

AbstractConfiguration now implements size() taking proper synchronization into
account. The actual work has to be done by sizeInternal() which is not yet
implemented.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java?rev=1643918&r1=1643917&r2=1643918&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
Mon Dec  8 21:02:57 2014
@@ -1027,13 +1027,6 @@ public abstract class AbstractConfigurat
         }
     }
 
-    @Override
-    public int size()
-    {
-        // TODO implementation
-        return 0;
-    }
-
     /**
      * Actually checks whether this configuration contains data. This method is
      * called by {@code isEmpty()}. It has to be defined by concrete subclasses.
@@ -1046,6 +1039,30 @@ public abstract class AbstractConfigurat
 
     /**
      * {@inheritDoc} This implementation handles synchronization and delegates
+     * to {@code sizeInternal()}.
+     */
+    @Override
+    public final int size()
+    {
+        beginRead(false);
+        try
+        {
+            return sizeInternal();
+        }
+        finally
+        {
+            endRead();
+        }
+    }
+
+    protected int sizeInternal()
+    {
+        // TODO implementation
+        return 1;
+    }
+
+    /**
+     * {@inheritDoc} This implementation handles synchronization and delegates
      * to {@code containsKeyInternal()}.
      */
     @Override

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java?rev=1643918&r1=1643917&r2=1643918&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationSynchronization.java
Mon Dec  8 21:02:57 2014
@@ -188,17 +188,27 @@ public class TestAbstractConfigurationSy
      * Tests whether isEmpty() is correctly synchronized.
      */
     @Test
-    public void testIsEmptySychronized()
+    public void testIsEmptySynchronized()
     {
         assertFalse("Configuration is empty", config.isEmpty());
         sync.verify(Methods.BEGIN_READ, Methods.END_READ);
     }
 
     /**
+     * Tests whether size() is correctly synchronized.
+     */
+    @Test
+    public void testSizeSynchronized()
+    {
+        assertTrue("Wrong size", config.size() > 0);
+        sync.verify(Methods.BEGIN_READ, Methods.END_READ);
+    }
+
+    /**
      * Tests whether getKeys() is correctly synchronized.
      */
     @Test
-    public void testGetKeysSychronized()
+    public void testGetKeysSynchronized()
     {
         assertTrue("No keys", config.getKeys().hasNext());
         sync.verify(Methods.BEGIN_READ, Methods.END_READ);



Mime
View raw message