Skip to content

Commit 97e6113

Browse files
authored
chore: change waiting condition for the test (#704)
change while() condition in testListLogEntriesSample() code. instead of waiting for first printed log entry it waits for the entry with designated payload. test will timeout after minute or succeed. Fixes #692
1 parent e30ca05 commit 97e6113

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

samples/snippets/src/test/java/com/example/logging/LoggingIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ public void testListLogEntriesSample() throws Exception {
112112
logging.flush();
113113
bout.reset();
114114

115-
// Check for mocked STDOUT having data
115+
// Check for mocked STDOUT for having STRING_PAYLOAD2 substring
116116
String[] args = new String[] {TEST_LOG};
117-
while (bout.toString().isEmpty()) {
117+
while (!bout.toString().contains(STRING_PAYLOAD2)) {
118118
ListLogEntries.main(args);
119119
Thread.sleep(5000);
120120
}
121+
// although the following assertion is formal
122+
// the line is left to emphasis the validation that is done by the test
121123
assertThat(bout.toString().contains(STRING_PAYLOAD2)).isTrue();
122124
}
123125

0 commit comments

Comments
 (0)