You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by tj...@apache.org on 2014/06/30 18:55:06 UTC

svn commit: r1606837 [12/27] - in /aries/branches/subsystemsR6: ./ application/ application/application-api/ application/application-bundle/ application/application-converters/ application/application-default-local-platform/ application/application-dep...

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -20,17 +20,11 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
-import static org.apache.aries.itest.ExtraOptions.*;
-
-import java.io.InputStream;
 import java.util.Dictionary;
 
-import javax.management.ObjectName;
+import javax.inject.Inject;
 import javax.management.openmbean.TabularData;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
@@ -38,18 +32,15 @@ import org.apache.aries.jmx.codec.Proper
 import org.apache.aries.jmx.test.bundlea.api.InterfaceA;
 import org.apache.aries.jmx.test.bundleb.api.InterfaceB;
 import org.apache.aries.jmx.test.bundleb.api.MSF;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Customizer;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
 import org.osgi.jmx.service.cm.ConfigurationAdminMBean;
 import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * 
@@ -57,57 +48,32 @@ import org.osgi.util.tracker.ServiceTrac
  * @version $Rev$ $Date$
  */
 public class ConfigurationAdminMBeanTest extends AbstractIntegrationTest {
+	private ConfigurationAdminMBean mbean;
+	
+	@Inject
+	InterfaceA managedServiceA; 
+	
+	@Inject
+	@org.ops4j.pax.exam.util.Filter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)")
+    MSF managedFactory;
+	
+	@Inject
+    ConfigurationAdmin configAdmin;
 
     @Configuration
-    public static Option[] configuration() {
-        return testOptions(
-                        CoreOptions.equinox(),
-                        paxLogging("INFO"),
-                        
-                        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
-                        mavenBundle("org.osgi", "org.osgi.compendium"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-                        new Customizer() {
-                            public InputStream customizeTestProbe(InputStream testProbe) throws Exception {
-                                return modifyBundle(testProbe)
-                                           .removeHeader(Constants.DYNAMICIMPORT_PACKAGE)
-                                           .set(Constants.REQUIRE_BUNDLE, "org.apache.aries.jmx.test.bundlea,org.apache.aries.jmx.test.bundleb")
-                                           .build(withBnd());
-                            }
-                        },
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundlea.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                                .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                                .set(Constants.BUNDLE_VERSION, "2.0.0")
-                                .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api;version=2.0.0")
-                                .set(Constants.IMPORT_PACKAGE,
-                                        "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional" +
-                                        ",org.osgi.service.cm")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundlea.Activator.class.getName())
-                                .build(withBnd())),
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundleb.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.MSF.class)
-                                .add(org.apache.aries.jmx.test.bundleb.impl.B.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.aries.jmx.test.bundleb")
-                                .set(Constants.BUNDLE_VERSION, "1.0.0")
-                                .set(Constants.EXPORT_PACKAGE,"org.apache.aries.jmx.test.bundleb.api;version=1.1.0")
-                                .set(Constants.IMPORT_PACKAGE,"org.osgi.framework;version=1.5.0,org.osgi.util.tracker" +
-                                        ",org.osgi.service.cm")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundleb.Activator.class.getName())
-                                .build(withBnd()))
-                        );
+    public Option[] configuration() {
+		return options(
+				jmxRuntime(), 
+				bundlea(),
+				bundleb()
+				);
     }
     
-    @Override
+    @Before
     public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(ConfigurationAdminMBean.OBJECTNAME));
+        waitForMBean(ConfigurationAdminMBean.OBJECTNAME);
+        mbean = getMBean(ConfigurationAdminMBean.OBJECTNAME, ConfigurationAdminMBean.class);
+        assertNotNull(mbean);
     }
     
     @Ignore("ManagedServiceFactory tests failing.. " +
@@ -115,39 +81,10 @@ public class ConfigurationAdminMBeanTest
     @Test
     @SuppressWarnings("unchecked")
     public void testMBeanInterface() throws Exception {
-        
-        ConfigurationAdminMBean mbean = getMBean(ConfigurationAdminMBean.OBJECTNAME, ConfigurationAdminMBean.class);
-        assertNotNull(mbean);
-       
         // get bundles
-        
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        assertNotNull(a);
-        
-        Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
-        assertNotNull(b);
-       
-        
-        // get services
-        
-        ServiceTracker trackerA = new ServiceTracker(bundleContext, InterfaceA.class.getName(), null);
-        trackerA.open();
-        InterfaceA managedServiceA = (InterfaceA) trackerA.getService();
-        assertNotNull(managedServiceA);
-        
-        Filter filter = bundleContext.createFilter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)");
-        ServiceTracker trackerMSF = new ServiceTracker(bundleContext, filter, null);
-        trackerMSF.open();
-        MSF managedFactory = (MSF) trackerMSF.getService();
-        assertNotNull(managedFactory);
-        
-        ServiceTracker tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
-        tracker.open();
-        ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.getService();
-        assertNotNull(configAdmin);
+        Bundle a = getBundleByName("org.apache.aries.jmx.test.bundlea");
         
         // ManagedService operations
-        
         assertNull(managedServiceA.getConfig());
         
         // create a configuration for A
@@ -171,13 +108,11 @@ public class ConfigurationAdminMBeanTest
         
         //delete
         mbean.deleteForLocation("org.apache.aries.jmx.test.ServiceA", a.getLocation());
-        
         Thread.sleep(1000);
         assertNull(managedServiceA.getConfig());
         
         
         // ManagedServiceFactory operations
-        
         String cpid = mbean.createFactoryConfiguration("jmx.test.B.factory");
         assertNotNull(cpid);
         assertTrue(cpid.contains("jmx.test.B.factory"));
@@ -245,11 +180,5 @@ public class ConfigurationAdminMBeanTest
         
         assertNull(managedServiceA.getConfig());
         
-        //clean up
-        
-        trackerA.close();
-        trackerMSF.close();
-        tracker.close();
-        
     }
 }

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,21 +16,15 @@
  */
 package org.apache.aries.jmx.framework;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+import static org.ops4j.pax.exam.CoreOptions.options;
 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;
@@ -39,7 +33,6 @@ import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
@@ -54,11 +47,12 @@ import javax.management.openmbean.Tabula
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.BundleData.Header;
+import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
@@ -70,85 +64,38 @@ import org.osgi.jmx.framework.BundleStat
 /**
  * @version $Rev$ $Date$
  */
+@ExamReactorStrategy(PerMethod.class)
 public class BundleStateMBeanTest 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 ),
