@Test public void testRemoveService() { ServiceHolder tested = new ServiceHolder(); Object service = new Object(); // Get the hash set. Set<Object> servicesSet = getField(tested, Set.class); servicesSet.add(service); tested.removeService(service); assertTrue("Set should be empty after removeal.", servicesSet.isEmpty()); }
@Test public void testAddService() { ServiceHolder tested = new ServiceHolder(); Object service = new Object(); tested.addService(service); Set<String> services = getField(tested, "services"); assertEquals("Size of the \"services\" Set should be 1", 1, services.size()); assertSame( "The services Set should didn't contain the expect service", service, services.iterator().next()); }