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

x33g5p2x  于11个月前 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(22)

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

Async.awaitSuccess介绍

暂无

代码示例

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

static void close(TestContext ctx, Consumer<Handler<AsyncResult<Void>>> producer) {
 if (producer != null) {
  Async closeAsync = ctx.async();
  producer.accept(v -> {
   closeAsync.complete();
  });
  closeAsync.awaitSuccess(10000);
 }
}

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

@Test
public void testAwaitWhenAlreadyCompleted(TestContext context) {
 try {
  test0.add("before");
  Async async = context.async();
  test0.add("complete");
  async.complete();
  async.awaitSuccess();
  test0.add("after");
 } finally {
  done.countDown();
 }
}

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

static void close(TestContext ctx, Consumer<Handler<AsyncResult<Void>>> producer) {
 if (producer != null) {
  Async closeAsync = ctx.async();
  producer.accept(v -> {
   closeAsync.complete();
  });
  closeAsync.awaitSuccess(10000);
 }
}

代码示例来源:origin: vietj/vertx-http-proxy

protected void startHttpServer(TestContext ctx, HttpServerOptions options, Handler<HttpServerRequest> handler) {
 HttpServer proxyServer = vertx.createHttpServer(options);
 proxyServer.requestHandler(handler);
 Async async1 = ctx.async();
 proxyServer.listen(ctx.asyncAssertSuccess(p -> async1.complete()));
 async1.awaitSuccess();
}

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

private void prepareServer(TestContext context, Consumer<HttpServerRequest> reqHandler) {
 Async async = context.async();
 server.requestHandler(req -> {
  try {
   reqHandler.accept(req);
  } finally {
   req.response().end();
  }
 });
 server.listen(context.asyncAssertSuccess(s -> async.complete()));
 async.awaitSuccess(15000);
}

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

private Properties setupConsumeWithHeaders(TestContext ctx, int numMessages, String topicName) {
 Async batch = ctx.async();
 AtomicInteger index = new AtomicInteger();
 kafkaCluster.useTo().produceStrings(numMessages, batch::complete, () ->
  new ProducerRecord<>(topicName, 0, "key-" + index.get(), "value-" + index.get(),
   Collections.singletonList(new RecordHeader("header_key" + index.get(), ("header_value" + index.getAndIncrement()).getBytes()))));
 batch.awaitSuccess(20000);
 Properties config = kafkaCluster.useTo().getConsumerProperties(topicName, topicName, OffsetResetStrategy.EARLIEST);
 config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
 config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
 return config;
}

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

private Properties setupConsumeWithHeaders(TestContext ctx, int numMessages, String topicName) {
 Async batch = ctx.async();
 AtomicInteger index = new AtomicInteger();
 kafkaCluster.useTo().produceStrings(numMessages, batch::complete, () ->
  new ProducerRecord<>(topicName, 0, "key-" + index.get(), "value-" + index.get(),
   Collections.singletonList(new RecordHeader("header_key" + index.get(), ("header_value" + index.getAndIncrement()).getBytes()))));
 batch.awaitSuccess(20000);
 Properties config = kafkaCluster.useTo().getConsumerProperties(topicName, topicName, OffsetResetStrategy.EARLIEST);
 config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
 config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
 return config;
}

代码示例来源:origin: vietj/vertx-http-proxy

protected SocketAddress startHttpBackend(TestContext ctx, HttpServerOptions options, Handler<HttpServerRequest> handler) {
 HttpServer backendServer = vertx.createHttpServer(options);
 backendServer.requestHandler(handler);
 Async async = ctx.async();
 backendServer.listen(ctx.asyncAssertSuccess(s -> async.complete()));
 async.awaitSuccess();
 return new SocketAddressImpl(options.getPort(), "localhost");
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void websocketServiceCloseConnectionOnUnrecoverableError(final TestContext context) {
 final Async async = context.async();
 final byte[] bigMessage = new byte[HttpServerOptions.DEFAULT_MAX_WEBSOCKET_MESSAGE_SIZE + 1];
 Arrays.fill(bigMessage, (byte) 1);
 httpClient.websocket(
   "/",
   webSocket -> {
    webSocket.write(Buffer.buffer(bigMessage));
    webSocket.closeHandler(v -> async.complete());
   });
 async.awaitSuccess(VERTX_AWAIT_TIMEOUT_MILLIS);
}

代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-audit

@Test
public void testUDP(TestContext testContext) throws Exception {
  auditContext.setAuditRepositoryTransport("UDP");
  int count = 10;
  Async async = testContext.async(count + 1);
  deploy(testContext, createUDPServer(LOCALHOST, port, async));
  while (async.count() > count) {
    Thread.sleep(10);
  }
  for (int i = 0; i < count; i++) sendAudit();
  async.awaitSuccess(WAIT_TIME);
}

代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-audit

@Test
public void testOneWayTLS(TestContext testContext) throws Exception {
  initTLSSystemProperties(null);
  Async async = testContext.async();
  deploy(testContext, createTCPServerOneWayTLS(port,
      SERVER_KEY_STORE,
      SERVER_KEY_STORE_PASS,
      async));
  sendAudit();
  async.awaitSuccess(WAIT_TIME);
}

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

@Test(timeout = 20000)
 public void testCloseBridgeThatWasntStarted(TestContext context) throws Exception {
  stopBroker();

  Async async = context.async();

  AmqpBridge bridge = AmqpBridge.create(vertx);
  bridge.close(shutdownRes -> {
   LOG.trace("Shutdown complete");
   context.assertTrue(shutdownRes.succeeded());

   async.complete();
  });

  async.awaitSuccess();
 }
}

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

