當前位置: 首頁>>代碼示例>>Java>>正文


Java Async.complete方法代碼示例

本文整理匯總了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();
	}
 
開發者ID:zandero,項目名稱:rest.vertx,代碼行數:36,代碼來源:RouteRegistrationTest.java

示例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();
}
 
開發者ID:valuelogic,項目名稱:vertx-web-problem,代碼行數:16,代碼來源:NotFoundHandlerTest.java

示例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();
	};
}
 
開發者ID:GreenfieldTech,項目名稱:irked,代碼行數:7,代碼來源:TestConsumes.java

示例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();
    };
}
 
開發者ID:millross,項目名稱:pac4j-async,代碼行數:7,代碼來源:AsyncSingleProfileSaveTest.java


注:本文中的io.vertx.ext.unit.Async.complete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。