SyncHandlerMappingTracker extends ServiceTracker { @Override public void removedService(ServiceReference reference, Object service) { referenceMap.remove(reference); super.removedService(reference, service); } SyncHandlerMappingTracker(@NotNull BundleContext context); @Override Object addingService(ServiceReference reference); @Override void modifiedService(ServiceReference reference, Object service); @Override void removedService(ServiceReference reference, Object service);  }
@Test public void testRemovedService() { when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH"); when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP"); tracker.addingService(ref); tracker.removedService(ref, service); assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH"))); }