public long[] getRegisteredServices(long bid) { Bundle b = Activator.bc.getBundle(bid); return Util.referencesToLong(b.getRegisteredServices()); }
public void runTest() throws Throwable { boolean pass = true; out.println("### framework test bundle :STARTLVL100A start"); try { buA = Util.installBundle(bc, "bundleSLA_test-1.0.0.jar"); sl.setBundleStartLevel(buA, baseLevel + 10); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } buB = null; try { buB = Util.installBundle(bc, "bundleSLB_test-1.0.0.jar"); sl.setBundleStartLevel(buB, baseLevel + 30); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } buC = null; try { buC = Util.installBundle(bc, "bundleSLC_test_api-1.0.0.jar"); sl.setBundleStartLevel(buC, baseLevel + 20); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } try { buA.start(); assertTrue("BundleA should not be ACTIVE", buA.getState() != Bundle.ACTIVE); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } try { buB.start(); assertTrue("BundleB should not be ACTIVE", buB.getState() != Bundle.ACTIVE); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } try { buC.start(); assertTrue("BundleC should not be ACTIVE", buC.getState() != Bundle.ACTIVE); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("framework test bundle " + e + " :STARTLVL100A:FAIL"); } syncBListen.clearEvents(); sl.setStartLevel(baseLevel + 30); pass = syncBListen.checkEvents( new BundleEvent[] { new BundleEvent(BundleEvent.STARTED, buA), new BundleEvent(BundleEvent.STARTED, buC), new BundleEvent(BundleEvent.STARTED, buB) }); assertTrue("Bundle A, C, B should start", pass); buD = null; try { buD = Util.installBundle(bc, "bundleSLD_test-1.0.0.jar"); sl.setBundleStartLevel(buD, baseLevel + 15); buD.start(); assertTrue("BundleD should be ACTIVE", buD.getState() == Bundle.ACTIVE); } catch (Exception e) { out.println("Unexpected exception: " + e); e.printStackTrace(); fail("start level test bundle " + e + " :STARTLVL100A:FAIL"); } syncBListen.clearEvents(); Util.updateBundle(bc, buC, "bundleSLC_test_api-1.0.0.jar"); // Check BundleEvent stop/start C pass = syncBListen.checkEvents( new BundleEvent[] { new BundleEvent(BundleEvent.STOPPED, buC), new BundleEvent(BundleEvent.STARTED, buC), }); assertTrue("Bundle C should stop and start", pass); syncBListen.clearEvents(); pa.refreshPackages(new Bundle[] {buA, buB, buC, buD}); // Check BundleEvent stop order B, C, D, A // Check BundleEvent start order A, D, C, B pass = syncBListen.checkEvents( new BundleEvent[] { new BundleEvent(BundleEvent.STOPPED, buB), new BundleEvent(BundleEvent.STOPPED, buC), new BundleEvent(BundleEvent.STOPPED, buD), new BundleEvent(BundleEvent.STOPPED, buA), new BundleEvent(BundleEvent.STARTED, buA), new BundleEvent(BundleEvent.STARTED, buD), new BundleEvent(BundleEvent.STARTED, buC), new BundleEvent(BundleEvent.STARTED, buB) }); assertTrue("Bundle B, C, D, A should stop and start in reverse", pass); buA.uninstall(); buA = null; buB.uninstall(); buB = null; buC.uninstall(); buC = null; buD.uninstall(); buD = null; out.println("### start level test bundle :STARTLVL100A:PASS"); }
public long[] getServicesInUse(long bid) { Bundle b = Activator.bc.getBundle(bid); return Util.referencesToLong(b.getServicesInUse()); }