lib/src/test/java/io/ably/lib/test/realtime/RealtimeConnectTest.java
/**
     * Connect with useTokenAuth=true and verify we got a token
     */
Connect with useTokenAuth=true and verify we got a token
Connect with useTokenAuth = true and verify we got a token
@Test
    public void connect_useTokenAuth() {
        AblyRealtime ably = null;
        try {
            ClientOptions opts = createOptions(testVars.keys[0].keyStr);
            opts.useTokenAuth = true;
            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);
            assertTrue("Expected to use token auth", ably.auth.getAuthMethod() == AuthMethod.token);
            System.out.println("Token is " + ably.auth.getTokenDetails().token);
        } catch (AblyException e) {
            e.printStackTrace();
            fail("init1: Unexpected exception instantiating library");
        } finally {
            if(ably != null) ably.close();
        }
    }
@ Test public void connect_useTokenAuth ( ) { AblyRealtime ably = null ; try { ClientOptions opts = createOptions ( testVars . keys [ 0 ] . keyStr ) ; opts . useTokenAuth = true ; 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 ) ; assertTrue ( "Expected to use token auth" , ably . auth . getAuthMethod ( ) == AuthMethod . token ) ; System . out . println ( "Token is " + ably . auth . getTokenDetails ( ) . token ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; fail ( "init1: Unexpected exception instantiating library" ) ; } finally { if ( ably != null ) ably . close ( ) ; } }
Connect with useTokenAuth=true and verify we got a token
Connect with useTokenAuth = true and verify we got a token