Skip to content

Commit 86cff67

Browse files
committed
test: cleanup test run warnings
1 parent 84eaf8f commit 86cff67

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ private void installBrowsers(Map<String, String> env) throws IOException, Interr
8787
}
8888
ProcessBuilder pb = createProcessBuilder();
8989
pb.command().add("install");
90-
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
91-
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
90+
if (System.getenv("PW_JAVA_INTERNAL_SILENT_INSTALL") != null) {
91+
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
92+
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
93+
}
9294
Process p = pb.start();
9395
boolean result = p.waitFor(10, TimeUnit.MINUTES);
9496
if (!result) {

driver-bundle/src/test/java/com/microsoft/playwright/impl/driver/jar/TestInstall.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void shouldThrowWhenBrowserPathIsInvalid(@TempDir Path tmpDir) throws NoSuchFiel
7474
// Make sure the browsers are not installed yet by pointing at an empty dir.
7575
env.put("PLAYWRIGHT_BROWSERS_PATH", tmpDir.toString());
7676
env.put("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "false");
77+
env.put("PW_JAVA_INTERNAL_SILENT_INSTALL", "true");
7778

7879
RuntimeException exception = assertThrows(RuntimeException.class, () -> Driver.createAndInstall(env, true));
7980
String message = exception.getMessage();

playwright/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
<groupId>org.java-websocket</groupId>
5858
<artifactId>Java-WebSocket</artifactId>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.slf4j</groupId>
62+
<artifactId>slf4j-simple</artifactId>
63+
</dependency>
6064
<dependency>
6165
<groupId>org.junit.jupiter</groupId>
6266
<artifactId>junit-jupiter-engine</artifactId>

playwright/src/test/java/com/microsoft/playwright/Server.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void handle(HttpExchange exchange) throws IOException {
218218
}
219219
long contentLength = body.size();
220220
// -1 means no body, 0 means chunked encoding.
221-
exchange.sendResponseHeaders(200, contentLength == 0 ? -1 : contentLength);
221+
exchange.sendResponseHeaders(200, (contentLength == 0 || exchange.getRequestMethod().equals("HEAD")) ? -1 : contentLength);
222222
if (contentLength > 0) {
223223
exchange.getResponseBody().write(body.toByteArray());
224224
}

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCredentials.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static boolean isChromiumHeadedLike() {
3333
@Test
3434
@DisabledIf(value="isChromiumHeadedLike", disabledReason="fail")
3535
void shouldFailWithoutCredentials() {
36-
System.out.println("channel2 " + getBrowserChannelFromEnv());
3736
server.setAuth("/empty.html", "user", "pass");
3837
Response response = page.navigate(server.EMPTY_PAGE);
3938
assertEquals(401, response.status());

playwright/src/test/java/com/microsoft/playwright/TestGlobalFetch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void shouldReturnBodyForFailingRequests() {
337337
for (String method : new String[] {"head", "put", "trace"}) {
338338
server.setRoute("/empty.html", exchange -> {
339339
exchange.getResponseHeaders().set("Content-type", "text/plain");
340-
exchange.sendResponseHeaders(404, 10);
340+
exchange.sendResponseHeaders(404, exchange.getRequestMethod().equals("HEAD") ? -1 : 10);
341341
try (Writer writer = new OutputStreamWriter(exchange.getResponseBody())) {
342342
writer.write("Not found.");
343343
}

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<junit.version>5.12.0</junit.version>
4949
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5050
<websocket.version>1.6.0</websocket.version>
51+
<slf4j.version>2.0.17</slf4j.version>
5152
<opentest4j.version>1.3.0</opentest4j.version>
5253
</properties>
5354

@@ -91,6 +92,12 @@
9192
<version>${websocket.version}</version>
9293
<scope>test</scope>
9394
</dependency>
95+
<dependency>
96+
<groupId>org.slf4j</groupId>
97+
<artifactId>slf4j-simple</artifactId>
98+
<version>${slf4j.version}</version>
99+
<scope>test</scope>
100+
</dependency>
94101
<dependency>
95102
<groupId>org.junit.jupiter</groupId>
96103
<artifactId>junit-jupiter-api</artifactId>

0 commit comments

Comments
 (0)