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 authInfoWithoutUsernameShouldFailAuthentication(final TestContext context) { JsonObject authInfo = new JsonObject().put("password", "foo"); tomlAuth.authenticate( authInfo, context.asyncAssertFailure( th -> context.assertEquals("No username provided", th.getMessage()))); }
@Test public void testFindByEnumContains(TestContext context) { createDemoRecords(context); IQuery<EnumRecord> query = getDataStore(context).createQuery(EnumRecord.class); query.field("enumEnum").contains("IN"); List<EnumRecord> list = (List<EnumRecord>) findAll(context, query); list.forEach(sm -> logger.info(sm.enumEnum)); context.assertEquals(1, list.size(), "incorrect result"); }
@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 createDefaultSession(TestContext tc) { ctx.writeClient().createSession(tc.asyncAssertSuccess(id -> { ctx.writeClient().infoSession(id, tc.asyncAssertSuccess(session -> { tc.assertEquals(id, session.getId()); tc.assertEquals(ctx.nodeName(), session.getNode()); ctx.writeClient().destroySession(id, tc.asyncAssertSuccess()); })); })); }
@Test public void testDuplicateRegistration(TestContext context) { CommandRegistry registry = CommandRegistry.getShared(vertx); Command a = CommandBuilder.command("a").build(vertx); Command b = CommandBuilder.command("b").build(vertx); registry.registerCommand(a, context.asyncAssertSuccess(reg -> { registry.registerCommands(Arrays.asList(a, b), context.asyncAssertFailure(err -> { context.assertEquals(1, registry.commands().size()); context.assertNotNull(registry.getCommand("a")); })); })); }
private void assertReceiveMessages(TestContext ctx, String topicName, int numMessages) { Async done = ctx.async(); AtomicInteger seq = new AtomicInteger(); kafkaCluster.useTo().consumeStrings(() -> seq.get() < numMessages, done::complete, Collections.singleton(topicName), record -> { int count = seq.getAndIncrement(); ctx.assertEquals("key-" + count, record.key()); ctx.assertEquals("value-" + count, record.value()); ctx.assertEquals("header_value-" + count, new String(record.headers().headers("header_key").iterator().next().value())); }); }
@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 authInfoWithoutPasswordShouldFailAuthentication(final TestContext context) { JsonObject authInfo = new JsonObject().put("username", "foo"); tomlAuth.authenticate( authInfo, context.asyncAssertFailure( th -> context.assertEquals("No password provided", th.getMessage()))); }
@Test public void testOutBinaryTrue(TestContext context) throws Exception { startTelnet(context, new TelnetTermOptions().setOutBinary(true), term -> { term.write("\u20AC"); }); client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false)); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); context.assertEquals(226, in.read()); context.assertEquals(130, in.read()); context.assertEquals(172, in.read()); }
@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); } }
@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 authInfoWithAbsentUserShouldFailAuthentication(final TestContext context) { JsonObject authInfo = new JsonObject().put("username", "foo").put("password", "foo"); tomlAuth.authenticate( authInfo, context.asyncAssertFailure(th -> context.assertEquals("User not found", th.getMessage()))); }
@Test public void mailTestMissingNL(TestContext testContext) { this.testContext=testContext; MailMessage message = exampleMessage(); // the protocol adds a newline at the end if there isn't one message.setText("."); testSuccess(mailClientLogin(), message, () -> { final MimeMessage mimeMessage = wiser.getMessages().get(0).getMimeMessage(); testContext.assertEquals(".\n", TestUtils.conv2nl(TestUtils.inputStreamToString(mimeMessage.getInputStream()))); }); }
@Override public void complete(List<String> candidates) { context.assertEquals(Collections.emptyList(), candidates); async.complete(); } });
@Test public void testBusSendReplyTimeout(TestContext context) { Async consumerAsync = context.async(); String result = assertBusSend(context, "bus-send --reply --timeout 50 the_address the_message", msg -> { context.assertEquals("the_message", msg.body()); consumerAsync.complete(); }); context.assertEquals("Error: Timed out after waiting 50(ms) for a reply. address: __vertx.reply.1, repliedAddress: the_address\n", result); }
@Test public void passwordMismatchShouldFailAuthentication(final TestContext context) { JsonObject authInfo = new JsonObject().put("username", "userA").put("password", "foo"); tomlAuth.authenticate( authInfo, context.asyncAssertFailure( th -> context.assertEquals("Invalid password", th.getMessage()))); }
@Override public void complete(List<String> candidates) { context.assertEquals(Arrays.asList("bar", "baz"), candidates.stream().sorted().collect(Collectors.toList())); async.complete(); } });