@Test public void testAddChangeListener() throws IOException { InetSocketAddress server = new InetSocketAddress(80); StaticServerSet set = new StaticServerSet(server); ServerSet.ChangeListener listener = mock(ServerSet.ChangeListener.class); set.addChangeListener(listener); verify(listener).onServerAdded(server); verifyNoMoreInteractions(listener); set.close(); }
@Override public void addChangeListener(ChangeListener listener) { listeners.add(listener); for (InetSocketAddress server : servers) { listener.onServerAdded(server); } }
StaticServerSet implements ServerSet { @Override public void addChangeListener(ChangeListener listener) { listeners.add(listener); for (InetSocketAddress server : servers) { listener.onServerAdded(server); } } }
StaticServerSet implements ServerSet { @Override public void addChangeListener(ChangeListener listener) { listeners.add(listener); for (InetSocketAddress server : servers) { listener.onServerAdded(server); } } @Inject  StaticServerSet(@Assisted InetSocketAddress... servers); }
StaticServerSet implements ServerSet { @Override public void addChangeListener(ChangeListener listener) { listeners.add(listener); for (InetSocketAddress server : servers) { listener.onServerAdded(server); } } @Inject  StaticServerSet(@Assisted InetSocketAddress... servers); @Override void addChangeListener(ChangeListener listener); @Override void removeChangeListener(ChangeListener listener); @Override void close(); @Override Set<InetSocketAddress> getServers(); }
StaticServerSet implements ServerSet { @Override public void addChangeListener(ChangeListener listener) { listeners.add(listener); for (InetSocketAddress server : servers) { listener.onServerAdded(server); } } @Inject  StaticServerSet(@Assisted InetSocketAddress... servers); @Override void addChangeListener(ChangeListener listener); @Override void removeChangeListener(ChangeListener listener); @Override void close(); @Override Set<InetSocketAddress> getServers();  }