io.vertx.ext.unit.Async.await()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(329)

本文整理了Java中io.vertx.ext.unit.Async.await()方法的一些代码示例,展示了Async.await()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Async.await()方法的具体详情如下:
包路径:io.vertx.ext.unit.Async
类名称:Async
方法名:await

Async.await介绍

暂无

代码示例

代码示例来源:origin: io.vertx/vertx-micrometer-metrics

void await() {
  startAsync.await(3000);
 }
}

代码示例来源:origin: stackoverflow.com

@Test
public void testDelegate(TestContext context) {
  EventBus eventBus = vertx.eventBus();
  Event event = new Event("id", "description")
  Async async = context.async();
  eventBus.publish("event.channel", Json.encode(event) ,done ->async.complete());

  async.await()

  //Mockito.verify
  verify(delegate).invokeMethod(anyString(), anyString());
}

代码示例来源:origin: de.braintags/vertx-pojo-mapper-common-test

public static void dropTable(TestContext context, String tableName) {
 Async async = context.async();
 ErrorObject<Void> err = new ErrorObject<Void>(null);
 TestHelper.getDatastoreContainer(context).dropTable(tableName, result -> {
  if (result.failed()) {
   err.setThrowable(result.cause());
  }
  async.complete();
 });
 async.await();
 if (err.isError())
  throw err.getRuntimeException();
}

代码示例来源:origin: io.vertx/vertx-web-templ-pebble

@Test
 public void acceptLanguageHeaderShouldBeUsedWhenSet(TestContext should) {
  final Async test = should.async();

  Locale.setDefault(Locale.US);
  final TemplateEngine engine = PebbleTemplateEngine.create(vertx);

  engine.render(new JsonObject().put("lang", "de-DE"), "src/test/filesystemtemplates/test-pebble-template-i18n.peb", render2 -> {
   should.assertTrue(render2.succeeded());
   should.assertEquals("Hallo", render2.result().toString());
   test.complete();
  });
  test.await();
 }
}

代码示例来源:origin: io.vertx/vertx-web-templ-pebble

