lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * Enter wrong client (mismatching one set in the token), check exception
     */
Enter wrong client (mismatching one set in the token), check exception
Enter wrong client ( mismatching one set in the token ) check exception
@Ignore("FIXME: fix exception")
    @Test
    public void presence_enter_mismatched_clientid() throws AblyException {
        String channelName = "presence_enter_mismatched_clientid" + testParams.name;
        AblyRealtime ably = null;
        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);
            /* should succeed with testClientId1 */
            CompletionWaiter enterWaiter = new CompletionWaiter();
            channel.presence.enterClient(testClientId1, null, enterWaiter);
            ErrorInfo enterErr = enterWaiter.waitFor();
            assertNull("Verify enter client succeeded", enterErr);
            /* should fail with testClientId2 */
            enterWaiter.reset();
            channel.presence.enterClient(testClientId2, null, enterWaiter);
            enterErr = enterWaiter.waitFor();
            assertNotNull("Verify enter client failed", enterErr);
        } finally {
            if (ably != null)
                ably.close();
        }
    }
@ Ignore ( "FIXME: fix exception" ) @ Test public void presence_enter_mismatched_clientid ( ) throws AblyException { String channelName = "presence_enter_mismatched_clientid" + testParams . name ; AblyRealtime ably = null ; 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 ) ; /* should succeed with testClientId1 */ CompletionWaiter enterWaiter = new CompletionWaiter ( ) ; channel . presence . enterClient ( testClientId1 , null , enterWaiter ) ; ErrorInfo enterErr = enterWaiter . waitFor ( ) ; assertNull ( "Verify enter client succeeded" , enterErr ) ; /* should fail with testClientId2 */ enterWaiter . reset ( ) ; channel . presence . enterClient ( testClientId2 , null , enterWaiter ) ; enterErr = enterWaiter . waitFor ( ) ; assertNotNull ( "Verify enter client failed" , enterErr ) ; } finally { if ( ably != null ) ably . close ( ) ; } }
Enter wrong client (mismatching one set in the token), check exception
Enter wrong client ( mismatching one set in the token ) check exception