lib/src/test/java/io/ably/lib/test/realtime/RealtimeConnectTest.java
/**
     * Perform a simple connect to the service
     * and confirm that heartbeat messages are received.
     */
Perform a simple connect to the service
and confirm that heartbeat messages are received.
Perform a simple connect to the service and confirm that heartbeat messages are received .
@Test
    public void connect_heartbeat() {
        try {
            ClientOptions opts = createOptions(testVars.keys[0].keyStr);
            CompletionWaiter heartbeatWaiter = new CompletionWaiter();
            AblyRealtime ably = new AblyRealtime(opts);
            ConnectionWaiter connectionWaiter = new ConnectionWaiter(ably.connection);
            connectionWaiter.waitFor(ConnectionState.connected);
            assertEquals("Verify connected state is reached", ConnectionState.connected, ably.connection.state);
            ably.connection.ping(heartbeatWaiter);
            heartbeatWaiter.waitFor();
            assertTrue("Verify heartbeat occurred", heartbeatWaiter.success);
            ably.close();
            connectionWaiter.waitFor(ConnectionState.closed);
            assertEquals("Verify closed state is reached", ConnectionState.closed, ably.connection.state);
        } catch (AblyException e) {
            e.printStackTrace();
            fail("init0: Unexpected exception instantiating library");
        }
    }
@ Test public void connect_heartbeat ( ) { try { ClientOptions opts = createOptions ( testVars . keys [ 0 ] . keyStr ) ; CompletionWaiter heartbeatWaiter = new CompletionWaiter ( ) ; AblyRealtime ably = new AblyRealtime ( opts ) ; ConnectionWaiter connectionWaiter = new ConnectionWaiter ( ably . connection ) ; connectionWaiter . waitFor ( ConnectionState . connected ) ; assertEquals ( "Verify connected state is reached" , ConnectionState . connected , ably . connection . state ) ; ably . connection . ping ( heartbeatWaiter ) ; heartbeatWaiter . waitFor ( ) ; assertTrue ( "Verify heartbeat occurred" , heartbeatWaiter . success ) ; ably . close ( ) ; connectionWaiter . waitFor ( ConnectionState . closed ) ; assertEquals ( "Verify closed state is reached" , ConnectionState . closed , ably . connection . state ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; fail ( "init0: Unexpected exception instantiating library" ) ; } }
Perform a simple connect to the service
 and confirm that heartbeat messages are received.
Perform a simple connect to the service and confirm that heartbeat messages are received .