Refine search
@Test public void test(TestContext testContext) { HttpClient client = vertx.createHttpClient(new HttpClientOptions() .setConnectTimeout(10000)); Async async = testContext.async(); client.getNow(PORT, "127.0.0.1", "/test", testContext.asyncAssertSuccess(httpClientResponse -> { testContext.assertEquals(HttpURLConnection.HTTP_NO_CONTENT, httpClientResponse.statusCode()); async.complete(); })); }
@Test public void testLoadingFromEnvironmentVariables(TestContext context) { Async async = context.async(); getJsonConfiguration(vertx, store, ar -> { assertThat(ar.succeeded()).isTrue(); assertThat(ar.result().getString(KEY_1)).isEqualTo(VAL_1); assertThat(ar.result().getString(KEY_2)).isEqualTo(VAL_2); async.complete(); }); } }
@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 testReleaseConnectionOnSetRollback(TestContext ctx) { Async async = ctx.async(); connector.accept(ctx.asyncAssertSuccess(conn -> { conn.query("SELECT whatever from DOES_NOT_EXIST", ctx.asyncAssertFailure(result -> { // Try acquire a connection pool.getConnection(ctx.asyncAssertSuccess(v2 -> { async.complete(); })); })); })); }
@Test public void testLoadingFromAJsonArrayFile(TestContext context) { Async async = context.async(); store = factory.create(vertx, new JsonObject().put("path", "src/test/resources/file/array.json")); getJsonConfiguration(vertx, store, ar -> { assertThat(ar.failed()).isTrue(); async.complete(); }); }
@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); } }
@Test public void testConnectInvalidPassword(TestContext ctx) { Async async = ctx.async(); options.setPassword("incorrect"); connector.accept(ctx.asyncAssertFailure(conn -> { ctx.assertEquals("password authentication failed for user \"postgres\"", conn.getMessage()); async.complete(); })); }
@Test public void testLoadingFromEnvWithNullKeySet(TestContext context) { Async async = context.async(); store = factory.create(vertx, new JsonObject().put("keys", (JsonArray) null)); getJsonConfiguration(vertx, store, ar -> { assertThat(ar.succeeded()).isTrue(); assertThat(ar.result().getString("PATH")).isNotNull(); async.complete(); }); }
@Test public void testConnectInvalidDatabase(TestContext ctx) { Async async = ctx.async(); options.setDatabase("blah_db"); connector.accept(ctx.asyncAssertFailure(conn -> { ctx.assertEquals("database \"blah_db\" does not exist", conn.getMessage()); async.complete(); })); }
@Test public void testEmptyBatch(TestContext ctx) { Async async = ctx.async(); PgClient.connect(vertx, options, ctx.asyncAssertSuccess(conn -> { List<Tuple> batch = new ArrayList<>(); conn.preparedBatch("INSERT INTO Test (id, val) VALUES ($1, $2)", batch, ctx.asyncAssertSuccess(result -> { async.complete(); })); })); }
@Test public void testConnectNonSSLServer(TestContext ctx) { Async async = ctx.async(); options.setSslMode(SslMode.REQUIRE).setTrustAll(true); connector.accept(ctx.asyncAssertFailure(err -> { ctx.assertEquals("Postgres Server does not handle SSL connection", err.getMessage()); async.complete(); })); }
@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 testInsert(TestContext ctx) { Async async = ctx.async(); connector.accept(ctx.asyncAssertSuccess(client -> { deleteFromTestTable(ctx, client, () -> { client.query("INSERT INTO Test (id, val) VALUES (1, 'Whatever')", ctx.asyncAssertSuccess(r1 -> { ctx.assertEquals(1, r1.rowCount()); async.complete(); })); }); })); }
@Test public void testOverloading(TestContext tc) { System.setProperty("key", "new-value"); retriever = ConfigRetriever.create(vertx, addStores(new ConfigRetrieverOptions())); Async async = tc.async(); retriever.getConfig(ar -> { assertThat(ar.result().getString("key")).isEqualToIgnoringCase("new-value"); async.complete(); }); }
@Test public void testReversedOverloading(TestContext tc) { System.setProperty("key", "new-value"); retriever = ConfigRetriever.create(vertx, addReversedStores(new ConfigRetrieverOptions())); Async async = tc.async(); retriever.getConfig(ar -> { assertThat(ar.result().getString("key")).isEqualToIgnoringCase("value"); async.complete(); }); }