@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
});
}
// });
}
问问题
50 次
1 回答
2
我假设您正在从 Vert.x 3 升级到 Vert.x 4?
在 Vert.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
}
});
}
});
于 2021-07-29T14:29:01.260 回答