@Test
    public void test_random_selection_of_source() {
        JRTConnectionPool sourcePool = new JRTConnectionPool(sources);
        assertEquals("host0,host1,host2",
                     sourcePool.getSources().stream().map(JRTConnection::getAddress).collect(Collectors.joining(",")));

        Map<String, Integer> sourceOccurrences = new HashMap<>();
        for (int i = 0; i < 1000; i++) {
            String address = sourcePool.switchConnection().getAddress();
            if (sourceOccurrences.containsKey(address)) {
                sourceOccurrences.put(address, sourceOccurrences.get(address) + 1);
            } else {
                sourceOccurrences.put(address, 1);
            }
        }
        for (int i = 0; i < sourcePool.getSize(); i++) {
            assertTrue(sourceOccurrences.get(sourcePool.getSources().get(i).getAddress()) > 200);
        }
    }
Tests for the JRTConnectionPool class.

@author Gunnar Gauslaa Bergem
@author hmusum
config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java