/** * Run the testsuite with the default options.<p/> * * When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this * context's event loop is used for running the test suite. Otherwise it is executed in the current thread.<p/> * * The returned {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback. * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run() { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run()); return ret; }
/** * Run the testsuite with the default options.<p/> * * When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this * context's event loop is used for running the test suite. Otherwise it is executed in the current thread.<p/> * * The returned {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback. * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run() { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run()); return ret; }
/** * Run the testsuite with the default options and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument. The returned * {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback.<p/> * @param vertx the vertx instance * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate())); return ret; }
/** * Run the testsuite with the default options and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument. The returned * {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback.<p/> * @param vertx the vertx instance * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate())); return ret; }
/** * Run the testsuite with the specified <code>options</code> and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument when * {@link io.vertx.ext.unit.TestOptions} is not set to <code>false</code>. The returned * {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback. * @param vertx the vertx instance * @param options the test options * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run(io.vertx.rxjava.core.Vertx vertx, TestOptions options) { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate(), options)); return ret; }
/** * Run the testsuite with the specified <code>options</code> and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument when * {@link io.vertx.ext.unit.TestOptions} is not set to <code>false</code>. The returned * {@link io.vertx.rxjava.ext.unit.Completion} object can be used to get a completion callback. * @param vertx the vertx instance * @param options the test options * @return the related test completion */ public io.vertx.rxjava.ext.unit.TestCompletion run(io.vertx.rxjava.core.Vertx vertx, TestOptions options) { io.vertx.rxjava.ext.unit.TestCompletion ret = io.vertx.rxjava.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate(), options)); return ret; }
public static io.vertx.ext.unit.TestCompletion run(io.vertx.ext.unit.TestSuite j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.run(vertx, options != null ? new io.vertx.ext.unit.TestOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } }
public static io.vertx.ext.unit.TestCompletion run(io.vertx.ext.unit.TestSuite j_receiver, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.run(options != null ? new io.vertx.ext.unit.TestOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.unit.TestCompletion run(io.vertx.ext.unit.TestSuite j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) {
@org.junit.Test public void testReportWithDefaultOptions() { String s = testSystemOut(() -> { suite.run(new TestOptions().addReporter(new ReportOptions())); }); assertTrue(s.length() > 0); }
private void testSucceeded(Consumer<Completion> consumer) { TestSuite suite = TestSuite.create("my_suite").test("my_test", context -> { }); Completion completion = suite.run(Vertx.vertx()); consumer.accept(completion); assertTrue(completion.isCompleted()); assertTrue(completion.isSucceeded()); assertFalse(completion.isFailed()); }
private void testAwaitFailed(Consumer<Completion> consumer) { TestSuite suite = TestSuite.create("my_suite").test("my_test", context -> { context.fail(); }); Completion completion = suite.run(Vertx.vertx()); consumer.accept(completion); assertTrue(completion.isCompleted()); assertFalse(completion.isSucceeded()); assertTrue(completion.isFailed()); }
@org.junit.Test public void testReportSucceededToCompletionHandler() { TestSuite suite = TestSuite.create("my_suite").test("first_test", context -> {}); suite.run(new TestOptions()).handler(ar -> { assertTrue(ar.succeeded()); testComplete(); }); await(); }
@org.junit.Test public void testReportToEventBus() { MessageConsumer<JsonObject> consumer = vertx.eventBus().<JsonObject>consumer("the_address"); consumer.handler(msg -> { if (msg.body().getString("type").equals(EventBusCollector.EVENT_TEST_SUITE_END)) { consumer.unregister(); testComplete(); } }); consumer.completionHandler(ar -> { assertTrue(ar.succeeded()); suite.run(vertx, new TestOptions().addReporter(new ReportOptions().setTo("bus:the_address"))); }); await(); }
private void testTimeout(Consumer<Completion> consumer) { TestSuite suite = TestSuite.create("my_suite").test("my_test", context -> { context.async(); }); Completion completion = suite.run(Vertx.vertx()); try { consumer.accept(completion); fail(); } catch (Exception e) { assertTrue(e instanceof TimeoutException); assertFalse(completion.isCompleted()); assertFalse(completion.isSucceeded()); assertFalse(completion.isFailed()); } }
@org.junit.Test public void testReportToConsole() { String s = testSystemOut(() -> { Reporter<?> reporter = Reporter.reporter(vertx, new ReportOptions().setTo("console")); assertTrue(reporter instanceof SimpleFormatter); suite.run(new TestOptions().addReporter(new ReportOptions().setTo("console"))); }); assertTrue(s.length() > 0); }
@org.junit.Test public void testReportToLog() { String s = testLog("mylogger", () -> { Reporter<?> reporter = Reporter.reporter(vertx, new ReportOptions().setTo("log:mylogger")); assertTrue(reporter instanceof SimpleFormatter); suite.run(new TestOptions().addReporter(new ReportOptions().setTo("log:mylogger"))); }); assertTrue(s.length() > 0); }
private void connect(DoubleHandler<ILdapClientConnection, TestContext> handler) { TestCompletion completion = TestSuite.create("").test("", context -> { Async async = context.async(); ldapClientComponent.connect(config, connectionResult -> { context.assertTrue(connectionResult.isSuccess()); connection = connectionResult.getResult(); handler.handle(connection, context); async.complete(); }); async.awaitSuccess(); }).run(); completion.awaitSuccess(); }
@Test public void shouldConnectSuccessfully() throws InterruptedException { config.setBindDn("uid=admin,ou=system"); config.setBindPassword("secret"); TestCompletion completion = TestSuite.create("").test("", context -> { Async async = context.async(); ldapClientComponent.connect(config, connectionResult -> { context.assertTrue(connectionResult.isSuccess()); connection = connectionResult.getResult(); async.complete(); }); async.awaitSuccess(); }).run(); completion.awaitSuccess(); }
@Test public void shouldErrorWhenFieldsInvalid() throws InterruptedException { config.setBindDn("x"); config.setBindPassword("x"); TestCompletion completion = TestSuite.create("").test("", context -> { Async async = context.async(); ldapClientComponent.bind(config, result -> { context.assertTrue(result.isSuccess()); context.assertTrue(result.getResult().getResultCode().equals(LdapResultCode.INVALID_DN_SYNTAX)); context.assertTrue(result.getResult().getMessage().equals("Incorrect DN given : x (0x78 ) is invalid")); async.complete(); }); async.awaitSuccess(); }).run(); completion.awaitSuccess(); }
@Test public void shouldFailWhenPasswordInvalid() throws InterruptedException { config.setBindDn("uid=admin,ou=system"); config.setBindPassword("miso-soup"); TestCompletion completion = TestSuite.create("").test("", context -> { Async async = context.async(); ldapClientComponent.bind(config, result -> { context.assertTrue(result.isSuccess()); context.assertTrue(result.getResult().getResultCode().equals(LdapResultCode.INVALID_CREDENTIALS)); async.complete(); }); async.awaitSuccess(); }).run(); completion.awaitSuccess(); }