@Test
    public void testCloseAfterIdleTime() throws Exception {
        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)).withMaxIdleTime(Duration.ofMillis(10)).build();

        // Get a connection and directly return it.
        PlcConnection connection = connectionManager.getConnection("test");
        connection.close();

        // Wait for longer than the max idle time.
        Thread.sleep(200);

        Assertions.assertEquals(0, connectionManager.getCachedConnections().size());
    }
This is the simplest possible test. Here the ConnectionManager is used exactly once.
So not really much of the caching we can test, but it tests if we're creating connections the right way.

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