You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by hu...@apache.org on 2011/11/08 18:27:37 UTC
svn commit: r1199354 [2/2] - in /aries/branches/oct-2011-release: ./
application/ application/application-itests/
application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/
application/application-itests/src/test/jav...
Modified: aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java?rev=1199354&r1=1199353&r2=1199354&view=diff
==============================================================================
--- aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java (original)
+++ aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java Tue Nov 8 17:27:34 2011
@@ -24,11 +24,20 @@ import static org.ops4j.pax.swissbox.tin
import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
import org.apache.aries.jmx.AbstractIntegrationTest;
+import org.apache.aries.jmx.codec.PropertyData;
import org.junit.Assert;
import org.junit.Test;
import org.ops4j.pax.exam.CoreOptions;
@@ -37,22 +46,20 @@ import org.ops4j.pax.exam.container.def.
import org.ops4j.pax.exam.junit.Configuration;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.jmx.framework.BundleRevisionsStateMBean;
import org.osgi.jmx.framework.PackageStateMBean;
-/**
- *
- *
- * @version $Rev: 1190259 $ $Date: 2011-10-28 12:46:48 +0100 (Fri, 28 Oct 2011) $
- */
public class BundleRevisionsStateMBeanTest extends AbstractIntegrationTest {
-
@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"),
@@ -111,46 +118,111 @@ public class BundleRevisionsStateMBeanTe
}
@Test
- public void testMBeanInterface() throws IOException {
- // BundleStateMBean bsMBean = getMBean(BundleStateMBean.OBJECTNAME, BundleStateMBean.class);
+ public void testGetCurrentWiring() throws IOException {
BundleRevisionsStateMBean brsMBean = getMBean(BundleRevisionsStateMBean.OBJECTNAME, BundleRevisionsStateMBean.class);
Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
+ CompositeData jmxWiring = brsMBean.getCurrentWiring(a.getBundleId(), BundleRevisionsStateMBean.PACKAGE_NAMESPACE);
- CompositeData wiring = brsMBean.getCurrentWiring(a.getBundleId(), BundleRevisionsStateMBean.PACKAGE_NAMESPACE);
-
- Assert.assertEquals(BundleRevisionsStateMBean.BUNDLE_WIRING_TYPE, wiring.getCompositeType());
- Assert.assertEquals(a.getBundleId(), wiring.get(BundleRevisionsStateMBean.BUNDLE_ID));
+ Assert.assertEquals(BundleRevisionsStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
+ Assert.assertEquals(a.getBundleId(), jmxWiring.get(BundleRevisionsStateMBean.BUNDLE_ID));
BundleWiring bw = a.adapt(BundleWiring.class);
- CompositeData[] capabilities = (CompositeData[]) wiring.get(BundleRevisionsStateMBean.CAPABILITIES);
- Assert.assertEquals(bw.getCapabilities(BundleRevisionsStateMBean.PACKAGE_NAMESPACE).size(), capabilities.length);
+ CompositeData[] jmxCapabilities = (CompositeData[]) jmxWiring.get(BundleRevisionsStateMBean.CAPABILITIES);
+ List<BundleCapability> capabilities = bw.getCapabilities(BundleRevision.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);
+
+ CompositeData[] jmxRequirements = (CompositeData[]) jmxWiring.get(BundleRevisionsStateMBean.REQUIREMENTS);
+ List<BundleRequirement> requirements = bw.getRequirements(BundleRevision.PACKAGE_NAMESPACE);
+ Assert.assertEquals(requirements.size(), jmxRequirements.length);
+
+ Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
+ Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
+ Assert.assertEquals(expectedRequirements, actualRequirements);
+
+ List<BundleWire> requiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
+ CompositeData[] jmxRequiredWires = (CompositeData[]) jmxWiring.get(BundleRevisionsStateMBean.BUNDLE_WIRES_TYPE);
+ // currently the wires only contains the required wires
+ // should we have separate JMX slots for provided and required wires instead?
+ Assert.assertEquals(requiredWires.size(), jmxRequiredWires.length);
+
+ Set<List<Object>> expectedWires = new HashSet<List<Object>>();
+ for (BundleWire wire : requiredWires) {
+ List<Object> data = new ArrayList<Object>();
+
+ data.add(wire.getCapability().getRevision().getBundle().getBundleId());
+ data.add(wire.getCapability().getAttributes());
+ data.add(wire.getCapability().getDirectives());
+ data.add(wire.getRequirement().getRevision().getBundle().getBundleId());
+ data.add(wire.getRequirement().getAttributes());
+ data.add(wire.getRequirement().getDirectives());
+ expectedWires.add(data);
+ }
+
+ Set<List<Object>> actualWires = new HashSet<List<Object>>();
+ for (CompositeData wire : jmxRequiredWires) {
+ List<Object> data = new ArrayList<Object>();
+ data.add(wire.get(BundleRevisionsStateMBean.PROVIDER_BUNDLE_ID));
+ // TODO bundle revision id
+ data.add(getJmxAttributes((CompositeData) wire.get(BundleRevisionsStateMBean.BUNDLE_CAPABILITY)));
+ data.add(getJmxDirectives((CompositeData) wire.get(BundleRevisionsStateMBean.BUNDLE_CAPABILITY)));
+ data.add(wire.get(BundleRevisionsStateMBean.REQUIRER_BUNDLE_ID));
+ data.add(getJmxAttributes((CompositeData) wire.get(BundleRevisionsStateMBean.BUNDLE_REQUIREMENT)));
+ data.add(getJmxDirectives((CompositeData) wire.get(BundleRevisionsStateMBean.BUNDLE_REQUIREMENT)));
+ actualWires.add(data);
+ }
+
+ Assert.assertEquals(expectedWires, actualWires);
+ }
+
+ private Map<Map<String, Object>, Map<String, String>> capabilitiesToMap(List<BundleCapability> capabilities) {
+ Map<Map<String, Object>, Map<String, String>> map = new HashMap<Map<String,Object>, Map<String,String>>();
+ for (BundleCapability cap : capabilities) {
+ map.put(cap.getAttributes(), cap.getDirectives());
+ }
+ return map;
+ }
- /*
- PackageStateMBean packagaState = getMBean(PackageStateMBean.OBJECTNAME, PackageStateMBean.class);
- assertNotNull(packagaState);
-
- long[] exportingBundles = packagaState.getExportingBundles("org.osgi.jmx.framework", "1.5.0");
- assertNotNull(exportingBundles);
- assertTrue("Should find a bundle exporting org.osgi.jmx.framework", exportingBundles.length > 0);
-
- long[] exportingBundles2 = packagaState.getExportingBundles("test", "1.0.0");
- assertNull("Shouldn't find a bundle exporting test package", exportingBundles2);
-
- long[] importingBundlesId = packagaState
- .getImportingBundles("org.osgi.jmx.framework", "1.5.0", exportingBundles[0]);
- assertTrue("Should find bundles importing org.osgi.jmx.framework", importingBundlesId.length > 0);
-
- TabularData table = packagaState.listPackages();
- assertNotNull("TabularData containing CompositeData with packages info shouldn't be null", table);
- assertEquals("TabularData should be a type PACKAGES", PackageStateMBean.PACKAGES_TYPE, table.getTabularType());
- Collection colData = table.values();
- assertNotNull("Collection of CompositeData shouldn't be null", colData);
- assertFalse("Collection of CompositeData should contain elements", colData.isEmpty());
-
- boolean isRemovalPending = packagaState.isRemovalPending("org.osgi.jmx.framework", "1.5.0", exportingBundles[0]);
- assertFalse("Should removal pending on org.osgi.jmx.framework be false", isRemovalPending);
- */
+ private Map<Map<String, Object>, Map<String, String>> requirementsToMap(List<BundleRequirement> requirements) {
+ Map<Map<String, Object>, Map<String, String>> map = new HashMap<Map<String,Object>, Map<String,String>>();
+ for (BundleRequirement req : requirements) {
+ map.put(req.getAttributes(), req.getDirectives());
+ }
+ return map;
}
+ private Map<Map<String, Object>, Map<String, String>> jmxCapReqToMap(CompositeData[] jmxCapabilitiesOrRequirements) {
+ Map<Map<String, Object>, Map<String, String>> actualCapabilities = new HashMap<Map<String,Object>, Map<String,String>>();
+ for (CompositeData jmxCapReq : jmxCapabilitiesOrRequirements) {
+ Map<String, Object> aMap = getJmxAttributes(jmxCapReq);
+ Map<String, String> dMap = getJmxDirectives(jmxCapReq);
+ actualCapabilities.put(aMap, dMap);
+ }
+ return actualCapabilities;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, Object> getJmxAttributes(CompositeData jmxCapReq) {
+ TabularData jmxAttributes = (TabularData) jmxCapReq.get(BundleRevisionsStateMBean.ATTRIBUTES);
+ Map<String, Object> aMap = new HashMap<String, Object>();
+ for (CompositeData jmxAttr : (Collection<CompositeData>) jmxAttributes.values()) {
+ PropertyData<Object> pd = PropertyData.from(jmxAttr);
+ aMap.put(pd.getKey(), pd.getValue());
+ }
+ return aMap;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, String> getJmxDirectives(CompositeData jmxCapReq) {
+ TabularData jmxDirectives = (TabularData) jmxCapReq.get(BundleRevisionsStateMBean.DIRECTIVES);
+ Map<String, String> dMap = new HashMap<String, String>();
+ for (CompositeData jmxDir : (Collection<CompositeData>) jmxDirectives.values()) {
+ dMap.put((String) jmxDir.get(BundleRevisionsStateMBean.KEY), (String) jmxDir.get(BundleRevisionsStateMBean.VALUE));
+ }
+ return dMap;
+ }
}
Modified: aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java?rev=1199354&r1=1199353&r2=1199354&view=diff
==============================================================================
--- aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java (original)
+++ aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java Tue Nov 8 17:27:34 2011
@@ -28,13 +28,21 @@ import static org.ops4j.pax.swissbox.tin
import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
import static org.osgi.jmx.framework.BundleStateMBean.OBJECTNAME;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import org.apache.aries.jmx.AbstractIntegrationTest;
@@ -46,11 +54,11 @@ import org.ops4j.pax.exam.container.def.
import org.ops4j.pax.exam.junit.Configuration;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWiring;
import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
/**
* @version $Rev$ $Date$
@@ -109,10 +117,28 @@ public class BundleStateMBeanTest extend
.set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundled")
.set(Constants.BUNDLE_VERSION, "3.0.0")
.set(Constants.REQUIRE_BUNDLE, "org.apache.aries.jmx.test.bundlea;bundle-version=2.0.0")
+ .build(withBnd())),
+ provision(newBundle()
+ .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlee")
+ .set(Constants.BUNDLE_DESCRIPTION, "%desc")
+ .add("OSGI-INF/l10n/bundle.properties", getBundleProps("desc", "Description"))
+ .add("OSGI-INF/l10n/bundle_nl.properties", getBundleProps("desc", "Omschrijving"))
.build(withBnd()))
);
}
+ private static InputStream getBundleProps(String key, String value) {
+ try {
+ Properties p = new Properties();
+ p.put(key, value);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ p.store(baos, "");
+ return new ByteArrayInputStream(baos.toByteArray());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
@Override
public void doSetUp() throws Exception {
waitForMBean(new ObjectName(BundleStateMBean.OBJECTNAME));
@@ -265,12 +291,52 @@ public class BundleStateMBeanTest extend
}
+ @Test
+ @SuppressWarnings({ "unchecked" })
+ public void testHeaderLocalization() throws Exception {
+ BundleStateMBean mbean = getMBean(OBJECTNAME, BundleStateMBean.class);
+ Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundlee");
+
+ CompositeData cd = mbean.getBundle(b.getBundleId());
+ long id = (Long) cd.get(BundleStateMBean.IDENTIFIER);
+ assertEquals("Description", mbean.getHeader(id, Constants.BUNDLE_DESCRIPTION));
+ assertEquals("Description", mbean.getHeader(id, Constants.BUNDLE_DESCRIPTION, "en"));
+ assertEquals("Omschrijving", mbean.getHeader(id, Constants.BUNDLE_DESCRIPTION, "nl"));
+
+ TabularData td = mbean.getHeaders(id);
+ boolean found = false;
+ for (CompositeData d : (Collection<CompositeData>) td.values()) {
+ if (Constants.BUNDLE_DESCRIPTION.equals(d.get(BundleStateMBean.KEY))) {
+ assertEquals("Description", d.get(BundleStateMBean.VALUE));
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+
+ TabularData tdNL = mbean.getHeaders(id, "nl");
+ boolean foundNL = false;
+ for (CompositeData d : (Collection<CompositeData>) tdNL.values()) {
+ if (Constants.BUNDLE_DESCRIPTION.equals(d.get(BundleStateMBean.KEY))) {
+ assertEquals("Omschrijving", d.get(BundleStateMBean.VALUE));
+ foundNL = true;
+ break;
+ }
+ }
+ assertTrue(foundNL);
+ }
+
private Version getPackageVersion(String packageName) {
- ServiceReference paRef = context().getServiceReference(PackageAdmin.class.getName());
- PackageAdmin pa = (PackageAdmin) context().getService(paRef);
- ExportedPackage pkg = pa.getExportedPackage(packageName);
- Version version = pkg.getVersion();
- return version;
+ Bundle systemBundle = context().getBundle(0);
+ BundleWiring wiring = systemBundle.adapt(BundleWiring.class);
+ List<BundleCapability> packages = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
+ for (BundleCapability pkg : packages) {
+ Map<String, Object> attrs = pkg.getAttributes();
+ if (attrs.get(BundleRevision.PACKAGE_NAMESPACE).equals(packageName)) {
+ return (Version) attrs.get(Constants.VERSION_ATTRIBUTE);
+ }
+ }
+ throw new IllegalStateException("Package version not found for " + packageName);
}
private static boolean arrayContains(long value, long[] values) {
Modified: aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java?rev=1199354&r1=1199353&r2=1199354&view=diff
==============================================================================
--- aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java (original)
+++ aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java Tue Nov 8 17:27:34 2011
@@ -31,11 +31,15 @@ import static org.ops4j.pax.swissbox.tin
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import org.apache.aries.jmx.AbstractIntegrationTest;
@@ -66,6 +70,9 @@ public class ServiceStateMBeanTest exten
@Configuration
public static Option[] configuration() {
return testOptions(
+ // 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"),
paxLogging("INFO"),
@@ -110,10 +117,7 @@ public class ServiceStateMBeanTest exten
",org.osgi.service.cm")
.set(Constants.BUNDLE_ACTIVATOR,
org.apache.aries.jmx.test.bundleb.Activator.class.getName())
- .build(withBnd()))//,
- /* For debugging, uncomment the next two lines */
-// vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
-// waitForFrameworkStartup()
+ .build(withBnd()))
);
}
@@ -183,9 +187,10 @@ public class ServiceStateMBeanTest exten
// listServices
+ ServiceReference<?>[] allSvsRefs = bundleContext.getAllServiceReferences(null, null);
TabularData allServices = mbean.listServices();
assertNotNull(allServices);
- assertEquals(bundleContext.getAllServiceReferences(null, null).length, allServices.values().size());
+ assertEquals(allSvsRefs.length, allServices.values().size());
// notifications
@@ -222,4 +227,92 @@ public class ServiceStateMBeanTest exten
}
+ @Test
+ public void testGetServiceIds() throws Exception {
+ ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
+
+ ServiceReference<?>[] allSvsRefs = bundleContext.getAllServiceReferences(null, null);
+ long[] expectedServiceIds = new long[allSvsRefs.length];
+ for (int i=0; i < allSvsRefs.length; i++) {
+ expectedServiceIds[i] = (Long) allSvsRefs[i].getProperty(Constants.SERVICE_ID);
+ }
+ long[] actualServiceIds = mbean.getServiceIds();
+ Arrays.sort(expectedServiceIds);
+ Arrays.sort(actualServiceIds);
+ assertTrue(Arrays.equals(expectedServiceIds, actualServiceIds));
+ }
+
+ @Test
+ public void testGetServiceAndGetProperty() throws Exception {
+ ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
+
+ ServiceReference<InterfaceA> sref = bundleContext.getServiceReference(InterfaceA.class);
+ Long serviceID = (Long) sref.getProperty(Constants.SERVICE_ID);
+
+ CompositeData svcData = mbean.getService(serviceID);
+ assertEquals(serviceID, svcData.get(ServiceStateMBean.IDENTIFIER));
+ assertEquals(sref.getBundle().getBundleId(), svcData.get(ServiceStateMBean.BUNDLE_IDENTIFIER));
+ Set<String> expectedClasses = new HashSet<String>(Arrays.asList(InterfaceA.class.getName(), ManagedService.class.getName()));
+ Set<String> actualClasses = new HashSet<String>(Arrays.asList((String []) svcData.get(ServiceStateMBean.OBJECT_CLASS)));
+ assertEquals(expectedClasses, actualClasses);
+ Bundle[] ub = sref.getUsingBundles();
+ assertEquals("Precondition", 1, ub.length);
+ assertTrue(Arrays.equals(new Long[] {ub[0].getBundleId()}, (Long[]) svcData.get("UsingBundles")));
+
+ // Test mbean.getProperty()
+ String pid = (String) sref.getProperty(Constants.SERVICE_PID);
+ CompositeData pidData = mbean.getProperty(serviceID, Constants.SERVICE_PID);
+ assertEquals(pid, pidData.get("Value"));
+ assertEquals("String", pidData.get("Type"));
+
+ CompositeData idData = mbean.getProperty(serviceID, Constants.SERVICE_ID);
+ assertEquals("" + serviceID, idData.get("Value"));
+ assertEquals("Long", idData.get("Type"));
+
+ CompositeData ocData = mbean.getProperty(serviceID, Constants.OBJECTCLASS);
+ String form1 = InterfaceA.class.getName() + "," + ManagedService.class.getName();
+ String form2 = ManagedService.class.getName() + "," + InterfaceA.class.getName();
+ assertTrue(ocData.get("Value").equals(form1) ||
+ ocData.get("Value").equals(form2));
+ assertEquals("Array of String", ocData.get("Type"));
+ }
+
+ @Test
+ public void testListServices() throws Exception {
+ ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
+
+ String filter = "(" + Constants.SERVICE_PID + "=*)";
+ ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(null, filter);
+ TabularData svcData = mbean.listServices(null, filter);
+ assertEquals(refs.length, svcData.size());
+
+ ServiceReference<InterfaceA> sref = bundleContext.getServiceReference(InterfaceA.class);
+ TabularData svcTab = mbean.listServices(InterfaceA.class.getName(), null);
+ assertEquals(1, svcTab.size());
+ CompositeData actualSvc = (CompositeData) svcTab.values().iterator().next();
+ CompositeData expectedSvc = mbean.getService((Long) sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(expectedSvc, actualSvc);
+ }
+
+ @Test
+ public void testListServicesSelectiveItems() throws Exception {
+ ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
+
+ String filter = "(|(service.pid=org.apache.aries.jmx.test.ServiceB)(service.pid=jmx.test.B.factory))";
+ ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(null, filter);
+ TabularData svcData = mbean.listServices(null, filter, ServiceStateMBean.BUNDLE_IDENTIFIER);
+ assertEquals(refs.length, svcData.size());
+
+ long id = refs[0].getBundle().getBundleId();
+ for (ServiceReference<?> ref : refs) {
+ assertEquals("Precondition", id, ref.getBundle().getBundleId());
+ }
+
+ for (CompositeData cd : new ArrayList<CompositeData>((Collection<CompositeData>) svcData.values())) {
+ assertEquals(id, cd.get(ServiceStateMBean.BUNDLE_IDENTIFIER));
+ assertNotNull(cd.get(ServiceStateMBean.IDENTIFIER));
+ assertNull(cd.get(ServiceStateMBean.OBJECT_CLASS));
+ assertNull(cd.get(ServiceStateMBean.USING_BUNDLES));
+ }
+ }
}
Propchange: aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 8 17:27:34 2011
@@ -0,0 +1 @@
+/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java:1189798-1199347
Propchange: aries/branches/oct-2011-release/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/framework/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 8 17:27:34 2011
@@ -1 +1 @@
-/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/framework:1189122-1190455
+/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/framework:1189122-1199347