Skip to content

Commit

Permalink
fix: integration tests for OkHttp realtime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttypic committed Oct 3, 2024
1 parent c7ba0b0 commit f75ca55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class WebSocketTransport implements ITransport {
private ConnectListener connectListener;
private WebSocketClient webSocketClient;
private final WebSocketEngine webSocketEngine;
private boolean activityCheckTurnedOff = false;

/******************
* protected constructor
Expand Down Expand Up @@ -173,6 +174,16 @@ protected void preProcessReceivedMessage(ProtocolMessage message) {
//Gives the chance to child classes to do message pre-processing
}

/**
* Visible For Testing
* </p>
* We need to turn off activity check for some tests (e.g. io.ably.lib.test.realtime.RealtimeConnectFailTest.disconnect_retry_channel_timeout_jitter_after_consistent_detach[binary_protocol])
* Those tests expects that activity checks are passing, but protocol messages are not coming
*/
protected void turnOffActivityCheckIfPingListenerIsNotSupported() {
if (!webSocketEngine.isPingListenerSupported()) activityCheckTurnedOff = true;
}

public String toString() {
return WebSocketTransport.class.getName() + " {" + getURL() + "}";
}
Expand Down Expand Up @@ -319,7 +330,7 @@ private synchronized void dispose() {
private synchronized void flagActivity() {
lastActivityTime = System.currentTimeMillis();
connectionManager.setLastActivity(lastActivityTime);
if (activityTimerTask == null && connectionManager.maxIdleInterval != 0) {
if (activityTimerTask == null && connectionManager.maxIdleInterval != 0 && !activityCheckTurnedOff) {
/* No timer currently running because previously there was no
* maxIdleInterval configured, but now there is a
* maxIdleInterval configured. Call checkActivity so a timer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private MockWebsocketTransport(TransportParams givenTransportParams, TransportPa
super(transformedTransportParams, connectionManager);
this.givenTransportParams = givenTransportParams;
this.transformedTransportParams = transformedTransportParams;
turnOffActivityCheckIfPingListenerIsNotSupported();
}

public List<ProtocolMessage> getSentMessages() {
Expand Down

0 comments on commit f75ca55

Please sign in to comment.