protected void assertServiceEvent(int type, ServiceReference reference) throws Exception { ServiceEvent event = (ServiceEvent) waitForEvent(serviceEvents, type); log.debug("serviceEvents=" + serviceEvents); assertNotNull("Event not null", event); serviceEvents.remove(event); assertEquals(ConstantsHelper.serviceEvent(type), ConstantsHelper.serviceEvent(event.getType())); assertEquals(reference, event.getSource()); assertEquals(reference, event.getServiceReference()); }
@Override public void serviceChanged(ServiceEvent event) { synchronized (serviceEvents) { log.debug( "ServiceChanged type=" + ConstantsHelper.serviceEvent(event.getType()) + " for " + event); serviceEvents.add(event); serviceEvents.notifyAll(); } }
@Override public void bundleChanged(BundleEvent event) { synchronized (bundleEvents) { log.debug( "BundleChanged type=" + ConstantsHelper.bundleEvent(event.getType()) + " for " + event); bundleEvents.add(event); bundleEvents.notifyAll(); } }
@Override public void frameworkEvent(FrameworkEvent event) { synchronized (frameworkEvents) { log.debug( "FrameworkEvent type=" + ConstantsHelper.frameworkEvent(event.getType()) + " for " + event); frameworkEvents.add(event); frameworkEvents.notifyAll(); } }
protected void assertFrameworkEvent( int type, Bundle bundle, Class<? extends Throwable> expectedThrowable) throws Exception { FrameworkEvent event = (FrameworkEvent) waitForEvent(frameworkEvents, type); log.debug("frameworkEvents=" + frameworkEvents); assertNotNull("Event not null", event); frameworkEvents.remove(event); assertEquals( ConstantsHelper.frameworkEvent(type), ConstantsHelper.frameworkEvent(event.getType())); Throwable t = event.getThrowable(); if (expectedThrowable == null) { if (t != null) { log.error("Unexpected error in Framework event: ", t); fail("Unexpected throwable: " + t); } } else { String message = expectedThrowable.getSimpleName() + " is assignable from " + t.getClass().getSimpleName(); assertTrue(message, expectedThrowable.isAssignableFrom(t.getClass())); } assertEquals(bundle, event.getSource()); assertEquals(bundle, event.getBundle()); }
@Override public ServiceName getServiceName(Deployment dep, int state) { // Currently the bundleId is needed for uniqueness because of // [MSC-97] Cannot re-install service with same name Long bundleId = dep.getAttachment(Long.class); ServiceName serviceName = ServiceName.of( BUNDLE_BASE_NAME, "" + bundleId, "" + dep.getSymbolicName(), "" + dep.getVersion()); if (state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.ACTIVE) { serviceName = serviceName.append(ConstantsHelper.bundleState(state)); } return serviceName; }
protected void assertBundleEvent(int type, Bundle bundle) throws Exception { BundleEvent event = (BundleEvent) waitForEvent(bundleEvents, type); log.debug("bundleEvents=" + bundleEvents); assertNotNull("Event not null", event); for (int i = 0; i < bundleEvents.size(); i++) { BundleEvent aux = bundleEvents.get(i); if (type == aux.getType()) { if (bundle.equals(aux.getSource()) && bundle.equals(aux.getBundle())) { bundleEvents.remove(aux); event = aux; break; } } } if (event == null) fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + " from " + bundle); }