Skip to content

Commit

Permalink
Remove assertions, replace with awaitility
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrutter committed Jan 3, 2025
1 parent bc2e6a0 commit 96e39f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ public void testMissingDepencencyWarningLogs() throws Exception {
Awaitility.await("waitForLogs")
.atMost(Duration.ofSeconds(50))
.pollDelay(Duration.ofMillis(200))
.until(() -> containsString(logFile, "org.apache.felix.http.jetty[org.apache.felix.http]"));

assertTrue(containsString(logFile, "Failed to initialize jetty specific websocket support"));
assertTrue(containsString(logFile, "Failed to initialize jakarta standard websocket support"));
.until(() -> containsString(logFile, "Failed to initialize jetty specific websocket support")
&& containsString(logFile, "Failed to initialize jakarta standard websocket support"));
}

/**
* Checks if the text is present in the file
*
* @param file the file to check
*
* @param file the file to check
* @param expected the text to look for
* @return true if the text was found, false otherwise
*/
private boolean containsString(File file, String expected) throws IOException {
String content = new String(Files.readAllBytes(file.toPath()));
return content.contains(expected);
try (Stream<String> stream = Files.lines(file.toPath())) {
return stream.anyMatch(line -> line.contains(expected));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ public void testMissingDepencencyWarningLogs() throws Exception {
Awaitility.await("waitForLogs")
.atMost(Duration.ofSeconds(50))
.pollDelay(Duration.ofMillis(200))
.until(() -> containsString(logFile, "org.apache.felix.http.jetty12[org.apache.felix.http]"));

assertTrue(containsString(logFile, "Failed to initialize jetty EE10 specific websocket support"));
assertTrue(containsString(logFile, "Failed to initialize jakarta EE10 standard websocket support"));
.until(() -> containsString(logFile, "Failed to initialize jetty EE10 specific websocket support")
&& containsString(logFile, "Failed to initialize jakarta EE10 standard websocket support"));
}

/**
* Checks if the text is present in the file
*
* @param file the file to check
* @param file the file to check
* @param expected the text to look for
* @return true if the text was found, false otherwise
*/
private boolean containsString(File file, String expected) throws IOException {
String content = new String(Files.readAllBytes(file.toPath()));
return content.contains(expected);
try (Stream<String> stream = Files.lines(file.toPath())) {
return stream.anyMatch(line -> line.contains(expected));
}
}

}

0 comments on commit 96e39f4

Please sign in to comment.