@Test public void testUnRegisterAllServices (){ DummyClass2 service = new DummyClass2(); Properties props = new Properties(); ServiceRegistration s = mock(ServiceRegistration.class); ServiceRegistration s2 = mock(ServiceRegistration.class); when(bc.registerService(eq(DummyInterface2.class.getName()), same(service), any(Dictionary.class))).thenReturn(s2); when(bc.registerService(eq(DummyInterface.class.getName()), same(service), any(Dictionary.class))).thenReturn(s); sri.registerAllServices(service, props); assertTrue(sri.getServiceRegistrations().get(DummyInterface2.class).get(service).equals(s2)); assertTrue(sri.getServiceRegistrations().get(DummyInterface.class).get(service).equals(s)); sri.unregisterAllServices(service); assertTrue(sri.getServiceRegistrations().get(DummyInterface.class).isEmpty()); assertTrue(sri.getServiceRegistrations().get(DummyInterface2.class).isEmpty()); }
public void unregisterAllServices(Object o) { for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) { if ( !c.getName().startsWith("java") ) { unregisterService(o,c); } } }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterAllServices(Object o) { for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) { if ( !c.getName().startsWith("java") ) { unregisterService(o,c); } } } }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterAllServices(Object o) { for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) { if ( !c.getName().startsWith("java") ) { unregisterService(o,c); } } } CyServiceRegistrarImpl(BundleContext bc); }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterAllServices(Object o) { for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) { if ( !c.getName().startsWith("java") ) { unregisterService(o,c); } } } CyServiceRegistrarImpl(BundleContext bc); void registerAllServices(Object service, Properties props); void registerService(Object service, Class serviceClass, Properties props); void unregisterAllServices(Object o); void unregisterService(Object o, Class c); @Override S getService(Class<S> serviceClass); @Override S getService(Class<S> serviceClass, String filter); @Override void registerServiceListener(Object listener,
		String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, Class<?> methodClass, String additionalFilter); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, String additionalFilter); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, Class<?> methodClass); }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterAllServices(Object o) { for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) { if ( !c.getName().startsWith("java") ) { unregisterService(o,c); } } } CyServiceRegistrarImpl(BundleContext bc); void registerAllServices(Object service, Properties props); void registerService(Object service, Class serviceClass, Properties props); void unregisterAllServices(Object o); void unregisterService(Object o, Class c); @Override S getService(Class<S> serviceClass); @Override S getService(Class<S> serviceClass, String filter); @Override void registerServiceListener(Object listener,
		String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, Class<?> methodClass, String additionalFilter); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, String additionalFilter); @Override void registerServiceListener(Object listener,
			String registerMethodName, String unregisterMethodName,
			Class<?> serviceClass, Class<?> methodClass);  }