@Test
public void noLocaleShouldUseDefaultLocale(TestContext should) {
 final Async test = should.async();
 Locale.setDefault(Locale.US);
 final TemplateEngine engine = PebbleTemplateEngine.create(vertx);
 engine.render(new JsonObject(), "src/test/filesystemtemplates/test-pebble-template-i18n.peb", render2 -> {
  should.assertTrue(render2.succeeded());
  should.assertEquals("Hi", render2.result().toString());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-mvel

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = MVELTemplateEngine.create(vertx);
 engine.render(new JsonObject(), "nosuchtemplate.templ", render -> {
  should.assertFalse(render.succeeded());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-rocker

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = RockerTemplateEngine.create();
 final JsonObject context = new JsonObject();
 engine.render(context, "nosuchtemplate.rocker.html", render -> {
  should.assertFalse(render.succeeded());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-freemarker

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = FreeMarkerTemplateEngine.create(vertx);
 engine.render(new JsonObject(), "not-found", render -> {
  should.assertTrue(render.failed());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-pebble

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = PebbleTemplateEngine.create(vertx);
 final JsonObject context = new JsonObject();
 engine.render(context, "non-existing", render -> {
  should.assertFalse(render.succeeded());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-thymeleaf

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = ThymeleafTemplateEngine.create(vertx);
 final JsonObject context = new JsonObject();
 engine.render(context, "nosuchtemplate.html", render -> {
  should.assertFalse(render.succeeded());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: io.vertx/vertx-web-templ-jade

@Test
public void testNoSuchTemplate(TestContext should) {
 final Async test = should.async();
 TemplateEngine engine = JadeTemplateEngine.create(vertx).setExtension("made");
 final JsonObject context = new JsonObject();
 engine.render(context, "somedir/foo", render -> {
  should.assertFalse(render.succeeded());
  test.complete();
 });
 test.await();
}

代码示例来源:origin: eclipse/hono

protected static void assertNotRegistered(
    final CompleteCredentialsService svc,
    final String tenant,
    final String authId,
    final String type,
    final TestContext ctx) {
  final Async registration = ctx.async();
  svc.get(tenant, type, authId, ctx.asyncAssertSuccess(t -> {
    assertThat(t.getStatus(), is(HttpURLConnection.HTTP_NOT_FOUND));
    registration.complete();
  }));
  registration.await();
}

代码示例来源:origin: eclipse/hono

protected static void assertRegistered(
    final CompleteCredentialsService svc,
    final String tenant,
    final String authId,
    final String type,
    final TestContext ctx) {
  final Async registration = ctx.async();
  svc.get(tenant, type, authId, ctx.asyncAssertSuccess(t -> {
    assertThat(t.getStatus(), is(HttpURLConnection.HTTP_OK));
    registration.complete();
  }));
  registration.await();
}

代码示例来源:origin: de.braintags/netrelay

@Test
public void testProcessor(TestContext context) throws Exception {
 try {
  Async async = context.async();
  DemoProcessor.async = async;
  context.assertEquals(DEMO_PROPERTY, demoProperty, "init does not seem to be handled");
  async.await(WAITTIME);
  context.assertTrue(eventProcessed, "the event wasn't processed");
 } catch (Exception e) {
  context.fail(e);
 }
}

代码示例来源:origin: de.braintags/NetRelayController

@Test
public void testProcessor(TestContext context) throws Exception {
 try {
  Async async = context.async();
  DemoMailProcessor.async = async;
  context.assertEquals(DEMO_PROPERTY, demoProperty, "init does not seem to be handled");
  async.await();
  context.assertTrue(eventProcessed, "the event wasn't processed");
 } catch (Exception e) {
  context.fail(e);
 }
}

代码示例来源:origin: io.vertx/vertx-micrometer-metrics

private void wsRequest(HttpClient httpClient, TestContext ctx) {
  Async async = ctx.async();
  httpClient.websocket(9195, "127.0.0.1", "", ws -> {
   ws.handler(event -> {
    async.complete();
    ws.close();
   });
   ws.writeTextMessage(CLIENT_REQUEST);
  }, ctx::fail);
  async.await();
 }
}

代码示例来源:origin: reactiverse/reactive-pg-client

@Test
public void testRunStandalone(TestContext ctx) {
 Async async = ctx.async();
 PgPool pool = PgClient.pool(new PgPoolOptions(options));
 try {
  pool.query("SELECT id, randomnumber from WORLD", ctx.asyncAssertSuccess(v -> {
   async.complete();
  }));
  async.await(4000);
 } finally {
  pool.close();
 }
}

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void clientSslTrustAllTest(TestContext context) {
 MqttClientOptions clientOptions = new MqttClientOptions()
  .setSsl(true)
  .setTrustAll(true);
 MqttClient client = MqttClient.create(vertx, clientOptions);
 client.exceptionHandler(t -> context.assertTrue(false));
 this.context = context;
 Async async = context.async();
 client.connect(MQTT_SERVER_TLS_PORT, MQTT_SERVER_HOST, s -> client.disconnect(d -> async.countDown()));
 async.await();
}

代码示例来源:origin: vert-x3/vertx-mqtt

@Test
public void clientSslTrustAllTest(TestContext context) {
 MqttClientOptions clientOptions = new MqttClientOptions()
  .setSsl(true)
  .setTrustAll(true);
 MqttClient client = MqttClient.create(vertx, clientOptions);
 client.exceptionHandler(t -> context.assertTrue(false));
 this.context = context;
 Async async = context.async();
 client.connect(MQTT_SERVER_TLS_PORT, MQTT_SERVER_HOST, s -> client.disconnect(d -> async.countDown()));
 async.await();
}

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void clientSslClientTruststoreTest(TestContext context) {
 this.context = context;
 JksOptions jksOptions = new JksOptions().setPath("/tls/client-truststore.jks");
 MqttClientOptions clientOptions = new MqttClientOptions()
  .setSsl(true)
  .setTrustStoreOptions(jksOptions);
 MqttClient client = MqttClient.create(vertx, clientOptions);
 client.exceptionHandler(t -> context.assertTrue(false));
 Async async = context.async();
 client.connect(MQTT_SERVER_TLS_PORT, MQTT_SERVER_HOST, s -> client.disconnect(d -> async.countDown()));
 async.await();
}

相关文章