commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r821995 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/base/Capabilities.java test/java/org/apache/commons/configuration2/base/TestCapabilities.java
Date Mon, 05 Oct 2009 20:31:28 GMT
Author: oheger
Date: Mon Oct  5 20:31:28 2009
New Revision: 821995

URL: http://svn.apache.org/viewvc?rev=821995&view=rev
Log:
Capabilities now also work with interfaces inherited from super classes.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/Capabilities.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestCapabilities.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/Capabilities.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/Capabilities.java?rev=821995&r1=821994&r2=821995&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/Capabilities.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/Capabilities.java
Mon Oct  5 20:31:28 2009
@@ -19,6 +19,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.commons.lang.ClassUtils;
+
 /**
  * <p>
  * A class for managing <em>capabilities</em>.
@@ -147,9 +149,9 @@
     private static void extractOwnerCapabilities(Collection<Capability> caps,
             Object owner)
     {
-        for (Class capCls : owner.getClass().getInterfaces())
+        for (Object capCls : ClassUtils.getAllInterfaces(owner.getClass()))
         {
-            caps.add(new Capability(capCls, owner));
+            caps.add(new Capability((Class) capCls, owner));
         }
     }
 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestCapabilities.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestCapabilities.java?rev=821995&r1=821994&r2=821995&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestCapabilities.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestCapabilities.java
Mon Oct  5 20:31:28 2009
@@ -98,6 +98,21 @@
     }
 
     /**
+     * Tests whether super interfaces are taken into account when querying
+     * capabilities from the owner object.
+     */
+    public void testGetCapabilityFromOwnerInherited()
+    {
+        @SuppressWarnings("serial")
+        ConfigurationSource owner = new MapConfigurationSource()
+        {
+        };
+        Capabilities caps = new Capabilities(owner, null);
+        assertSame("Wrong source", owner, caps
+                .getCapability(ConfigurationSource.class));
+    }
+
+    /**
      * Tests whether capabilities from the list can be obtained.
      */
     public void testGetCapabilityFromList()



Mime
View raw message