void await() { startAsync.await(3000); } }
@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()); }
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(); }
@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(); } }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
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(); }
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(); }
@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); } }
@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); } }
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(); } }
@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(); } }
@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(); }