Skip to content

Commit

Permalink
Wait until the connect process is fully completed before asserting st…
Browse files Browse the repository at this point in the history
…ate (#564)

Related issue: #560
  • Loading branch information
brenuart authored Jul 10, 2021
1 parent 32d6f87 commit 68b8be1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -175,7 +176,7 @@ public void testReconnectOnOpen() throws Exception {

appender.stop();

verify(listener).connectionClosed(appender, socket);
verify(listener, timeout(VERIFICATION_TIMEOUT)).connectionClosed(appender, socket);

assertThat(appender.getConnectedDestination()).isNotPresent();
}
Expand Down Expand Up @@ -236,14 +237,16 @@ public void testConnectOnPrimary() throws Exception {
appender.start();
verify(encoder).start();

// Wait for the connection process to be fully completed
verify(listener, timeout(VERIFICATION_TIMEOUT)).connectionOpened(appender, socket);

// Only one socket should have been created
verify(socket, timeout(VERIFICATION_TIMEOUT).times(1)).connect(any(SocketAddress.class), anyInt());
verify(socket, times(1)).connect(any(SocketAddress.class), anyInt());

// The only socket should be connected to primary
verify(socket).connect(host("localhost", 10000), anyInt());

assertThat(appender.getConnectedDestination()).isPresent();

}


Expand Down

0 comments on commit 68b8be1

Please sign in to comment.