JRTConnectionPool implements ConnectionPool { public JRTConnectionPool updateSources(List<String> addresses) { ConfigSourceSet newSources = new ConfigSourceSet(addresses); return updateSources(newSources); } JRTConnectionPool(ConfigSourceSet sourceSet);  JRTConnectionPool(List<String> addresses); void addSources(ConfigSourceSet sourceSet); synchronized JRTConnection getCurrent(); synchronized JRTConnection setNewCurrentConnection(); @Override void setError(Connection connection, int errorCode); JRTConnectionPool updateSources(List<String> addresses); JRTConnectionPool updateSources(ConfigSourceSet sourceSet); String toString(); void close(); @Override int getSize(); @Override Supervisor getSupervisor();  }
@Test public void updateSources() { List<String> twoSources = new ArrayList<>(); twoSources.add("host0"); twoSources.add("host1"); JRTConnectionPool sourcePool = new JRTConnectionPool(twoSources); ConfigSourceSet sourcesBefore = sourcePool.getSourceSet(); sourcePool.updateSources(twoSources); assertThat(sourcesBefore, is(sourcePool.getSourceSet())); List<String> newSources = new ArrayList<>(); newSources.add("host2"); newSources.add("host3"); sourcePool.updateSources(newSources); ConfigSourceSet newSourceSet = sourcePool.getSourceSet(); assertNotNull(newSourceSet); assertThat(newSourceSet.getSources().size(), is(2)); assertThat(newSourceSet, is(not(sourcesBefore))); assertTrue(newSourceSet.getSources().contains("host2")); assertTrue(newSourceSet.getSources().contains("host3")); List<String> newSources2 = new ArrayList<>(); newSources2.add("host4"); sourcePool.updateSources(newSources2); ConfigSourceSet newSourceSet2 = sourcePool.getSourceSet(); assertNotNull(newSourceSet2); assertThat(newSourceSet2.getSources().size(), is(1)); assertThat(newSourceSet2, is(not(newSourceSet))); assertTrue(newSourceSet2.getSources().contains("host4")); }