@Test
public void testIdleTimeoutFutureIsCanceled() throws IOException {

    final AtomicBoolean canceled = new AtomicBoolean(false);
    final InvocationHandler scheduledFutureHandler = (proxy, method, args) -> {
        switch (method.getName()) {
            case "cancel":
                canceled.set(true);
                return true;
            default:
                return null;
        }
    };
    final InvocationHandler scheduledExecutorServiceHandler = (proxy, method, args) -> {
        switch (method.getName()) {
            case "schedule":
                return Proxy.newProxyInstance(
                        getClass().getClassLoader(), new Class[]{ScheduledFuture.class}, scheduledFutureHandler
                );
            default:
                return null;
        }
    };
    final WebSocketContainer webSocketContainer = new TestContainer() {
        @Override
        public ScheduledExecutorService getScheduledExecutorService() {
            return (ScheduledExecutorService) Proxy.newProxyInstance(
                    getClass().getClassLoader(),
                    new Class[]{ScheduledExecutorService.class},
                    scheduledExecutorServiceHandler
            );
        }
    };
    final Session session = createSession(endpointWrapper, webSocketContainer);
    session.close();
    assertTrue(canceled.get());
}