lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java
/**
     * <p>
     * Validate {@code Presence#enter(...)} will result in the listener not being
     * registered and an error being indicated, when the channel moves to the
     * FAILED state before the operation succeeds
     * </p>
     * <p>
     * Spec: RTP8d
     * </p>
     *
     * @throws AblyException
     */

Validate  Presence#enter(...) will result in the listener not being
registered and an error being indicated, when the channel moves to the
FAILED state before the operation succeeds


Spec: RTP8d



Validate Presence#enter ( ... ) will result in the listener not being registered and an error being indicated when the channel moves to the FAILED state before the operation succeeds Spec : RTP8d
@Test
    public void realtime_presence_attach_implicit_enter_fail() throws AblyException {
        AblyRealtime ably = null;
        try {
            ClientOptions opts = createOptions(testVars.keys[1].keyStr);
            opts.clientId = "theClient";
            ably = new AblyRealtime(opts);
            /* wait until connected */
            new ConnectionWaiter(ably.connection).waitFor(ConnectionState.connected);
            assertEquals("Verify connected state reached", ably.connection.state, ConnectionState.connected);
            /* create a channel and subscribe */
            final Channel channel = ably.channels.get("enter_fail_" + testParams.name);
            CompletionWaiter completionWaiter = new CompletionWaiter();
            channel.presence.enter("Lorem Ipsum", completionWaiter);
            assertEquals("Verify attaching state reached", channel.state, ChannelState.attaching);
            ErrorInfo errorInfo = completionWaiter.waitFor();
            new ChannelWaiter(channel).waitFor(ChannelState.failed);
            assertEquals("Verify failed state reached", channel.state, ChannelState.failed);
            assertEquals("Verify reason code gives correct failure reason", errorInfo.statusCode, 401);
        } finally {
            if(ably != null)
                ably.close();
        }
    }
@ Test public void realtime_presence_attach_implicit_enter_fail ( ) throws AblyException { AblyRealtime ably = null ; try { ClientOptions opts = createOptions ( testVars . keys [ 1 ] . keyStr ) ; opts . clientId = "theClient" ; ably = new AblyRealtime ( opts ) ; /* wait until connected */ new ConnectionWaiter ( ably . connection ) . waitFor ( ConnectionState . connected ) ; assertEquals ( "Verify connected state reached" , ably . connection . state , ConnectionState . connected ) ; /* create a channel and subscribe */ final Channel channel = ably . channels . get ( "enter_fail_" + testParams . name ) ; CompletionWaiter completionWaiter = new CompletionWaiter ( ) ; channel . presence . enter ( "Lorem Ipsum" , completionWaiter ) ; assertEquals ( "Verify attaching state reached" , channel . state , ChannelState . attaching ) ; ErrorInfo errorInfo = completionWaiter . waitFor ( ) ; new ChannelWaiter ( channel ) . waitFor ( ChannelState . failed ) ; assertEquals ( "Verify failed state reached" , channel . state , ChannelState . failed ) ; assertEquals ( "Verify reason code gives correct failure reason" , errorInfo . statusCode , 401 ) ; } finally { if ( ably != null ) ably . close ( ) ; } }
<p>
 Validate {@code Presence#enter(...)} will result in the listener not being
 registered and an error being indicated, when the channel moves to the
 FAILED state before the operation succeeds
 </p>
 <p>
 Spec: RTP8d
 </p>
<p > Validate { @code Presence#enter ( ... ) } will result in the listener not being registered and an error being indicated when the channel moves to the FAILED state before the operation succeeds < / p > <p > Spec : RTP8d < / p >