aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1210898 - in /aries/trunk/sandbox/jmx-next: jmx-api/src/main/java/org/osgi/jmx/framework/wiring/ jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/ jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/
Date Tue, 06 Dec 2011 13:20:20 GMT
Author: davidb
Date: Tue Dec  6 13:20:20 2011
New Revision: 1210898

URL: http://svn.apache.org/viewvc?rev=1210898&view=rev
Log:
Implement BundleWiringStateMBean.getCurrentRevisionDeclaredCapabilities()

Modified:
    aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java?rev=1210898&r1=1210897&r2=1210898&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
Tue Dec  6 13:20:20 2011
@@ -227,7 +227,7 @@ public interface BundleWiringStateMBean 
      * @return the declared capabilities for the current revision of <code>bundleId</code>
      * and <code>namespace</code>
      */
-    ArrayType getCurrentRevisionDeclaredCapabilities(long bundleId,
+    CompositeData[] getCurrentRevisionDeclaredCapabilities(long bundleId,
             String namespace) throws IOException;
 
     /**

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java?rev=1210898&r1=1210897&r2=1210898&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
Tue Dec  6 13:20:20 2011
@@ -62,9 +62,11 @@ public class BundleWiringState implement
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentRevisionDeclaredCapabilities(long,
java.lang.String)
      */
-    public ArrayType getCurrentRevisionDeclaredCapabilities(long bundleId, String namespace)
{
-        // TODO Auto-generated method stub
-        return null;
+    public CompositeData[] getCurrentRevisionDeclaredCapabilities(long bundleId, String namespace)
throws IOException {
+        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
+        BundleRevision revision = bundle.adapt(BundleRevision.class);
+
+        return BundleWiringData.getCapabilitiesCompositeData(revision.getDeclaredCapabilities(namespace));
     }
 
     /* (non-Javadoc)

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java?rev=1210898&r1=1210897&r2=1210898&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
Tue Dec  6 13:20:20 2011
@@ -58,8 +58,8 @@ public class BundleWiringStateMBeanTest 
     @Configuration
     public static Option[] configuration() {
         return testOptions(
-            // new VMOption( "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
),
-            // new TimeoutOption( 0 ),
+            //new VMOption( "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
),
+            //new TimeoutOption( 0 ),
 
             PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
             CoreOptions.equinox().version("3.7.0.v20110613"),
@@ -127,7 +127,26 @@ public class BundleWiringStateMBeanTest 
         List<BundleRequirement> requirements = br.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
         CompositeData[] jmxRequirements = brsMBean.getCurrentRevisionDeclaredRequirements(a.getBundleId(),
BundleWiringStateMBean.PACKAGE_NAMESPACE);
         Assert.assertEquals(requirements.size(), jmxRequirements.length);
-        // TODO more test content
+
+        Map<Map<String, Object>, Map<String, String>> expectedRequirements
= requirementsToMap(requirements);
+        Map<Map<String, Object>, Map<String, String>> actualRequirements
= jmxCapReqToMap(jmxRequirements);
+        Assert.assertEquals(expectedRequirements, actualRequirements);
+    }
+
+    @Test
+    public void testGetCurrentRevisionDeclaredCapabilities() throws IOException {
+        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
+
+        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
+        BundleRevision br = a.adapt(BundleRevision.class);
+
+        List<BundleCapability> capabilities = br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
+        CompositeData[] jmxCapabilities = brsMBean.getCurrentRevisionDeclaredCapabilities(a.getBundleId(),
BundleWiringStateMBean.PACKAGE_NAMESPACE);
+        Assert.assertEquals(capabilities.size(), jmxCapabilities.length);
+
+        Map<Map<String, Object>, Map<String, String>> expectedCapabilities
= capabilitiesToMap(capabilities);
+        Map<Map<String, Object>, Map<String, String>> actualCapabilities
= jmxCapReqToMap(jmxCapabilities);
+        Assert.assertEquals(expectedCapabilities, actualCapabilities);
     }
 
     @Test



Mime
View raw message