lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * Attach to channel, enter presence channel and get presence using realtime get()
     */
Attach to channel, enter presence channel and get presence using realtime get()
Attach to channel enter presence channel and get presence using realtime get ()
@Ignore("FIXME: fix exception")
    @Test
    public void realtime_get_simple() {
        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);
            /* wait until connected */
            (new ConnectionWaiter(clientAbly1.connection)).waitFor(ConnectionState.connected);
            assertEquals("Verify connected state reached", clientAbly1.connection.state, ConnectionState.connected);
            /* get channel and attach */
            Channel client1Channel = clientAbly1.channels.get(testChannel.channelName);
            client1Channel.attach();
            (new ChannelWaiter(client1Channel)).waitFor(ChannelState.attached);
            assertEquals("Verify attached state reached", client1Channel.state, ChannelState.attached);
            /* let client1 enter the channel and wait for the success callback */
            CompletionWaiter enterComplete = new CompletionWaiter();
            String enterString = "Test data (get_simple)";
            client1Channel.presence.enter(enterString, enterComplete);
            enterComplete.waitFor();
            assertTrue("Verify enter callback called on completion", enterComplete.success);
            /* get presence set and verify client present */
            presenceWaiter.waitFor(testClientId1);
            PresenceMessage[] presences = testChannel.realtimeChannel.presence.get(false);
            PresenceMessage expectedPresent = contains(presences, testClientId1, Action.present);
            assertNotNull("Verify expected client is in presence set", expectedPresent);
            assertEquals(expectedPresent.data, enterString);
        } 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 realtime_get_simple ( ) { 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 ) ; /* wait until connected */ ( new ConnectionWaiter ( clientAbly1 . connection ) ) . waitFor ( ConnectionState . connected ) ; assertEquals ( "Verify connected state reached" , clientAbly1 . connection . state , ConnectionState . connected ) ; /* get channel and attach */ Channel client1Channel = clientAbly1 . channels . get ( testChannel . channelName ) ; client1Channel . attach ( ) ; ( new ChannelWaiter ( client1Channel ) ) . waitFor ( ChannelState . attached ) ; assertEquals ( "Verify attached state reached" , client1Channel . state , ChannelState . attached ) ; /* let client1 enter the channel and wait for the success callback */ CompletionWaiter enterComplete = new CompletionWaiter ( ) ; String enterString = "Test data (get_simple)" ; client1Channel . presence . enter ( enterString , enterComplete ) ; enterComplete . waitFor ( ) ; assertTrue ( "Verify enter callback called on completion" , enterComplete . success ) ; /* get presence set and verify client present */ presenceWaiter . waitFor ( testClientId1 ) ; PresenceMessage [ ] presences = testChannel . realtimeChannel . presence . get ( false ) ; PresenceMessage expectedPresent = contains ( presences , testClientId1 , Action . present ) ; assertNotNull ( "Verify expected client is in presence set" , expectedPresent ) ; assertEquals ( expectedPresent . data , enterString ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; fail ( "Unexpected exception running test: " + e . getMessage ( ) ) ; } finally { if ( clientAbly1 != null ) clientAbly1 . close ( ) ; if ( testChannel != null ) testChannel . dispose ( ) ; } }
Attach to channel, enter presence channel and get presence using realtime get()
Attach to channel enter presence channel and get presence using realtime get ()