@Test
    public void testDoubleConnectionRequestTimeoutTest() throws Exception {
        // Create a connectionManager with a maximum wait time of 50ms
        PlcConnectionManager mockConnectionManager = Mockito.mock(PlcConnectionManager.class);
        Mockito.when(mockConnectionManager.getConnection("test")).thenReturn(Mockito.mock(PlcConnection.class));
        CachedPlcConnectionManager connectionManager = CachedPlcConnectionManager.getBuilder(mockConnectionManager).withMaxWaitTime(Duration.ofMillis(50)).build();
        CountDownLatch startSignal = new CountDownLatch(1);

        // Get the connection for the first time.
        (new Thread(() -> {
            try {
                PlcConnection connection = connectionManager.getConnection("test");
                startSignal.countDown();
                Assertions.assertInstanceOf(LeasedPlcConnection.class, connection);
            } catch (Exception e) {
                Assertions.fail("Not expecting an exception here", e);
            }
        })).start();

        // This is needed as starting the previous thread seems to take a little-bit of time.
        startSignal.await();

        // Get the same connection a second time.
        try (PlcConnection ignored = connectionManager.getConnection("test")) {
            Assertions.fail("Was expecting an exception here");
        } catch (Exception e) {
            Assertions.assertInstanceOf(PlcConnectionException.class, e);
            Assertions.assertEquals("Error acquiring lease for connection", e.getMessage());
        }

        // Check getConnection was called on the mockConnectionManager instance exactly once.
        Mockito.verify(mockConnectionManager, Mockito.times(1)).getConnection("test");
    }
This test is almost the same setup as the double connection test, but in this case the one usage exceeds
the maximum wait time, so the connection-cache gives up waiting and returns an exception.

@throws PlcConnectionException something went wrong
plc4j/tools/connection-cache/src/test/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java