CompositeService extends AbstractService { protected boolean removeService(Service service) { LOG.debug("Removing service {}", service.getName()); synchronized (serviceList) { return serviceList.remove(service); } } CompositeService(String name); List<Service> getServices();  }
@Test public void testRemoveService() { CompositeService testService = new CompositeService("TestService") { @Override public void serviceInit(Configuration conf) { Integer notAService = new Integer(0); assertFalse("Added an integer as a service", addIfService(notAService)); Service service1 = new AbstractService("Service1") {}; addIfService(service1); Service service2 = new AbstractService("Service2") {}; addIfService(service2); Service service3 = new AbstractService("Service3") {}; addIfService(service3); removeService(service1); } }; testService.init(new Configuration()); assertEquals("Incorrect number of services", 2, testService.getServices().size()); }