Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ void wireLoggerLogsOpeningAndClosingConnectionAroundHttpRequest() throws Excepti
}
// Implicit close of auto-closeable client so that "Closing connection" is logged before we assert.

List<String> messages = logSpy.getMessages();
// "Closing connection" is logged asynchronously by the server's event loop, and
// ListAppender#getMessages returns a snapshot, so re-read the messages on each poll.
Awaitility.await()
.atMost(5, TimeUnit.SECONDS)
.until(() -> messages.size() >= 4);

assertThat(messages, hasItem(matchesPattern("Opening connection .*" + HOST + ":\\d+")));
assertThat(messages, hasItem(matchesPattern("Closing connection .*" + HOST + ":\\d+")));
.untilAsserted(() -> {
List<String> messages = logSpy.getMessages();
assertThat(messages, hasItem(matchesPattern("Opening connection .*" + HOST + ":\\d+")));
assertThat(messages, hasItem(matchesPattern("Closing connection .*" + HOST + ":\\d+")));
});
}

@Test
Expand Down
Loading