Search in sources :

Example 1 with DisconnectEvent

use of org.pircbotx.hooks.events.DisconnectEvent in project downlords-faf-client by FAForever.

the class PircBotXChatServiceTest method testAddOnChatDisconnectedListener.

@Test
public void testAddOnChatDisconnectedListener() throws Exception {
    CompletableFuture<Void> onChatDisconnectedFuture = new CompletableFuture<>();
    instance.connectionState.addListener((observable, oldValue, newValue) -> {
        switch(newValue) {
            case DISCONNECTED:
                onChatDisconnectedFuture.complete(null);
                break;
        }
    });
    connect();
    CompletableFuture<Void> future = listenForDisconnected();
    firePircBotXEvent(new DisconnectEvent(pircBotX, daoSnapshot, null));
    future.get(TIMEOUT, TIMEOUT_UNIT);
    onChatDisconnectedFuture.get(TIMEOUT, TIMEOUT_UNIT);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) DisconnectEvent(org.pircbotx.hooks.events.DisconnectEvent) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.Test)1 DisconnectEvent (org.pircbotx.hooks.events.DisconnectEvent)1