@Test public void testUnRegisterService (){ DummyClass service = new DummyClass(); Properties props = new Properties(); ServiceRegistration s = mock(ServiceRegistration.class); when(bc.registerService(eq(DummyInterface.class.getName()), same(service), any(Dictionary.class))).thenReturn(s); sri.registerService(service, DummyInterface.class, props); assertTrue(sri.getServiceRegistrations().get(DummyInterface.class).get(service).equals(s)); sri.unregisterService(service, DummyInterface.class); assertTrue(sri.getServiceRegistrations().get(DummyInterface.class).get(service)== null); }
public void unregisterService(Object o, Class c) { if ( o == null ) throw new NullPointerException( "service object is null" ); if ( c == null ) throw new NullPointerException( "class is null" ); Map<Object, ServiceRegistration> registrations = serviceRegistrations.get(c); if ( registrations == null ) return; ServiceRegistration s = registrations.get(o); if ( s == null ) return; s.unregister(); serviceRegistrations.get(c).remove(o); }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterService(Object o, Class c) { if ( o == null ) throw new NullPointerException( "service object is null" ); if ( c == null ) throw new NullPointerException( "class is null" ); Map<Object, ServiceRegistration> registrations = serviceRegistrations.get(c); if ( registrations == null ) return; ServiceRegistration s = registrations.get(o); if ( s == null ) return; s.unregister(); serviceRegistrations.get(c).remove(o); } }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterService(Object o, Class c) { if ( o == null ) throw new NullPointerException( "service object is null" ); if ( c == null ) throw new NullPointerException( "class is null" ); Map<Object, ServiceRegistration> registrations = serviceRegistrations.get(c); if ( registrations == null ) return; ServiceRegistration s = registrations.get(o); if ( s == null ) return; s.unregister(); serviceRegistrations.get(c).remove(o); } CyServiceRegistrarImpl(BundleContext bc); }
CyServiceRegistrarImpl implements CyServiceRegistrar { public void unregisterService(Object o, Class c) { if ( o == null ) throw new NullPointerException( "service object is null" ); if ( c == null ) throw new NullPointerException( "class is null" ); Map<Object, ServiceRegistration> registrations = serviceRegistrations.get(c); if ( registrations == null ) return; ServiceRegistration s = registrations.get(o); if ( s == null ) return; s.unregister(); serviceRegistrations.get(c).remove(o); } 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 unregisterService(Object o, Class c) { if ( o == null ) throw new NullPointerException( "service object is null" ); if ( c == null ) throw new NullPointerException( "class is null" ); Map<Object, ServiceRegistration> registrations = serviceRegistrations.get(c); if ( registrations == null ) return; ServiceRegistration s = registrations.get(o); if ( s == null ) return; s.unregister(); serviceRegistrations.get(c).remove(o); } 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);  }