lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * Enter presence channel without prior connect and await entered event
     */
Enter presence channel without prior connect and await entered event
Enter presence channel without prior connect and await entered event
@Ignore("FIXME: fix exception")
    @Test
    public void enter_before_connect() {
        AblyRealtime clientAbly1 = null;
        TestChannel testChannel = new TestChannel();
        try {
            /* subscribe for presence events in the anonymous connection */
            PresenceWaiter presenceWaiter = new PresenceWaiter(testChannel.realtimeChannel);
            /* set up a connection with specific clientId */
            ClientOptions client1Opts = new ClientOptions() {{
                tokenDetails = token1;
                clientId = testClientId1;
            }};
            fillInOptions(client1Opts);
            clientAbly1 = new AblyRealtime(client1Opts);
            /* get channel */
            Channel client1Channel = clientAbly1.channels.get(testChannel.channelName);
            /* let client1 enter the channel and wait for the entered event to be delivered */
            CompletionWaiter enterComplete = new CompletionWaiter();
            String enterString = "Test data (enter_before_connect)";
            client1Channel.presence.enter(enterString, enterComplete);
            presenceWaiter.waitFor(testClientId1, Action.enter);
            PresenceMessage expectedPresent = presenceWaiter.contains(testClientId1, clientAbly1.connection.id, Action.enter);
            assertNotNull(expectedPresent);
            assertEquals(expectedPresent.data, enterString);
            /* verify enter callback called on completion */
            enterComplete.waitFor();
            assertTrue("Verify enter callback called on completion", enterComplete.success);
        } catch(AblyException e) {
            e.printStackTrace();
            fail("Unexpected exception running test: " + e.getMessage());
        } finally {
            if(clientAbly1 != null)
                clientAbly1.close();
            if(testChannel != null)
                testChannel.dispose();
        }
    }
@ Ignore ( "FIXME: fix exception" ) @ Test public void enter_before_connect ( ) { AblyRealtime clientAbly1 = null ; TestChannel testChannel = new TestChannel ( ) ; try { /* subscribe for presence events in the anonymous connection */ PresenceWaiter presenceWaiter = new PresenceWaiter ( testChannel . realtimeChannel ) ; /* set up a connection with specific clientId */ ClientOptions client1Opts = new ClientOptions ( ) { { tokenDetails = token1 ; clientId = testClientId1 ; } } ; fillInOptions ( client1Opts ) ; clientAbly1 = new AblyRealtime ( client1Opts ) ; /* get channel */ Channel client1Channel = clientAbly1 . channels . get ( testChannel . channelName ) ; /* let client1 enter the channel and wait for the entered event to be delivered */ CompletionWaiter enterComplete = new CompletionWaiter ( ) ; String enterString = "Test data (enter_before_connect)" ; client1Channel . presence . enter ( enterString , enterComplete ) ; presenceWaiter . waitFor ( testClientId1 , Action . enter ) ; PresenceMessage expectedPresent = presenceWaiter . contains ( testClientId1 , clientAbly1 . connection . id , Action . enter ) ; assertNotNull ( expectedPresent ) ; assertEquals ( expectedPresent . data , enterString ) ; /* verify enter callback called on completion */ enterComplete . waitFor ( ) ; assertTrue ( "Verify enter callback called on completion" , enterComplete . success ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; fail ( "Unexpected exception running test: " + e . getMessage ( ) ) ; } finally { if ( clientAbly1 != null ) clientAbly1 . close ( ) ; if ( testChannel != null ) testChannel . dispose ( ) ; } }
Enter presence channel without prior connect and await entered event
Enter presence channel without prior connect and await entered event