Skip to content

Commit

Permalink
ConnectionManagerTest: avoid use of race-prone ConnectionManagerWaite…
Browse files Browse the repository at this point in the history
…r helper
  • Loading branch information
paddybyers committed Nov 15, 2019
1 parent d073edb commit a61136a
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void connectionmanager_fallback_none() throws AblyException {
AblyRealtime ably = new AblyRealtime(opts);
ConnectionManager connectionManager = ably.connection.connectionManager;

new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.connected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.connected);

/* Verify that,
* - connectionManager is connected
Expand Down Expand Up @@ -96,7 +96,7 @@ public void connectionmanager_fallback_none_customhost() throws AblyException {
AblyRealtime ably = new AblyRealtime(opts);
ConnectionManager connectionManager = ably.connection.connectionManager;

new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.disconnected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.disconnected);

/* Verify that,
* - connectionManager is disconnected
Expand Down Expand Up @@ -126,6 +126,7 @@ public void connectionmanager_fallback_none_withoutconnection() throws AblyExcep
opts.realtimeHost = "un.reachable.host";
opts.environment = null;
opts.autoConnect = false;
opts.logLevel = Log.VERBOSE;
AblyRealtime ably = new AblyRealtime(opts);
Connection connection = Mockito.mock(Connection.class);

Expand Down Expand Up @@ -176,7 +177,7 @@ public void connectionmanager_fallback_applied() throws AblyException {
AblyRealtime ably = new AblyRealtime(opts);
ConnectionManager connectionManager = ably.connection.connectionManager;

new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.disconnected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.disconnected);

/* Verify that,
* - connectionManager is disconnected
Expand Down Expand Up @@ -210,7 +211,7 @@ public void connectionmanager_reconnect_default_endpoint() throws AblyException
ConnectionManager connectionManager = ably.connection.connectionManager;

System.out.println("waiting for disconnected");
new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.disconnected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.disconnected);
System.out.println("got disconnected");

/* Verify that,
Expand All @@ -225,7 +226,7 @@ public void connectionmanager_reconnect_default_endpoint() throws AblyException
System.out.println("about to connect");
ably.connection.connect();

new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.failed);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.failed);

/* Verify that,
* - connectionManager is failed, because we are using an application key
Expand Down Expand Up @@ -260,7 +261,7 @@ public void connectionmanager_reconnect_default_fallback() throws AblyException
ConnectionManager connectionManager = ably.connection.connectionManager;

System.out.println("waiting for disconnected");
new Helpers.ConnectionManagerWaiter(connectionManager).waitFor(ConnectionState.disconnected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.disconnected);
System.out.println("got disconnected");
ably.close();

Expand Down Expand Up @@ -470,7 +471,7 @@ public void onConnectionStateChanged(ConnectionStateChange state) {
}
}
});
new Helpers.ConnectionManagerWaiter(ably.connection.connectionManager).waitFor(ConnectionState.connected);
new Helpers.ConnectionWaiter(ably.connection).waitFor(ConnectionState.connected);
assertTrue("Connected callback was not run", callbackWasRun[0]);
ably.close();
} catch (AblyException e) {
Expand Down

0 comments on commit a61136a

Please sign in to comment.