lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * Enter channel without subscribe permission, expect presence message from this connection
     * Test RTP17a
     *
     * Not functional yet
     */
Enter channel without subscribe permission, expect presence message from this connection
Test RTP17a

Not functional yet
Enter channel without subscribe permission expect presence message from this connection Test RTP17a Not functional yet
@Ignore("FIXME: fix exception")
    @Test
    public void presence_without_subscribe_capability() throws AblyException {
        String channelName = "presence_without_subscribe" + testParams.name;
        AblyRealtime ably = null;
        String presenceData = "presence_test_data";
        try {
            /* init ably for token */
            ClientOptions optsForToken = createOptions(testVars.keys[0].keyStr);
            final AblyRest ablyForToken = new AblyRest(optsForToken);
            /* get first token */
            Auth.TokenParams tokenParams = new Auth.TokenParams();
            Capability capability = new Capability();
            capability.addResource(channelName, "publish");
            capability.addOperation(channelName, "presence");
            tokenParams.capability = capability.toString();
            tokenParams.clientId = testClientId1;
            Auth.TokenDetails token = ablyForToken.auth.requestToken(tokenParams, null);
            assertNotNull("Expected token value", token.token);
            ClientOptions opts = createOptions();
            opts.clientId = testClientId1;
            opts.tokenDetails = token;
            ably = new AblyRealtime(opts);
            Channel channel = ably.channels.get(channelName);
            channel.attach();
            ChannelWaiter channelWaiter = new ChannelWaiter(channel);
            channelWaiter.waitFor(ChannelState.attached);
            channel.presence.enterClient(testClientId1, presenceData, new CompletionListener() {
                @Override
                public void onSuccess() {
                    System.out.println("Success");
                }
                @Override
                public void onError(ErrorInfo reason) {
                    System.out.println("failure");
                }
            });
            PresenceWaiter presenceWaiter = new PresenceWaiter(Action.enter, channel);
            presenceWaiter.waitFor(1);
            PresenceMessage[] presenceMessages = channel.presence.get(testClientId1, false);
            assertEquals("Verify total number of received presence messages", presenceMessages.length, 1);
            assertEquals("Verify present message is valid", presenceMessages[0].data, presenceData);
        } finally {
            if (ably != null)
                ably.close();
        }
    }
@ Ignore ( "FIXME: fix exception" ) @ Test public void presence_without_subscribe_capability ( ) throws AblyException { String channelName = "presence_without_subscribe" + testParams . name ; AblyRealtime ably = null ; String presenceData = "presence_test_data" ; try { /* init ably for token */ ClientOptions optsForToken = createOptions ( testVars . keys [ 0 ] . keyStr ) ; final AblyRest ablyForToken = new AblyRest ( optsForToken ) ; /* get first token */ Auth . TokenParams tokenParams = new Auth . TokenParams ( ) ; Capability capability = new Capability ( ) ; capability . addResource ( channelName , "publish" ) ; capability . addOperation ( channelName , "presence" ) ; tokenParams . capability = capability . toString ( ) ; tokenParams . clientId = testClientId1 ; Auth . TokenDetails token = ablyForToken . auth . requestToken ( tokenParams , null ) ; assertNotNull ( "Expected token value" , token . token ) ; ClientOptions opts = createOptions ( ) ; opts . clientId = testClientId1 ; opts . tokenDetails = token ; ably = new AblyRealtime ( opts ) ; Channel channel = ably . channels . get ( channelName ) ; channel . attach ( ) ; ChannelWaiter channelWaiter = new ChannelWaiter ( channel ) ; channelWaiter . waitFor ( ChannelState . attached ) ; channel . presence . enterClient ( testClientId1 , presenceData , new CompletionListener ( ) { @ Override public void onSuccess ( ) { System . out . println ( "Success" ) ; } @ Override public void onError ( ErrorInfo reason ) { System . out . println ( "failure" ) ; } } ) ; PresenceWaiter presenceWaiter = new PresenceWaiter ( Action . enter , channel ) ; presenceWaiter . waitFor ( 1 ) ; PresenceMessage [ ] presenceMessages = channel . presence . get ( testClientId1 , false ) ; assertEquals ( "Verify total number of received presence messages" , presenceMessages . length , 1 ) ; assertEquals ( "Verify present message is valid" , presenceMessages [ 0 ] . data , presenceData ) ; } finally { if ( ably != null ) ably . close ( ) ; } }
Enter channel without subscribe permission, expect presence message from this connection
 Test RTP17a
Enter channel without subscribe permission expect presence message from this connection Test RTP17a
//capability.addOperation(channelName, "subscribe");