lib/src/test/java/io/ably/lib/test/realtime/RealtimeConnectTest.java
/**
     * Verify that given transport params are included in the ws connection URL.
     */
Verify that given transport params are included in the ws connection URL.
Verify that given transport params are included in the ws connection URL .
@Test
    public void connect_with_transport_params() {
        try {
            DebugOptions opts = new DebugOptions(testVars.keys[0].keyStr);
            fillInOptions(opts);
            final String[] urlWrapper = new String[1];
            opts.protocolListener = new RawProtocolListener() {
                @Override
                public void onRawConnect(String url) {
                    /* store url */
                    urlWrapper[0] = url;
                }
                @Override
                public void onRawConnectRequested(String url) {}
                @Override
                public void onRawMessageSend(ProtocolMessage message) {}
                @Override
                public void onRawMessageRecv(ProtocolMessage message) {}
            };
            opts.transportParams = new Param[] {new Param("testStringParam", "testStringValue"), new Param("testIntParam", 100), new Param("testBooleanParam", false)};
            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);
            String url = urlWrapper[0];
            assertNotNull("Verify connection url was obtained", url);
            assertTrue("Verify expected string param present", url.contains("testStringParam=testStringValue"));
            assertTrue("Verify expected int param present", url.contains("testIntParam=100"));
            assertTrue("Verify expected boolean param present", url.contains("testBooleanParam=false"));
            ably.close();
            connectionWaiter.waitFor(ConnectionState.closed);
            assertEquals("Verify closed state is reached", ConnectionState.closed, ably.connection.state);
        } catch (AblyException e) {
            e.printStackTrace();
            fail("connect_with_transport_params: Unexpected exception instantiating library");
        }
    }
@ Test public void connect_with_transport_params ( ) { try { DebugOptions opts = new DebugOptions ( testVars . keys [ 0 ] . keyStr ) ; fillInOptions ( opts ) ; final String [ ] urlWrapper = new String [ 1 ] ; opts . protocolListener = new RawProtocolListener ( ) { @ Override public void onRawConnect ( String url ) { /* store url */ urlWrapper [ 0 ] = url ; } @ Override public void onRawConnectRequested ( String url ) { } @ Override public void onRawMessageSend ( ProtocolMessage message ) { } @ Override public void onRawMessageRecv ( ProtocolMessage message ) { } } ; opts . transportParams = new Param [ ] { new Param ( "testStringParam" , "testStringValue" ) , new Param ( "testIntParam" , 100 ) , new Param ( "testBooleanParam" , false ) } ; 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 ) ; String url = urlWrapper [ 0 ] ; assertNotNull ( "Verify connection url was obtained" , url ) ; assertTrue ( "Verify expected string param present" , url . contains ( "testStringParam=testStringValue" ) ) ; assertTrue ( "Verify expected int param present" , url . contains ( "testIntParam=100" ) ) ; assertTrue ( "Verify expected boolean param present" , url . contains ( "testBooleanParam=false" ) ) ; ably . close ( ) ; connectionWaiter . waitFor ( ConnectionState . closed ) ; assertEquals ( "Verify closed state is reached" , ConnectionState . closed , ably . connection . state ) ; } catch ( AblyException e ) { e . printStackTrace ( ) ; fail ( "connect_with_transport_params: Unexpected exception instantiating library" ) ; } }
Verify that given transport params are included in the ws connection URL.
Verify that given transport params are included in the ws connection URL .