Skip to content

Commit 1512b0f

Browse files
authored
chore: change waiting condition for the test (googleapis#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 googleapis#692
1 parent a057554 commit 1512b0f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • java-logging/samples/snippets/src/test/java/com/example/logging

java-logging/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)