本文整理汇总了Java中io.vertx.ext.unit.Async.complete方法的典型用法代码示例。如果您正苦于以下问题:Java Async.complete方法的具体用法?Java Async.complete怎么用?Java Async.complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.unit.Async
的用法示例。
在下文中一共展示了Async.complete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerTwoRoutesTest
import io.vertx.ext.unit.Async; //导入方法依赖的package包/类
@Test
public void registerTwoRoutesTest(TestContext context) throws IOException {
TestRest testRest = new TestRest();
TestPostRest testPostRest = new TestPostRest();
Router router = RestRouter.register(vertx, testRest, testPostRest);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(PORT);
final Async async = context.async();
// check if both are active
Dummy json = new Dummy("test", "me");
StringEntity input = new StringEntity(JsonUtils.toJson(json));
input.setContentType("application/json");
/* HttpPost request = (HttpPost) HttpUtils.post(ROOT_PATH + "/test/json/post", null, null, input, null);
HttpResponse response = HttpUtils.execute(request);
assertEquals(200, response.getStatusLine().getStatusCode());
String output = HttpUtils.getContentAsString(response);
assertEquals("{\"name\":\"Received-test\",\"value\":\"Received-me\"}", output);
*/
// 2nd REST
HttpPost request = (HttpPost) HttpUtils.post(ROOT_PATH + "/post/json", null, null, input, null);
HttpResponse response = HttpUtils.execute(request);
assertEquals(200, response.getStatusLine().getStatusCode());
String output = HttpUtils.getContentAsString(response);
assertEquals("{\"name\":\"Received-test\",\"value\":\"Received-me\"}", output);
async.complete();
}
示例2: shouldReturnNotFoundForBadMethod
import io.vertx.ext.unit.Async; //导入方法依赖的package包/类
@Test
public void shouldReturnNotFoundForBadMethod(TestContext context) {
final Async async = context.async();
given()
.port(ExampleVerticle.HTTP_PORT)
.when()
.contentType("application/json")
.post("/test-get")
.then()
.assertThat()
.contentType("application/problem+json")
.body("title", equalTo("Not Found"))
.body("status", equalTo(404));
async.complete();
}
示例3: verifyMissHandler
import io.vertx.ext.unit.Async; //导入方法依赖的package包/类
private Handler<HttpClientResponse> verifyMissHandler(TestContext context, Async f) {
return r -> {
context.assertEquals(404, r.statusCode(), "Should have received an error for incorrect type");
f.complete();
};
}
示例4: validateProfiles
import io.vertx.ext.unit.Async; //导入方法依赖的package包/类
private Consumer<List<CommonProfile>> validateProfiles(final Matcher<List<CommonProfile>> expectedProfiles, final Async async) {
return l -> {
assertThat(l, is(expectedProfiles));
async.complete();
};
}