@@ -32,6 +32,8 @@ public class WebSocketConnectionTest {
3232
3333    private  static  final  long  ACTIVITY_TIMEOUT  = 500 ;
3434    private  static  final  long  PONG_TIMEOUT  = 500 ;
35+     private  static  final  int  MAX_RECONNECTIONS  = 6 ;
36+     private  static  final  int  MAX_GAP  = 30 ;
3537    private  static  final  String  URL  = "ws://ws.example.com/" ;
3638    private  static  final  String  EVENT_NAME  = "my-event" ;
3739    private  static  final  String  CONN_ESTABLISHED_EVENT  = "{\" event\" :\" pusher:connection_established\" ,\" data\" :\" {\\ \" socket_id\\ \" :\\ \" 21112.816204\\ \" }\" }" ;
@@ -65,22 +67,24 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
6567        }).when (factory ).queueOnEventThread (any (Runnable .class ));
6668        when (factory .getTimers ()).thenReturn (new  DoNothingExecutor ());
6769
68-         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , PROXY , factory );
70+         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , MAX_RECONNECTIONS ,  MAX_GAP ,  PROXY , factory );
6971        connection .bind (ConnectionState .ALL , mockEventListener );
7072    }
7173
7274    @ Test 
7375    public  void  testUnbindingWhenNotAlreadyBoundReturnsFalse () throws  URISyntaxException  {
7476        final  ConnectionEventListener  listener  = mock (ConnectionEventListener .class );
75-         final  WebSocketConnection  connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , PROXY , factory );
77+         final  WebSocketConnection  connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , MAX_RECONNECTIONS , MAX_GAP ,
78+                 PROXY , factory );
7679        final  boolean  unbound  = connection .unbind (ConnectionState .ALL , listener );
7780        assertEquals (false , unbound );
7881    }
7982
8083    @ Test 
8184    public  void  testUnbindingWhenBoundReturnsTrue () throws  URISyntaxException  {
8285        final  ConnectionEventListener  listener  = mock (ConnectionEventListener .class );
83-         final  WebSocketConnection  connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , PROXY , factory );
86+         final  WebSocketConnection  connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , MAX_RECONNECTIONS , MAX_GAP ,
87+                 PROXY , factory );
8488
8589        connection .bind (ConnectionState .ALL , listener );
8690
@@ -118,7 +122,8 @@ public void testConnectDoesNotCallConnectOnUnderlyingConnectionIfAlreadyInConnec
118122
119123    @ Test 
120124    public  void  testListenerDoesNotReceiveConnectingEventIfItIsOnlyBoundToTheConnectedEvent () throws  URISyntaxException  {
121-         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , PROXY , factory );
125+         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , MAX_RECONNECTIONS , MAX_GAP ,
126+                 PROXY , factory );
122127        connection .bind (ConnectionState .CONNECTED , mockEventListener );
123128        connection .connect ();
124129
@@ -219,7 +224,8 @@ public void testOnCloseCallbackUpdatesStateToDisconnectedWhenPreviousStateIsDisc
219224
220225    @ Test 
221226    public  void  testOnCloseCallbackDoesNotCallListenerIfItIsNotBoundToDisconnectedEvent () throws  URISyntaxException  {
222-         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , PROXY , factory );
227+         connection  = new  WebSocketConnection (URL , ACTIVITY_TIMEOUT , PONG_TIMEOUT , MAX_RECONNECTIONS , MAX_GAP ,
228+                 PROXY , factory );
223229        connection .bind (ConnectionState .CONNECTED , mockEventListener );
224230
225231        connection .connect ();
0 commit comments