@Test
public void serverIsStarted(TestContext context) {
final Async async = context.async(); // <-- create the Async instance
vertx.createHttpClient().getnow(8081, "localhost", "/inexistent", response -> {
context.assertEquals(200, response.statusCode());
async.complete(); // <-- signal this test can now terminate
});
}
// });
}
我假设您正在从Vert升级。x3到Vert。x 4 ?
在绿色。x 4,HttpClient
API已经重做。你应该这样做:
client.request(HttpMethod.GET, "/inexistent", ar1 -> {
if (ar1.succeeded()) {
HttpClientRequest request = ar1.result();
request.send(ar2 -> {
if (ar2.succeeded()) {
HttpClientResponse response = ar2.result();
context.assertEquals(200, response.statusCode());
async.complete(); // <-- signal this test can now terminate
}
});
}
});