lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * Enter, then leave (with no data) and await leave event,
     * expecting enter data to be in leave event
     */
Enter, then leave (with no data) and await leave event,
expecting enter data to be in leave event
Enter then leave ( with no data ) and await leave event expecting enter data to be in leave event
@Ignore("FIXME: fix exception")
    @Test
    public void enter_leave_nodata() {
        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_leave_nodata)";
            client1Channel.presence.enter(enterString, enterComplete);
            presenceWaiter.waitFor(testClientId1, Action.enter);
            assertNotNull(presenceWaiter.contains(testClientId1, Action.enter));
            assertEquals(presenceWaiter.receivedMessages.get(0).data, enterString);
            presenceWaiter.reset();
            /* verify enter callback called on completion */
            enterComplete.waitFor();
            assertTrue("Verify enter callback called on completion", enterComplete.success);
            /* let client1 leave the channel and wait for the leave event to be delivered */
            CompletionWaiter leaveComplete = new CompletionWaiter();
            client1Channel.presence.leave(leaveComplete);
            presenceWaiter.waitFor(testClientId1, Action.leave);
            assertNotNull(presenceWaiter.contains(testClientId1, Action.leave));
            assertEquals(presenceWaiter.receivedMessages.get(0).data, enterString);
            /* verify leave callback called on completion */
            leaveComplete.waitFor();
            assertTrue("Verify leave callback called on completion", leaveComplete.success);
        } catch(AblyException e) {
            e.printStackTrace();
        } finally {
            if(clientAbly1 != null)
                clientAbly1.close();
            if(testChannel != null)
                testChannel.dispose();
        }
    }
@ Ignore ( "FIXME: fix exception" ) @ Test public void enter_leave_nodata ( ) { 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_leave_nodata)" ; client1Channel . presence . enter ( enterString , enterComplete ) ; presenceWaiter . waitFor ( testClientId1 , Action . enter ) ; assertNotNull ( presenceWaiter . contains ( testClientId1 , Action . enter ) ) ; assertEquals ( presenceWaiter . receivedMessages . get ( 0 ) . data , enterString ) ; presenceWaiter . reset ( ) ; /* verify enter callback called on completion */ enterComplete . waitFor ( ) ; assertTrue ( "Verify enter callback called on completion" , enterComplete . success ) ; /* let client1 leave the channel and wait for the leave event to be delivered */ CompletionWaiter leaveComplete = new CompletionWaiter ( ) ; client1Channel . presence . leave ( leaveComplete ) ; presenceWaiter . waitFor ( testClientId1 , Action . leave ) ; assertNotNull ( presenceWaiter . contains ( testClientId1 , Action . leave ) ) ; assertEquals ( presenceWaiter . receivedMessages . get ( 0 ) . data , enterString ) ; /* verify leave callback called on completion */ leaveComplete . waitFor ( ) ; assertTrue ( "Verify leave callback called on completion" , leaveComplete . success ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; } finally { if ( clientAbly1 != null ) clientAbly1 . close ( ) ; if ( testChannel != null ) testChannel . dispose ( ) ; } }
Enter, then leave (with no data) and await leave event,
 expecting enter data to be in leave event
Enter then leave ( with no data ) and await leave event expecting enter data to be in leave event