-
-                        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-                        CoreOptions.equinox().version("3.8.0.V20120529-1548"),
-                        paxLogging("INFO"),
-
-                        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
-                        mavenBundle("org.osgi", "org.osgi.compendium"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-                        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundlea.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                                .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                                .set(Constants.BUNDLE_VERSION, "2.0.0")
-                                .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api;version=2.0.0")
-                                .set(Constants.IMPORT_PACKAGE,
-                                        "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional" +
-                                        ",org.osgi.service.cm")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundlea.Activator.class.getName())
-                                .build(withBnd())),
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundleb.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.MSF.class)
-                                .add(org.apache.aries.jmx.test.bundleb.impl.B.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.aries.jmx.test.bundleb")
-                                .set(Constants.BUNDLE_VERSION, "1.0.0")
-                                .set(Constants.EXPORT_PACKAGE,"org.apache.aries.jmx.test.bundleb.api;version=1.1.0")
-                                .set(Constants.IMPORT_PACKAGE,"org.osgi.framework;version=1.5.0,org.osgi.util.tracker," +
-                                		"org.osgi.service.cm,org.apache.aries.jmx.test.fragmentc")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundleb.Activator.class.getName())
-                                .build(withBnd())),
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.fragmentc.C.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.fragc")
-                                .set(Constants.FRAGMENT_HOST, "org.apache.aries.jmx.test.bundlea")
-                                .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.fragmentc")
-                                .build(withBnd())),
-                        provision(newBundle()
-                                .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 ObjectName objectName;
+	private BundleStateMBean mbean;
+	private Bundle a;
+	private Bundle b;
+	private Bundle fragc;
+	private Bundle d;
+
+	@Configuration
+    public Option[] configuration() {
+		return options(
+				// new VMOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"),
+				// new TimeoutOption( 0 ),
+				jmxRuntime(), 
+				bundlea(),
+				bundleb(),
+				fragmentc(),
+				bundled(),
+				bundlee());
     }
 
-    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
+    @Before
     public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(BundleStateMBean.OBJECTNAME));
+    	objectName = waitForMBean(BundleStateMBean.OBJECTNAME);
+        mbean = getMBean(BundleStateMBean.OBJECTNAME, BundleStateMBean.class);
+        //get bundles
+        a = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        b = getBundleByName("org.apache.aries.jmx.test.bundleb");
+        fragc = getBundleByName("org.apache.aries.jmx.test.fragc");
+        d = getBundleByName("org.apache.aries.jmx.test.bundled");
     }
 
     @Test
