### Question:
ServiceContext { public synchronized void addListener(final ServiceChangeListener listener) { if (listener == null) { return; } listeners.add(listener); } ServiceContext(DiscoveryConfig discoveryConfig); DiscoveryConfig getDiscoveryConfig(); synchronized Service newService(); synchronized void setService(Service service); synchronized boolean deleteInstance(Instance instance); synchronized boolean updateInstance(Instance instance); synchronized boolean addInstance(Instance instance); synchronized boolean isAvailable(); synchronized Set<ServiceChangeListener> getListeners(); synchronized void addListener(final ServiceChangeListener listener); ServiceChangeEvent newServiceChangeEvent(final String changeType); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object other);  }### Answer:
@Test public void testAddListener() { final ServiceChangeListener listener1 = emptyListener(); context.addListener(listener1); Assert.assertEquals(1, context.getListeners().size()); Assert.assertTrue(context.getListeners().contains(listener1)); final ServiceChangeListener listener2 = emptyListener(); context.addListener(listener2); Assert.assertEquals(2, context.getListeners().size()); Assert.assertTrue(context.getListeners().contains(listener2)); }