@@ -2743,6 +2743,37 @@ public void noConnectionIdWhenSkippingNegotiate() {
27432743 assertNull (hubConnection .getConnectionId ());
27442744 }
27452745
2746+ @ Test
2747+ public void SkippingNegotiateDoesNotNegotiate () {
2748+ try (TestLogger logger = new TestLogger (WebSocketTransport .class .getName ())) {
2749+ AtomicBoolean negotiateCalled = new AtomicBoolean (false );
2750+ TestHttpClient client = new TestHttpClient ().on ("POST" , "http://example.com/negotiate?negotiateVersion=1" ,
2751+ (req ) -> {
2752+ negotiateCalled .set (true );
2753+ return Single .just (new HttpResponse (200 , "" ,
2754+ TestUtils .stringToByteBuffer ("{\" connectionId\" :\" bVOiRPG8-6YiJ6d7ZcTOVQ\" ,\" "
2755+ + "availableTransports\" :[{\" transport\" :\" WebSockets\" ,\" transferFormats\" :[\" Text\" ,\" Binary\" ]}]}" )));
2756+ });
2757+
2758+ HubConnection hubConnection = HubConnectionBuilder
2759+ .create ("http://example" )
2760+ .withTransport (TransportEnum .WEBSOCKETS )
2761+ .shouldSkipNegotiate (true )
2762+ .withHttpClient (client )
2763+ .build ();
2764+
2765+ try {
2766+ hubConnection .start ().timeout (30 , TimeUnit .SECONDS ).blockingAwait ();
2767+ } catch (Exception e ) {
2768+ assertEquals ("WebSockets isn't supported in testing currently." , e .getMessage ());
2769+ }
2770+ assertEquals (HubConnectionState .DISCONNECTED , hubConnection .getConnectionState ());
2771+ assertFalse (negotiateCalled .get ());
2772+
2773+ logger .assertLog ("Starting Websocket connection." );
2774+ }
2775+ }
2776+
27462777 @ Test
27472778 public void connectionIdIsAvailableAfterStart () {
27482779 TestHttpClient client = new TestHttpClient ().on ("POST" , "http://example.com/negotiate?negotiateVersion=1" ,
0 commit comments