@@ -163,128 +110,88 @@ public class BundleStateMBeanTest extend
 
     @Test
     public void testMBeanInterface() throws Exception {
-        ObjectName objectName = waitForMBean(new ObjectName(BundleStateMBean.OBJECTNAME));
-
-        BundleStateMBean mbean = getMBean(objectName, BundleStateMBean.class);
-        assertNotNull(mbean);
-
-        //get bundles
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        assertNotNull(a);
-
-        Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
-        assertNotNull(b);
-
-        Bundle frag = context().getBundleByName("org.apache.aries.jmx.test.fragc");
-        assertNotNull(frag);
-
-        Bundle d = context().getBundleByName("org.apache.aries.jmx.test.bundled");
-        assertNotNull(d);
-
         // exportedPackages
-
         String[] exports = mbean.getExportedPackages(a.getBundleId());
         assertEquals(2, exports.length);
-
         List<String> packages = Arrays.asList(exports);
         assertTrue(packages.contains("org.apache.aries.jmx.test.bundlea.api;2.0.0"));
         assertTrue(packages.contains("org.apache.aries.jmx.test.fragmentc;0.0.0"));
 
-        //fragments
-
+        // fragments
         long[] fragments = mbean.getFragments(a.getBundleId());
         assertEquals(1, fragments.length);
-        assertEquals(frag.getBundleId() , fragments[0]);
-
-        //headers
+        assertEquals(fragc.getBundleId() , fragments[0]);
 
+        // headers
         TabularData headers = mbean.getHeaders(b.getBundleId());
         assertNotNull(headers);
         assertEquals(BundleStateMBean.HEADERS_TYPE, headers.getTabularType());
         assertTrue(headers.values().size() >= 4 );
         assertEquals("org.apache.aries.jmx.test.bundleb", Header.from(headers.get(new Object[] {Constants.BUNDLE_SYMBOLICNAME})).getValue());
 
-        //hosts
-
-        long[] hosts = mbean.getHosts(frag.getBundleId());
+        // hosts
+        long[] hosts = mbean.getHosts(fragc.getBundleId());
         assertEquals(1, hosts.length);
         assertEquals(a.getBundleId() , hosts[0]);
 
         //imported packages
-
         String[] imports = mbean.getImportedPackages(a.getBundleId());
         assertTrue(imports.length >= 3);
         List<String> importedPackages = Arrays.asList(imports);
-
         Version version = getPackageVersion("org.osgi.framework");
         assertTrue(importedPackages.contains("org.osgi.framework;" + version.toString()));
         assertTrue(importedPackages.contains("org.apache.aries.jmx.test.bundleb.api;1.1.0"));
 
         //last modified
-
         assertTrue(mbean.getLastModified(b.getBundleId()) > 0);
 
         //location
-
         assertEquals(b.getLocation(), mbean.getLocation(b.getBundleId()));
 
         //registered services
-
         long[] serviceIds = mbean.getRegisteredServices(a.getBundleId());
         assertEquals(1, serviceIds.length);
 
         //required bundles
-
         long[] required = mbean.getRequiredBundles(d.getBundleId());
         assertEquals(1, required.length);
         assertEquals(a.getBundleId(), required[0]);
 
         //requiring bundles
-
         long[] requiring = mbean.getRequiringBundles(a.getBundleId());
-        assertEquals(3, requiring.length);
-        assertTrue(b.getSymbolicName(), arrayContains(b.getBundleId(), requiring));
-        assertTrue(frag.getSymbolicName(), arrayContains(frag.getBundleId(), requiring));
+        assertEquals(2, requiring.length);
+        assertTrue(fragc.getSymbolicName(), arrayContains(fragc.getBundleId(), requiring));
         assertTrue(d.getSymbolicName(), arrayContains(d.getBundleId(), requiring));
 
         //services in use
-
         long[] servicesInUse = mbean.getServicesInUse(a.getBundleId());
         assertEquals(1, servicesInUse.length);
 
         //start level
-
         long startLevel = mbean.getStartLevel(b.getBundleId());
         assertTrue(startLevel >= 0);
 
         //state
-
         assertEquals("ACTIVE", mbean.getState(b.getBundleId()));
 
         //isFragment
-
         assertFalse(mbean.isFragment(b.getBundleId()));
-        assertTrue(mbean.isFragment(frag.getBundleId()));
+        assertTrue(mbean.isFragment(fragc.getBundleId()));
 
         //isRemovalPending
         assertFalse(mbean.isRemovalPending(b.getBundleId()));
 
         // isRequired
-
         assertTrue(mbean.isRequired(a.getBundleId()));
         assertTrue(mbean.isRequired(b.getBundleId()));
 
         // listBundles
-
         TabularData bundlesTable = mbean.listBundles();
         assertNotNull(bundlesTable);
         assertEquals(BundleStateMBean.BUNDLES_TYPE, bundlesTable.getTabularType());
         assertEquals(bundleContext.getBundles().length, bundlesTable.values().size());
 
-
         // notifications
-
         final List<Notification> received = new ArrayList<Notification>();
 
         mbeanServer.addNotificationListener(objectName, new NotificationListener() {
@@ -310,9 +217,6 @@ public class BundleStateMBeanTest extend
 
     @Test
     public void testAttributeChangeNotifications() throws Exception {
-        ObjectName objectName = waitForMBean(new ObjectName(BundleStateMBean.OBJECTNAME));
-        BundleStateMBean mbean = getMBean(objectName, BundleStateMBean.class);
-
         final List<AttributeChangeNotification> attributeChanges = new ArrayList<AttributeChangeNotification>();
         AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
         filter.disableAllAttributes();
@@ -349,7 +253,7 @@ public class BundleStateMBeanTest extend
         assertEquals(1, attributeChanges.size());
         AttributeChangeNotification ac = attributeChanges.get(0);
         assertEquals("BundleIds", ac.getAttributeName());
-        assertEquals(1, ac.getSequenceNumber());
+        long oldSequence = ac.getSequenceNumber();
         assertTrue(Arrays.equals(idsWithout, (long []) ac.getOldValue()));
         assertTrue(Arrays.equals(idsWith, (long []) ac.getNewValue()));
 
@@ -358,7 +262,7 @@ public class BundleStateMBeanTest extend
         waitForListToReachSize(attributeChanges, 2);
         AttributeChangeNotification ac2 = attributeChanges.get(1);
         assertEquals("BundleIds", ac2.getAttributeName());
-        assertEquals(2, ac2.getSequenceNumber());
+        assertEquals(oldSequence +1, ac2.getSequenceNumber());
         assertTrue(Arrays.equals(idsWith, (long []) ac2.getOldValue()));
         assertTrue(Arrays.equals(idsWithout, (long []) ac2.getNewValue()));
     }
@@ -383,10 +287,9 @@ 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");
+        Bundle bundleE = context().getBundleByName("org.apache.aries.jmx.test.bundlee");
 
-        CompositeData cd = mbean.getBundle(b.getBundleId());
+        CompositeData cd = mbean.getBundle(bundleE.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"));
@@ -417,7 +320,7 @@ public class BundleStateMBeanTest extend
 
     private Version getPackageVersion(String packageName) {
         Bundle systemBundle = context().getBundle(0);
-        BundleWiring wiring = systemBundle.adapt(BundleWiring.class);
+        BundleWiring wiring = (BundleWiring) systemBundle.adapt(BundleWiring.class);
         List<BundleCapability> packages = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
         for (BundleCapability pkg : packages) {
             Map<String, Object> attrs = pkg.getAttributes();

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,17 +16,14 @@
  */
 package org.apache.aries.jmx.framework;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -53,12 +50,15 @@ import javax.management.openmbean.Compos
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.BatchActionResult;
+import org.junit.Before;
 import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 import org.osgi.framework.wiring.BundleRevision;
@@ -71,42 +71,49 @@ import org.osgi.jmx.framework.FrameworkM
 /**
  * @version $Rev$ $Date$
  */
+@ExamReactorStrategy(PerMethod.class)
 public class FrameworkMBeanTest extends AbstractIntegrationTest {
 
-    @Configuration
-    public static Option[] configuration() {
-        return testOptions(
+    private FrameworkMBean framework;
+
+	@Configuration
+    public Option[] configuration() {
+        return CoreOptions.options(
             // 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.8.0.V20120529-1548"),
-            paxLogging("INFO"),
-
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-            mavenBundle("org.apache.aries", "org.apache.aries.util"),
-
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                    .add(org.apache.aries.jmx.test.bundlea.impl.A2.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                    .set(Constants.BUNDLE_VERSION, "1")
-                    .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api")
-                    .build(withBnd())),
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundleb")
-                    .set(Constants.IMPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api," +
-                            "org.apache.aries.jmx.test.bundlea.impl;resolution:=optional")
-                    .build(withBnd()))
+            jmxRuntime(),
+            bundlea1(),
+            bundleb1()
         );
     }
-
-    @Override
-    public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(FrameworkMBean.OBJECTNAME));
+    
+	protected Option bundlea1() {
+		return provision(bundle()
+		        .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
+		        .add(org.apache.aries.jmx.test.bundlea.impl.A2.class)
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
+		        .set(Constants.BUNDLE_VERSION, "1")
+		        .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api")
+		        .build(withBnd()));
+	}
+	
+	protected Option bundleb1() {
+		return provision(bundle()
+		        .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundleb")
+		        .set(Constants.IMPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api," +
+		                "org.apache.aries.jmx.test.bundlea.impl;resolution:=optional")
+		        .build(withBnd()));
+	}
+
+    @Before
+    public void doSetUp() throws BundleException {
+    	for (Bundle bundle : context().getBundles()) {
+			System.out.println(bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getState());
+		};
+        waitForMBean(FrameworkMBean.OBJECTNAME);
+        framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
     }
 
     @Test
@@ -121,8 +128,6 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testGetProperty() throws Exception {
-        FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
-
         String expectedVer = context().getProperty(Constants.FRAMEWORK_VERSION);
         String actualVer = framework.getProperty(Constants.FRAMEWORK_VERSION);
         assertEquals(expectedVer, actualVer);
@@ -134,12 +139,10 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testGetDependencyClosure() throws Exception {
-        FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
+        Bundle bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        Bundle bundleB = getBundleByName("org.apache.aries.jmx.test.bundleb");
 
-        Bundle bundleA = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        Bundle bundleB = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
-
-        BundleWiring bw = bundleB.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleB.adapt(BundleWiring.class);
 
         List<BundleWire> initialRequiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(1, initialRequiredWires.size());
@@ -149,7 +152,7 @@ public class FrameworkMBeanTest extends 
         assertEquals("Precondition", new Version("1.0"), capabilityAttributes.get(Constants.BUNDLE_VERSION_ATTRIBUTE));
         assertEquals("Precondition", "org.apache.aries.jmx.test.bundlea.api", capabilityAttributes.get(BundleRevision.PACKAGE_NAMESPACE));
 
-        Collection<Bundle> expectedDC = context().getBundle(0).adapt(FrameworkWiring.class).getDependencyClosure(Collections.singleton(bundleA));
+        Collection<Bundle> expectedDC = ((FrameworkWiring) context().getBundle(0).adapt(FrameworkWiring.class)).getDependencyClosure(Collections.singleton(bundleA));
         Set<Long> expectedClosure = new TreeSet<Long>();
         for (Bundle b : expectedDC) {
             expectedClosure.add(b.getBundleId());
@@ -166,13 +169,12 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testRefreshBundleAndWait() throws Exception {
-        FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
-        FrameworkWiring frameworkWiring = context().getBundle(0).adapt(FrameworkWiring.class);
+        FrameworkWiring frameworkWiring = (FrameworkWiring) context().getBundle(0).adapt(FrameworkWiring.class);
 
-        Bundle bundleA = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        Bundle bundleB = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
+        Bundle bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        Bundle bundleB = getBundleByName("org.apache.aries.jmx.test.bundleb");
 
-        BundleWiring bw = bundleB.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleB.adapt(BundleWiring.class);
 
         List<BundleWire> initialRequiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(1, initialRequiredWires.size());
@@ -198,20 +200,20 @@ public class FrameworkMBeanTest extends 
         assertEquals("Precondition", 0, frameworkWiring.getRemovalPendingBundles().size());
         assertEquals(0, framework.getRemovalPendingBundles().length);
 
-        assertEquals("Precondition", 1, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("Precondition", 1, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         bundleA.update(new ByteArrayInputStream(baos.toByteArray()));
-        assertEquals("There should be 2 revisions now", 2, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("There should be 2 revisions now", 2, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         assertEquals("No refresh called, the bundle wiring for B should still be the old one",
                 bw, bundleB.adapt(BundleWiring.class));
 
         assertEquals("Precondition", 1, frameworkWiring.getRemovalPendingBundles().size());
         assertEquals(1, framework.getRemovalPendingBundles().length);
-        assertEquals(frameworkWiring.getRemovalPendingBundles().iterator().next().getBundleId(),
+        assertEquals(((Bundle) frameworkWiring.getRemovalPendingBundles().iterator().next()).getBundleId(),
                 framework.getRemovalPendingBundles()[0]);
 
         assertTrue(framework.refreshBundleAndWait(bundleB.getBundleId()));
 
-        List<BundleWire> requiredWires = bundleB.adapt(BundleWiring.class).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
+        List<BundleWire> requiredWires = ((BundleWiring) bundleB.adapt(BundleWiring.class)).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(2, requiredWires.size());
         List<String> imported = new ArrayList<String>();
         for (BundleWire w : requiredWires) {
@@ -230,10 +232,10 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testRefreshBundlesAndWait() throws Exception {
-        Bundle bundleA = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        Bundle bundleB = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
+        Bundle bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        Bundle bundleB = getBundleByName("org.apache.aries.jmx.test.bundleb");
 
-        BundleWiring bw = bundleB.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleB.adapt(BundleWiring.class);
 
         List<BundleWire> initialRequiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(1, initialRequiredWires.size());
@@ -256,9 +258,9 @@ public class FrameworkMBeanTest extends 
         addResourceToJar("org/apache/aries/jmx/test/bundlea/impl/A2.class", jos, bundleA);
         jos.close();
 
-        assertEquals("Precondition", 1, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("Precondition", 1, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         bundleA.update(new ByteArrayInputStream(baos.toByteArray()));
-        assertEquals("There should be 2 revisions now", 2, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("There should be 2 revisions now", 2, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         assertEquals("No refresh called, the bundle wiring for B should still be the old one",
                 bw, bundleB.adapt(BundleWiring.class));
 
@@ -267,7 +269,7 @@ public class FrameworkMBeanTest extends 
         assertTrue((Boolean) result.get(FrameworkMBean.SUCCESS));
         assertTrue(Arrays.equals(new Long[] {bundleB.getBundleId()}, (Long []) result.get(FrameworkMBean.COMPLETED)));
 
-        List<BundleWire> requiredWires = bundleB.adapt(BundleWiring.class).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
+        List<BundleWire> requiredWires = ((BundleWiring) bundleB.adapt(BundleWiring.class)).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(2, requiredWires.size());
         List<String> imported = new ArrayList<String>();
         for (BundleWire w : requiredWires) {
@@ -286,10 +288,10 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testRefreshBundlesAndWait2() throws Exception {
-        Bundle bundleA = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        Bundle bundleB = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
+        Bundle bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        Bundle bundleB = getBundleByName("org.apache.aries.jmx.test.bundleb");
 
-        BundleWiring bw = bundleB.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleB.adapt(BundleWiring.class);
 
         List<BundleWire> initialRequiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(1, initialRequiredWires.size());
@@ -312,11 +314,11 @@ public class FrameworkMBeanTest extends 
         addResourceToJar("org/apache/aries/jmx/test/bundlea/impl/A2.class", jos, bundleA);
         jos.close();
 
-        assertEquals("Precondition", 1, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("Precondition", 1, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         bundleA.update(new ByteArrayInputStream(baos.toByteArray()));
-        assertEquals("There should be 2 revisions now", 2, bundleA.adapt(BundleRevisions.class).getRevisions().size());
+        assertEquals("There should be 2 revisions now", 2, ((BundleRevisions) bundleA.adapt(BundleRevisions.class)).getRevisions().size());
         assertEquals("No refresh called, the bundle wiring for B should still be the old one",
-                bw, bundleB.adapt(BundleWiring.class));
+                bw, ((BundleWiring) bundleB.adapt(BundleWiring.class)));
 
         FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
         CompositeData result = framework.refreshBundlesAndWait(null);
@@ -324,7 +326,7 @@ public class FrameworkMBeanTest extends 
         assertTrue(completed.contains(bundleA.getBundleId()));
         assertTrue(completed.contains(bundleB.getBundleId()));
 
-        List<BundleWire> requiredWires = bundleB.adapt(BundleWiring.class).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
+        List<BundleWire> requiredWires = ((BundleWiring) bundleB.adapt(BundleWiring.class)).getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
         assertEquals(2, requiredWires.size());
         List<String> imported = new ArrayList<String>();
         for (BundleWire w : requiredWires) {
@@ -354,9 +356,6 @@ public class FrameworkMBeanTest extends 
 
     @Test
     public void testMBeanInterface() throws IOException {
-        FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
-        assertNotNull(framework);
-
         long[] bundleIds = new long[]{1,2};
         int[] newlevels = new int[]{1,1};
         CompositeData compData = framework.setBundleStartLevels(bundleIds, newlevels);

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,14 +16,12 @@
  */
 package org.apache.aries.jmx.framework;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -34,11 +32,10 @@ import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
+import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.Configuration;
 import org.osgi.framework.Constants;
 import org.osgi.jmx.framework.PackageStateMBean;
 
@@ -50,20 +47,16 @@ import org.osgi.jmx.framework.PackageSta
 public class PackageStateMBeanTest extends AbstractIntegrationTest {
 
     @Configuration
-    public static Option[] configuration() {
-        return testOptions(
-            PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-            CoreOptions.equinox().version("3.8.0.V20120529-1548"),
-            paxLogging("INFO"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-            mavenBundle("org.apache.aries", "org.apache.aries.util"));
+    public Option[] configuration() {
+        return options(
+        		jmxRuntime(),
+        		bundlea()
+        		);
     }
 
-    @Override
-    public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(PackageStateMBean.OBJECTNAME));
+    @Before
+    public void doSetUp() {
+        waitForMBean(PackageStateMBean.OBJECTNAME);
     }
 
     @Test
@@ -95,7 +88,7 @@ public class PackageStateMBeanTest exten
         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();
+        Collection<?> colData = table.values();
         assertNotNull("Collection of CompositeData shouldn't be null", colData);
         assertFalse("Collection of CompositeData should contain elements", colData.isEmpty());
 

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,19 +16,12 @@
  */
 package org.apache.aries.jmx.framework;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -47,16 +40,18 @@ import javax.management.ObjectName;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.TabularData;
 
+import junit.framework.Assert;
+
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.PropertyData;
 import org.apache.aries.jmx.test.bundlea.api.InterfaceA;
 import org.apache.aries.jmx.test.bundleb.api.InterfaceB;
+import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Customizer;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -71,65 +66,29 @@ import org.osgi.service.cm.ManagedServic
  *
  * @version $Rev$ $Date$
  */
+@ExamReactorStrategy(PerMethod.class)
 public class ServiceStateMBeanTest extends AbstractIntegrationTest {
+	
+    private ObjectName objectName;
+	private ServiceStateMBean mbean;
 
     @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.8.0.V20120529-1548"),
-                        paxLogging("INFO"),
-
-                        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
-                        mavenBundle("org.osgi", "org.osgi.compendium"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-                        mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-                        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-
-                        new Customizer() {
-                            public InputStream customizeTestProbe(InputStream testProbe) throws Exception {
-                                return modifyBundle(testProbe)
-                                           .removeHeader(Constants.DYNAMICIMPORT_PACKAGE)
-                                           .set(Constants.REQUIRE_BUNDLE, "org.apache.aries.jmx.test.bundlea,org.apache.aries.jmx.test.bundleb")
-                                           .build(withBnd());
-                            }
-                        },
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundlea.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                                .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                                .set(Constants.BUNDLE_VERSION, "2.0.0")
-                                .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api;version=2.0.0")
-                                .set(Constants.IMPORT_PACKAGE,
-                                        "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional" +
-                                        ",org.osgi.service.cm")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundlea.Activator.class.getName())
-                                .build(withBnd())),
-                        provision(newBundle()
-                                .add(org.apache.aries.jmx.test.bundleb.Activator.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
-                                .add(org.apache.aries.jmx.test.bundleb.api.MSF.class)
-                                .add(org.apache.aries.jmx.test.bundleb.impl.B.class)
-                                .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.aries.jmx.test.bundleb")
-                                .set(Constants.BUNDLE_VERSION, "1.0.0")
-                                .set(Constants.EXPORT_PACKAGE,"org.apache.aries.jmx.test.bundleb.api;version=1.1.0")
-                                .set(Constants.IMPORT_PACKAGE,"org.osgi.framework;version=1.5.0,org.osgi.util.tracker" +
-                                		",org.osgi.service.cm")
-                                .set(Constants.BUNDLE_ACTIVATOR,
-                                        org.apache.aries.jmx.test.bundleb.Activator.class.getName())
-                                .build(withBnd()))
-                        );
-    }
-
-    @Override
-    public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(ServiceStateMBean.OBJECTNAME));
+    public Option[] configuration() {
+		return options(
+		        // new VMOption( "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" ),
+		        // new TimeoutOption( 0 ),
+				jmxRuntime(), 
+				bundlea(), 
+				bundleb()
+				);
+    }
+    
+    @Before
+    public void doSetUp() {
+        waitForMBean(ServiceStateMBean.OBJECTNAME);
+        objectName = waitForMBean(ServiceStateMBean.OBJECTNAME);
+        mbean = getMBean(objectName, ServiceStateMBean.class);
+        assertNotNull(mbean);
     }
 
     @Test
@@ -144,18 +103,11 @@ public class ServiceStateMBeanTest exten
 
     @Test
     public void testMBeanInterface() throws Exception {
-        ObjectName objectName = waitForMBean(new ObjectName(ServiceStateMBean.OBJECTNAME));
-
-        ServiceStateMBean mbean = getMBean(objectName, ServiceStateMBean.class);
-        assertNotNull(mbean);
-
         //get bundles
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        assertNotNull(a);
-
-        Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
-        assertNotNull(b);
+        Bundle a = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        assertBundleStarted(a);
+        Bundle b = getBundleByName("org.apache.aries.jmx.test.bundleb");
+        assertBundleStarted(b);
 
         // get services
 
@@ -204,7 +156,7 @@ public class ServiceStateMBeanTest exten
 
         // listServices
 
-        ServiceReference<?>[] allSvsRefs = bundleContext.getAllServiceReferences(null, null);
+        ServiceReference[] allSvsRefs = bundleContext.getAllServiceReferences(null, null);
         TabularData allServices = mbean.listServices();
         assertNotNull(allServices);
         assertEquals(allSvsRefs.length, allServices.values().size());
@@ -245,11 +197,13 @@ public class ServiceStateMBeanTest exten
         assertEquals(4, attributeChanges.size());
     }
 
-    @Test
-    public void testAttributeChangeNotifications() throws Exception {
-        ObjectName objectName = waitForMBean(new ObjectName(ServiceStateMBean.OBJECTNAME));
-        ServiceStateMBean mbean = getMBean(objectName, ServiceStateMBean.class);
+	private void assertBundleStarted(Bundle bundle) {
+		Assert.assertEquals("Bundle " + bundle.getSymbolicName() + " should be started but is in state " + bundle.getState(),
+				Bundle.ACTIVE, bundle.getState());
+	}
 
+	@Test
+    public void testAttributeChangeNotifications() throws Exception {
         final List<AttributeChangeNotification> attributeChanges = new ArrayList<AttributeChangeNotification>();
         mbeanServer.addNotificationListener(objectName, new NotificationListener() {
             public void handleNotification(Notification notification, Object handback) {
@@ -264,7 +218,7 @@ public class ServiceStateMBeanTest exten
         long[] idsWithout = mbean.getServiceIds();
 
         String svc = "A String Service";
-        ServiceRegistration<?> reg = bundleContext.registerService(String.class.getName(), svc, null);
+        ServiceRegistration reg = bundleContext.registerService(String.class.getName(), svc, null);
         long id = (Long) reg.getReference().getProperty(Constants.SERVICE_ID);
 
         long[] idsWith = new long[idsWithout.length + 1];
@@ -275,7 +229,7 @@ public class ServiceStateMBeanTest exten
         waitForListToReachSize(attributeChanges, 1);
         AttributeChangeNotification ac = attributeChanges.get(0);
         assertEquals("ServiceIds", ac.getAttributeName());
-        assertEquals(1, ac.getSequenceNumber());
+        long seq1 = ac.getSequenceNumber();
         assertTrue(Arrays.equals(idsWithout, (long []) ac.getOldValue()));
         assertTrue(Arrays.equals(idsWith, (long []) ac.getNewValue()));
 
@@ -293,16 +247,14 @@ public class ServiceStateMBeanTest exten
         waitForListToReachSize(attributeChanges, 2);
         AttributeChangeNotification ac2 = attributeChanges.get(1);
         assertEquals("ServiceIds", ac2.getAttributeName());
-        assertEquals(2, ac2.getSequenceNumber());
+        assertEquals(seq1 +1, ac2.getSequenceNumber());
         assertTrue(Arrays.equals(idsWith, (long []) ac2.getOldValue()));
         assertTrue(Arrays.equals(idsWithout, (long []) ac2.getNewValue()));
     }
 
     @Test
     public void testGetServiceIds() throws Exception {
-        ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
-
-        ServiceReference<?>[] allSvsRefs = bundleContext.getAllServiceReferences(null, null);
+        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);
@@ -315,9 +267,10 @@ public class ServiceStateMBeanTest exten
 
     @Test
     public void testGetServiceAndGetProperty() throws Exception {
-        ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
-
-        ServiceReference<InterfaceA> sref = bundleContext.getServiceReference(InterfaceA.class);
+    	
+        ServiceReference sref = bundleContext.getServiceReference(InterfaceA.class);
+        // Get service to increase service references
+        context().getService(sref);
         Long serviceID = (Long) sref.getProperty(Constants.SERVICE_ID);
 
         CompositeData svcData  = mbean.getService(serviceID);
@@ -346,16 +299,15 @@ public class ServiceStateMBeanTest exten
         assertTrue(ocData.get("Value").equals(form1) ||
                    ocData.get("Value").equals(form2));
         assertEquals("Array of String", ocData.get("Type"));
+        context().ungetService(sref);
     }
 
     @Test
     @SuppressWarnings("unchecked")
     public void testServicePropertiesInListServices() throws Exception {
-        ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
-
-        ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(InterfaceA.class.getName(), null);
+        ServiceReference[] refs = bundleContext.getAllServiceReferences(InterfaceA.class.getName(), null);
         assertEquals("Precondition", 1, refs.length);
-        ServiceReference<?> ref = refs[0];
+        ServiceReference ref = refs[0];
 
         TabularData svcTab = mbean.listServices();
         CompositeData svcData = svcTab.get(new Object [] {ref.getProperty(Constants.SERVICE_ID)});
@@ -391,14 +343,12 @@ public class ServiceStateMBeanTest exten
 
     @Test
     public void testListServices() throws Exception {
-        ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
-
         String filter = "(" + Constants.SERVICE_PID + "=*)";
-        ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(null, filter);
+        ServiceReference[] refs = bundleContext.getAllServiceReferences(null, filter);
         TabularData svcData = mbean.listServices(null, filter);
         assertEquals(refs.length, svcData.size());
 
-        ServiceReference<InterfaceA> sref = bundleContext.getServiceReference(InterfaceA.class);
+        ServiceReference sref = bundleContext.getServiceReference(InterfaceA.class);
         TabularData svcTab = mbean.listServices(InterfaceA.class.getName(), null);
         assertEquals(1, svcTab.size());
         CompositeData actualSvc = (CompositeData) svcTab.values().iterator().next();
@@ -406,17 +356,16 @@ public class ServiceStateMBeanTest exten
         assertEquals(expectedSvc, actualSvc);
     }
 
-    @Test
+    @SuppressWarnings("unchecked")
+	@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);
+        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) {
+        for (ServiceReference ref : refs) {
             assertEquals("Precondition", id, ref.getBundle().getBundleId());
         }
 

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,13 +16,7 @@
  */
 package org.apache.aries.jmx.framework.wiring;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertEquals;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -41,11 +35,11 @@ import javax.management.openmbean.Tabula
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.PropertyData;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.Configuration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.wiring.BundleCapability;
@@ -57,66 +51,27 @@ import org.osgi.framework.wiring.BundleW
 import org.osgi.jmx.framework.wiring.BundleWiringStateMBean;
 
 public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
-    @Configuration
-    public static Option[] configuration() {
-        return testOptions(
+    private BundleWiringStateMBean brsMBean;
+	private Bundle bundleA;
+
+	@Configuration
+    public Option[] configuration() {
+        return CoreOptions.options(
             // 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.8.0.V20120529-1548"),
-            paxLogging("INFO"),
-
-            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
-            mavenBundle("org.osgi", "org.osgi.compendium"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-            mavenBundle("org.apache.aries", "org.apache.aries.util"),
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.bundlea.Activator.class)
-                    .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                    .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                    .set(Constants.BUNDLE_VERSION, "2.0.0")
-                    .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api;version=2.0.0")
-                    .set(Constants.IMPORT_PACKAGE,
-                            "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional" +
-                            ",org.osgi.service.cm")
-                    .set(Constants.BUNDLE_ACTIVATOR,
-                            org.apache.aries.jmx.test.bundlea.Activator.class.getName())
-                    .build(withBnd())),
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.bundleb.Activator.class)
-                    .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
-                    .add(org.apache.aries.jmx.test.bundleb.api.MSF.class)
-                    .add(org.apache.aries.jmx.test.bundleb.impl.B.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.aries.jmx.test.bundleb")
-                    .set(Constants.BUNDLE_VERSION, "1.0.0")
-                    .set(Constants.EXPORT_PACKAGE,"org.apache.aries.jmx.test.bundleb.api;version=1.1.0")
-                    .set(Constants.IMPORT_PACKAGE,"org.osgi.framework;version=1.5.0,org.osgi.util.tracker," +
-                            "org.osgi.service.cm,org.apache.aries.jmx.test.fragmentc")
-                    .set(Constants.BUNDLE_ACTIVATOR,
-                            org.apache.aries.jmx.test.bundleb.Activator.class.getName())
-                    .build(withBnd())),
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.fragmentc.C.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.fragc")
-                    .set(Constants.FRAGMENT_HOST, "org.apache.aries.jmx.test.bundlea")
-                    .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.fragmentc")
-                    .build(withBnd())),
-            provision(newBundle()
-                    .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()))
+        	jmxRuntime(),
+            bundlea(),
+            bundleb(),
+            fragmentc(),
+            bundled()
             );
-
     }
 
-    @Override
+    @Before
     public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(BundleWiringStateMBean.OBJECTNAME));
+        brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
+        bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
     }
 
     @Test
@@ -131,10 +86,8 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testGetCurrentRevisionDeclaredRequirements() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        BundleRevision br = a.adapt(BundleRevision.class);
+        Bundle a = getBundleByName("org.apache.aries.jmx.test.bundlea");
+        BundleRevision br = (BundleRevision) a.adapt(BundleRevision.class);
 
         List<BundleRequirement> requirements = br.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
         CompositeData[] jmxRequirements = brsMBean.getCurrentRevisionDeclaredRequirements(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
@@ -147,13 +100,10 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testGetCurrentRevisionDeclaredCapabilities() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        BundleRevision br = a.adapt(BundleRevision.class);
+        BundleRevision br = (BundleRevision) bundleA.adapt(BundleRevision.class);
 
         List<BundleCapability> capabilities = br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
-        CompositeData[] jmxCapabilities = brsMBean.getCurrentRevisionDeclaredCapabilities(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        CompositeData[] jmxCapabilities = brsMBean.getCurrentRevisionDeclaredCapabilities(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
         Assert.assertEquals(capabilities.size(), jmxCapabilities.length);
 
         Map<Map<String, Object>, Map<String, String>> expectedCapabilities = capabilitiesToMap(capabilities);
@@ -163,17 +113,14 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testGetRevisionsDeclaredRequirements() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        BundleRevisions revisions = a.adapt(BundleRevisions.class);
+        BundleRevisions revisions = (BundleRevisions) bundleA.adapt(BundleRevisions.class);
 
         Assert.assertEquals("Precondition", 1, revisions.getRevisions().size());
 
-        TabularData jmxRequirementsTable = brsMBean.getRevisionsDeclaredRequirements(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        TabularData jmxRequirementsTable = brsMBean.getRevisionsDeclaredRequirements(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
         Assert.assertEquals(1, jmxRequirementsTable.size());
 
-        List<BundleRequirement> requirements = revisions.getRevisions().iterator().next().getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
+        List<BundleRequirement> requirements = ((BundleRevision) revisions.getRevisions().iterator().next()).getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
         CompositeData jmxRevRequirements = (CompositeData) jmxRequirementsTable.values().iterator().next();
         CompositeData[] jmxRequirements = (CompositeData[]) jmxRevRequirements.get(BundleWiringStateMBean.REQUIREMENTS);
 
@@ -184,17 +131,14 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testGetRevisionsDeclaredCapabilities() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        BundleRevisions revisions = a.adapt(BundleRevisions.class);
+        BundleRevisions revisions = (BundleRevisions) bundleA.adapt(BundleRevisions.class);
 
         Assert.assertEquals("Precondition", 1, revisions.getRevisions().size());
 
-        TabularData jmxCapabilitiesTable = brsMBean.getRevisionsDeclaredCapabilities(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        TabularData jmxCapabilitiesTable = brsMBean.getRevisionsDeclaredCapabilities(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
         Assert.assertEquals(1, jmxCapabilitiesTable.size());
 
-        List<BundleCapability> capabilities = revisions.getRevisions().iterator().next().getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
+        List<BundleCapability> capabilities = ((BundleRevision) revisions.getRevisions().iterator().next()).getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
         CompositeData jmxRevCapabilities = (CompositeData) jmxCapabilitiesTable.values().iterator().next();
         CompositeData[] jmxCapabilities = (CompositeData[]) jmxRevCapabilities.get(BundleWiringStateMBean.CAPABILITIES);
 
@@ -205,31 +149,25 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testGetCurrentWiring() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        CompositeData jmxWiring = brsMBean.getCurrentWiring(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        CompositeData jmxWiring = brsMBean.getCurrentWiring(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
 
         Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
-        Assert.assertEquals(a.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
+        Assert.assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
 
-        BundleWiring bw = a.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleA.adapt(BundleWiring.class);
         assertBundleWiring(bw, jmxWiring);
     }
 
     @Test
     public void testRevisionsWiring() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        TabularData jmxWiringTable = brsMBean.getRevisionsWiring(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        TabularData jmxWiringTable = brsMBean.getRevisionsWiring(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
 
         Assert.assertEquals(1, jmxWiringTable.size());
         CompositeData jmxWiring = (CompositeData) jmxWiringTable.values().iterator().next();
         Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
-        Assert.assertEquals(a.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
+        Assert.assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
 
-        BundleWiring bw = a.adapt(BundleWiring.class);
+        BundleWiring bw = (BundleWiring) bundleA.adapt(BundleWiring.class);
         assertBundleWiring(bw, jmxWiring);
     }
 
@@ -313,54 +251,48 @@ public class BundleWiringStateMBeanTest 
 
     @Test
     public void testCurrentWiringClosure() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
+        TabularData jmxWiringClosure = brsMBean.getCurrentWiringClosure(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
 
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        TabularData jmxWiringClosure = brsMBean.getCurrentWiringClosure(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
-
-        CompositeData jmxWiringA = jmxWiringClosure.get(new Object [] {a.getBundleId(), 0});
-        assertBundleWiring(a.adapt(BundleWiring.class), jmxWiringA);
+        CompositeData jmxWiringA = jmxWiringClosure.get(new Object [] {bundleA.getBundleId(), 0});
+        assertBundleWiring((BundleWiring) bundleA.adapt(BundleWiring.class), jmxWiringA);
 
         Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
         int bRevID = findRevisionID(jmxWiringA, b);
         CompositeData jmxWiringB = jmxWiringClosure.get(new Object [] {b.getBundleId(), bRevID});
-        assertBundleWiring(b.adapt(BundleWiring.class), jmxWiringB);
+        assertBundleWiring((BundleWiring) b.adapt(BundleWiring.class), jmxWiringB);
 
         Bundle cm = context().getBundleByName("org.apache.felix.configadmin");
         int cmRevID = findRevisionID(jmxWiringA, cm);
         CompositeData jmxWiringCM = jmxWiringClosure.get(new Object [] {cm.getBundleId(), cmRevID});
-        assertBundleWiring(cm.adapt(BundleWiring.class), jmxWiringCM);
+        assertBundleWiring((BundleWiring) cm.adapt(BundleWiring.class), jmxWiringCM);
 
         Bundle sb = context().getBundle(0);
         int sbRevID = findRevisionID(jmxWiringA, sb);
         CompositeData jmxWiringSB = jmxWiringClosure.get(new Object [] {sb.getBundleId(), sbRevID});
-        assertBundleWiring(sb.adapt(BundleWiring.class), jmxWiringSB);
+        assertBundleWiring((BundleWiring) sb.adapt(BundleWiring.class), jmxWiringSB);
     }
 
     @Test
     public void testRevisionsWiringClosure() throws Exception {
-        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
-
-        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
-        TabularData jmxWiringClosure = brsMBean.getRevisionsWiringClosure(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
+        TabularData jmxWiringClosure = brsMBean.getRevisionsWiringClosure(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
 
-        CompositeData jmxWiringA = jmxWiringClosure.get(new Object [] {a.getBundleId(), 0});
-        assertBundleWiring(a.adapt(BundleWiring.class), jmxWiringA);
+        CompositeData jmxWiringA = jmxWiringClosure.get(new Object [] {bundleA.getBundleId(), 0});
+        assertBundleWiring((BundleWiring) bundleA.adapt(BundleWiring.class), jmxWiringA);
 
         Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
         int bRevID = findRevisionID(jmxWiringA, b);
         CompositeData jmxWiringB = jmxWiringClosure.get(new Object [] {b.getBundleId(), bRevID});
-        assertBundleWiring(b.adapt(BundleWiring.class), jmxWiringB);
+        assertBundleWiring((BundleWiring) b.adapt(BundleWiring.class), jmxWiringB);
 
         Bundle cm = context().getBundleByName("org.apache.felix.configadmin");
         int cmRevID = findRevisionID(jmxWiringA, cm);
         CompositeData jmxWiringCM = jmxWiringClosure.get(new Object [] {cm.getBundleId(), cmRevID});
-        assertBundleWiring(cm.adapt(BundleWiring.class), jmxWiringCM);
+        assertBundleWiring((BundleWiring) cm.adapt(BundleWiring.class), jmxWiringCM);
 
         Bundle sb = context().getBundle(0);
         int sbRevID = findRevisionID(jmxWiringA, sb);
         CompositeData jmxWiringSB = jmxWiringClosure.get(new Object [] {sb.getBundleId(), sbRevID});
-        assertBundleWiring(sb.adapt(BundleWiring.class), jmxWiringSB);
+        assertBundleWiring((BundleWiring) sb.adapt(BundleWiring.class), jmxWiringSB);
     }
 
     private int findRevisionID(CompositeData jmxWiring, Bundle bundle) {

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java Mon Jun 30 16:54:57 2014
@@ -16,28 +16,17 @@
  */
 package org.apache.aries.jmx.permissionadmin;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
 import java.io.IOException;
 
-import javax.management.ObjectName;
-
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.junit.Test;
-import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-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.jmx.service.permissionadmin.PermissionAdminMBean;
 import org.osgi.service.permissionadmin.PermissionAdmin;
 import org.osgi.service.permissionadmin.PermissionInfo;
@@ -50,41 +39,20 @@ import org.osgi.service.permissionadmin.
 public class PermissionAdminMBeanTest extends AbstractIntegrationTest {
 
     @Configuration
-    public static Option[] configuration() {
-        return testOptions(
-            PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-            CoreOptions.equinox().version("3.8.0.V20120529-1548"),
-            paxLogging("INFO"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api"),
-            mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard"),
-            mavenBundle("org.apache.aries", "org.apache.aries.util"),
-            provision(newBundle()
-                    .add(org.apache.aries.jmx.test.bundlea.Activator.class)
-                    .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
-                    .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
-                    .set(Constants.BUNDLE_VERSION, "2.0.0")
-                    .set(Constants.IMPORT_PACKAGE,
-                            "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional")
-                    .set(Constants.BUNDLE_ACTIVATOR,
-                            org.apache.aries.jmx.test.bundlea.Activator.class.getName())
-                    .build(withBnd()))
+    public Option[] configuration() {
+        return options(
+            jmxRuntime(),
+            bundlea()
                     /* For debugging, uncomment the next two lines */
 //                     vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7778"),
 //                     waitForFrameworkStartup()
         );
     }
 
-    @Override
-    public void doSetUp() throws Exception {
-        waitForMBean(new ObjectName(PermissionAdminMBean.OBJECTNAME));
-    }
-
     @Test
     public void testMBeanInterface() throws IOException {
         PermissionAdminMBean mBean = getMBean(PermissionAdminMBean.OBJECTNAME, PermissionAdminMBean.class);
-        PermissionAdmin permAdminService = getService(PermissionAdmin.class);
+        PermissionAdmin permAdminService = context().getService(PermissionAdmin.class);
         assertNotNull(permAdminService);
 
         String[] serviceLocation = permAdminService.getLocations();
@@ -132,14 +100,4 @@ public class PermissionAdminMBeanTest ex
         return encoded;
     }
 
-    private <S> S getService(Class<S> serviceInterface){
-        ServiceReference ref =  bundleContext.getServiceReference(serviceInterface.getName());
-        if(ref != null){
-            Object service = bundleContext.getService(ref);
-            if(service != null){
-                return (S)service;
-            }
-        }
-        return null;
-    }
 }
\ No newline at end of file