[java] Fixing distributed CDP test to send proper headers that pass requirements introduced in commit
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.testing.drivers.Browser;
-import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
@@ -108,7 +107,8 @@ public void ensureBasicFunctionality() throws MalformedURLException, Interrupted
HttpClient client = HttpClient.Factory.createDefault().createClient(new URL("http://localhost:" + routerPort));
new FluentWait<>(client).withTimeout(ofSeconds(10)).until(c -> {
- HttpResponse res = c.execute(new HttpRequest(GET, "/status"));
+ HttpResponse res = c.execute(new HttpRequest(GET, "/status")
+ .addHeader("Content-Type", "application/json; charset=utf-8"));
if (!res.isSuccessful()) {
return false;
}
@@ -151,17 +151,7 @@ public void ensureBasicFunctionality() throws MalformedURLException, Interrupted
}
private void waitUntilUp(int port) {
- try {
- HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
- HttpClient client = clientFactory.createClient(new URL("http://localhost:" + port));
-
- new FluentWait<>(client)
- .ignoring(UncheckedIOException.class)
- .withTimeout(ofSeconds(15))
- .until(http -> http.execute(new HttpRequest(GET, "/status")).isSuccessful());
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
+ PortProber.waitForPortUp(port, 15, SECONDS);
}
private String getBrowserShortName() {