private void runClientRequests(TestContext ctx) {
 Async clientsFinished = ctx.async(concurrentClients);
 for (int i = 0; i < concurrentClients; i++) {
  ForkJoinPool.commonPool().execute(() -> {
   NetClient client = vertx.createNetClient();
   request(client, ctx);
   clientsFinished.countDown();
  });
 }
 clientsFinished.awaitSuccess();
}

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

@Test
public void testCloseShellServer(TestContext context) throws Exception {
 testClose(context, conn -> {
  Async async = context.async();
  shellServer.close(context.asyncAssertSuccess(v -> async.complete()));
  async.awaitSuccess(20000);
 });
}

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

@AfterClass
public static void shutdown(TestContext context) throws Exception {
 LOGGER.debug("performing shutdown");
 if (vertx != null) {
  Async async = context.async();
  vertx.close(ar -> {
   vertx = null;
   async.complete();
  });
  async.awaitSuccess();
  LOGGER.debug("finished shutdown");
 }
}

代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-audit

@Test
public void testUDPVertx(TestContext testContext) throws Exception {
  auditContext.setAuditTransmissionProtocol(new VertxUDPSyslogSenderImpl(vertx));
  int count = 10;
  Async async = testContext.async(count);
  deploy(testContext, createUDPServer(LOCALHOST, port, async));
  for (int i = 0; i < count; i++) sendAudit();
  async.awaitSuccess(WAIT_TIME);
}

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

private void startTelnet(TestContext context, TelnetTermOptions options, Handler<Term> termHandler) {
 server = TermServer.createTelnetTermServer(vertx, options.setPort(4000));
 server.termHandler(termHandler);
 Async async = context.async();
 server.listen(context.asyncAssertSuccess(v -> async.complete()));
 async.awaitSuccess(5000);
}

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

private void startShellServer(TestContext context, long sessionTimeout, long reaperInterval) {
 if (shellServer != null) {
  throw new IllegalStateException("Already started");
 }
 Async latch = context.async();
 shellServer = ShellServer.create(vertx, new ShellServerOptions().setSessionTimeout(sessionTimeout).setReaperInterval(reaperInterval)).
   registerTermServer(termServer).
   registerCommandResolver(registry).
   listen(context.asyncAssertSuccess(v -> latch.complete()));
 latch.awaitSuccess(20000);
}

代码示例来源:origin: vietj/vertx-http-proxy

protected SocketAddress startNetBackend(TestContext ctx, int port, Handler<NetSocket> handler) {
 NetServer backendServer = vertx.createNetServer(new HttpServerOptions().setPort(port).setHost("localhost"));
 backendServer.connectHandler(handler);
 Async async = ctx.async();
 backendServer.listen(ctx.asyncAssertSuccess(s -> async.complete()));
 async.awaitSuccess();
 return new SocketAddressImpl(port, "localhost");
}

代码示例来源:origin: apiman/apiman

private void connect(DoubleHandler<ILdapClientConnection, TestContext> handler) {
  TestCompletion completion = TestSuite.create("").test("",  context -> {
    Async async = context.async();
    ldapClientComponent.connect(config, connectionResult -> {
      context.assertTrue(connectionResult.isSuccess());
      connection = connectionResult.getResult();
      handler.handle(connection, context);
      async.complete();
    });
    async.awaitSuccess();
  }).run();
  completion.awaitSuccess();
}

相关文章