Fix test to wait for server startup
@@ -196,12 +196,14 @@ public class StaticHandlerTest extends WebTestBase {
public void testNoHttp2Push() throws Exception {
stat.setWebRoot("webroot/somedir3");
router.route().handler(stat);
- HttpServer http2Server = vertx.createHttpServer(new HttpServerOptions()
+
+ vertx.createHttpServer(new HttpServerOptions()
.setUseAlpn(true)
.setSsl(true)
- .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")));
- http2Server.requestHandler(router).listen(8443);
-
+ .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")))
+ .requestHandler(router).listen(8443)
+ .onFailure(this::fail)
+ .onSuccess(server -> {
HttpClientOptions options = new HttpClientOptions()
.setSsl(true)
.setUseAlpn(true)
@@ -220,6 +222,8 @@ public class StaticHandlerTest extends WebTestBase {
testComplete();
}));
}));
+ });
+
await();
}
@@ -231,19 +235,22 @@ public class StaticHandlerTest extends WebTestBase {
stat.setHttp2PushMapping(mappings)
.setWebRoot("webroot/somedir3");
router.route().handler(stat);
- HttpServer http2Server = vertx.createHttpServer(new HttpServerOptions()
+
+ CountDownLatch latch = new CountDownLatch(2);
+
+ vertx.createHttpServer(new HttpServerOptions()
.setUseAlpn(true)
.setSsl(true)
- .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")));
- http2Server.requestHandler(router).listen(8443);
-
+ .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")))
+ .requestHandler(router).listen(8443)
+ .onFailure(this::fail)
+ .onSuccess(server -> {
HttpClientOptions options = new HttpClientOptions()
.setSsl(true)
.setUseAlpn(true)
.setProtocolVersion(HttpVersion.HTTP_2)
.setPemTrustOptions(new PemTrustOptions().addCertPath("tls/server-cert.pem"));
HttpClient client = vertx.createHttpClient(options);
- CountDownLatch latch = new CountDownLatch(2);
client.request(HttpMethod.GET, 8443, "localhost", "/testLinkPreload.html")
.onComplete(onSuccess(req -> {
req.pushHandler(pushedReq -> pushedReq.response(onSuccess(pushedResp -> {
@@ -257,6 +264,8 @@ public class StaticHandlerTest extends WebTestBase {
resp.bodyHandler(this::assertNotNull);
}));
}));
+ });
+
latch.await();
}
