本文整理匯總了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();
};
}