/** * Count down the async. */ public void countDown() { delegate.countDown(); }
/** * Count down the async. */ public void countDown() { delegate.countDown(); }
@Override public void afterStartingVertx(Vertx vertx) { ExternalConfigurationTest.this.vertx = vertx; startAsync.countDown(); }
@Override public void handle(AsyncResult<SQLConnection> sqlConnectionAsyncResult) { testContext.assertFalse(sqlConnectionAsyncResult.succeeded()); async.countDown(); } };
@Override public void handle(AsyncResult<SQLConnection> sqlConnectionAsyncResult) { testContext.assertFalse(sqlConnectionAsyncResult.succeeded()); async.countDown(); } };
@Override public void handle(AsyncResult<SQLConnection> sqlConnectionAsyncResult) { testContext.assertFalse(sqlConnectionAsyncResult.succeeded()); async.countDown(); } };
@Override public void start() throws Exception { NetServer netServer = vertx.createNetServer(nsOptions); netServer.connectHandler(netSocket -> netSocket.handler(buffer -> { log.debug("================= Received content on " + port + ":" + async.count() + " =================== \n" + buffer.toString()); async.countDown(); })).listen(port); } }
@Override public void start() throws Exception { vertx.eventBus().consumer("test", m -> { client.get(host, uri).send(ar -> { testContext.assertTrue(ar.succeeded()); async.countDown(); }); }); } };
@Override public void start() { NetServer netServer = vertx.createNetServer(nsOptions); netServer.connectHandler(netSocket -> netSocket.handler(buffer -> { LOG.debug("Received content on port {} ({}) : {}", port, async.count(), buffer.toString()); async.countDown(); })).listen(port); } }
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(); }
private void getConfigAndCheck(TestContext tc, Async async) { getJsonConfiguration(vertx, store, tc.asyncAssertSuccess(res -> { if (res.isEmpty()) { // Retry as the publication may not have been dispatched yet. vertx.setTimer(10, tid -> getConfigAndCheck(tc, async)); } else { ConfigChecker.check(res); async.countDown(); } })); } }
private void getConfigAndCheck(TestContext tc, Async async) { getJsonConfiguration(vertx, store, tc.asyncAssertSuccess(res -> { if (res.isEmpty()) { // Retry as the publication may not have been dispatched yet. vertx.setTimer(10, tid -> getConfigAndCheck(tc, async)); } else { ConfigChecker.check(res); async.countDown(); } })); } }
@Override public void start(Future<Void> fut) { KafkaConsumer<String, String> consumer = KafkaConsumer.create(vertx, config); deployed = true; consumer.handler(record -> { if (deployed) { deployed = false; vertx.undeploy(context.deploymentID(), ctx.asyncAssertSuccess(v2 -> async.countDown())); } }); consumer.assign(new TopicPartition(topicName, 0), fut); } }, ctx.asyncAssertSuccess(v -> produceLatch.complete()));
@Test public void testBasicConsumeWithErrorHandler(TestContext ctx) throws Exception { int count = 3; Set<String> messages = createMessages(count); String q = setupQueue(ctx, messages, "application/json"); Async latch = ctx.async(count); vertx.eventBus().consumer("my.address", msg -> ctx.fail("Getting message with malformed json")); Handler<Throwable> errorHandler = throwable -> latch.countDown(); client.basicConsume(q, "my.address", true, ctx.asyncAssertSuccess(), errorHandler); }
@Test public void testBasicConsumeWithErrorHandler(TestContext ctx) throws Exception { int count = 3; Set<String> messages = createMessages(count); String q = setupQueue(ctx, messages, "application/json"); Async latch = ctx.async(count); vertx.eventBus().consumer("my.address", msg -> ctx.fail("Getting message with malformed json")); Handler<Throwable> errorHandler = throwable -> latch.countDown(); client.basicConsume(q, "my.address", true, ctx.asyncAssertSuccess(), errorHandler); }
@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(); }
@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(); }
@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(); }
@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(); }
@Test public void sessionInfoBlocking(TestContext tc) { ctx.writeClient().createSession(tc.asyncAssertSuccess(id -> { ctx.readClient().infoSession(id, tc.asyncAssertSuccess(s1 -> { Async async = tc.async(); ctx.readClient().infoSessionWithOptions(id, new BlockingQueryOptions().setIndex(s1.getIndex()), h -> async.countDown()); vertx.setTimer(1000, l -> { assertEquals(async.count(), 1); ctx.writeClient().destroySession(id, tc.asyncAssertSuccess()); }); })); })); }