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(); })); }
@Override public void complete(List<String> candidates) { context.assertEquals(Collections.emptyList(), candidates); 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 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 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(); }); }
@Override public void complete(List<String> candidates) { context.assertEquals(Collections.emptyList(), candidates); 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 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(); }); }
@Override public void complete(List<String> candidates) { context.assertEquals(Arrays.asList("bar", "baz", "err", "foo"), candidates.stream().sorted().collect(Collectors.toList())); 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(); })); }
@Override public void complete(String value, boolean terminal) { context.assertFalse(terminal); context.assertEquals("a", value); async.complete(); } });
@Test public void testBusSendJsonObject(TestContext context) { Async consumerAsync = context.async(); assertBusSend(context, "bus-send --type JSON_OBJECT the_address '{\"foo\":\"foo_value\",\"bar\":3}'", msg -> { context.assertEquals(new JsonObject().put("foo", "foo_value").put("bar", 3), msg.body()); consumerAsync.complete(); }); }
@Test public void testExceptionHandler(TestContext ctx) throws Exception { Async async = ctx.async(); Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); Date invalidValue = new Date(); KafkaProducer.create(Vertx.vertx(), props). exceptionHandler(exception -> async.complete()). write(KafkaProducerRecord.create("topic", "key", invalidValue)); }
@Override public void onComplete() { ctx.assertEquals(Collections.emptySet(), ids); // Check the pool is back in the pool by the commit pool.rxGetConnection().subscribe(conn -> { conn.close(); async.complete(); }, ctx::fail); } });
@Test public void testBusSendBase64(TestContext context) { Async consumerAsync = context.async(); assertBusSend(context, "bus-send --type BASE64 the_address " + new String(Base64.getEncoder().encode(new byte[]{0,31,-1})), msg -> { context.assertEquals(Buffer.buffer(new byte[]{0,31,-1}), msg.body()); consumerAsync.complete(); }); }
@Test public void testBusSendHex(TestContext context) { Async consumerAsync = context.async(); assertBusSend(context, "bus-send --type HEX the_address 001FFF", msg -> { context.assertEquals(Buffer.buffer(new byte[]{0,31,-1}), msg.body()); consumerAsync.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(); }