@Test
void getConnection() throws Exception {

    when(plcDriver.getConnection(anyString())).then(invocationOnMock -> new DummyPlcConnection(invocationOnMock.getArgument(0)));
    LinkedList<Callable<PlcConnection>> callables = new LinkedList<>();
    // This: should result in one open connection
    IntStream.range(0, 8).forEach(i -> callables.add(() -> {
        try {
            return SUT.getConnection("dummydummy:single/socket1/socket2?fancyOption=true");
        } catch (PlcConnectionException e) {
            throw new RuntimeException(e);
        }
    }));
    // This should result in five open connections
    IntStream.range(0, 5).forEach(i -> callables.add(() -> {
        try {
            return SUT.getConnection("dummydummy:multi-" + i + "/socket1/socket2?fancyOption=true");
        } catch (PlcConnectionException e) {
            throw new RuntimeException(e);
        }
    }));
    List<Future<PlcConnection>> futures = executorService.invokeAll(callables);
    // Wait for existing connections
    futures.forEach(plcConnectionFuture1 -> {
        try {
            plcConnectionFuture1.get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    });
    LOGGER.info("Statistics after execution {}", SUT.getStatistics());
    // As we have a pool size of 8 we should have only 8 + 5 calls for the separate pools
    verify(plcDriver, times(13)).getConnection(anyString());
    assertThat(SUT.getStatistics()).contains(
        entry("PoolKey{url='dummydummy:single/socket1/socket2?fancyOption=true'}.numActive", 8)
    );
    futures.forEach(plcConnectionFuture -> {
        try {
            plcConnectionFuture.get().close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    assertThat(SUT.getStatistics()).contains(
        entry("PoolKey{url='dummydummy:single/socket1/socket2?fancyOption=true'}.numActive", 0)
    );
}