@Test
public void testClose() {

    markSourceConnected(true);
    
    assert !client.getListener().isClosed();
    
    CompletableFuture<Boolean> wsFut = client.getWebsocketConnectionFuture();
    CompletableFuture<Boolean> aFut = client.getAuthenticationFuture();
    CompletableFuture<Boolean> sFut = client.getSourceConnectionFuture();
    
    assert wsFut.getNow(false);
    assert aFut.getNow(false);
    assert sFut.getNow(false);
    
    ExtensionWebSocketListener oldListen = client.getListener();
    client.close();
    
    assert !client.getListener().isClosed();
    assert oldListen.isClosed();
    
    ExtensionWebSocketListener newListen = client.getListener();
    
    // '==' and not '.equals()' because they should be the exact same object
    assert newListen.authHandler == oldListen.authHandler;
    assert newListen.httpHandler == oldListen.httpHandler;
    assert newListen.configHandler == oldListen.configHandler;
    assert newListen.reconnectHandler == oldListen.reconnectHandler;
    assert newListen.publishHandler == oldListen.publishHandler;
    assert newListen.queryHandler == oldListen.queryHandler;
    
    // Should be set to false now
    assert !wsFut.getNow(true);
    assert !aFut.getNow(true);
    assert !sFut.getNow(true);
    
    // The old Futures should have been removed from client
    assert client.getWebsocketConnectionFuture() == null;
    assert client.getAuthenticationFuture() == null;
    assert client.getSourceConnectionFuture() == null;
}