@Before public void before(TestContext context) { vertx = Vertx.vertx(); Async async = context.async(); vertx.deployVerticle(TestVerticle.class.getName(), context.asyncAssertSuccess(event -> async.complete())); }
@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(); })); }
@After public void after(TestContext context) { vertx.close(context.asyncAssertSuccess()); }
@Override public void complete(String value, boolean terminal) { context.assertTrue(terminal); context.assertEquals("oo", value); async.complete(); } });
@Override public void complete(String value, boolean terminal) { context.assertFalse(terminal); context.assertEquals("a", value); async.complete(); } });
@Override public void accept(ExecutionResult result) { context.assertFalse(true); async.complete(); }}); } catch (Exception e ) {
/** * Assert the specified <code>condition</code> is <code>true</code>. If the condition is <code>false</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertTrue(boolean condition) { delegate.assertTrue(condition); return this; }
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @param message the failure message * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertNull(Object expected, String message) { delegate.assertNull(expected, message); return this; }
@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(); }
/** * @return the current count */ public int count() { int ret = delegate.count(); return ret; }
/** * Get some data from the context. * @param key the key of the data * @return the data */ public <T> T get(String key) { T ret = (T) delegate.get(key); return ret; }
@Test public void testAwaitSucceeded() { testSucceeded(completion -> completion.await()); testSucceeded(completion -> completion.await(2000)); }
@Test public void testAwaitSuccessSucceeded() { testSucceeded(completion -> completion.awaitSuccess()); testSucceeded(completion -> completion.awaitSuccess(2000)); }
/** * @return true if this completion is completed */ public boolean isCompleted() { boolean ret = delegate.isCompleted(); return ret; }
/** * Cause the current thread to wait until this completion completes and succeeds with a configurable timeout.<p/> * * If completion times out or the current thread is interrupted or the suite fails, an exception will be thrown. * @param timeoutMillis the timeout in milliseconds */ public void awaitSuccess(long timeoutMillis) { delegate.awaitSuccess(timeoutMillis); }
/** * Completion handler to receive a completion signal when this completions completes. * @param completionHandler the completion handler */ public void handler(Handler<AsyncResult<Void>> completionHandler) { delegate.handler(completionHandler); }
@Override public void complete(String value, boolean terminal) { context.assertTrue(terminal); context.assertEquals("", value); async.complete(); } });
@Override public void complete(String value, boolean terminal) { context.assertFalse(terminal); context.assertEquals("completed_by_foo", value); async.complete(); } });
/** * Assert the specified <code>condition</code> is <code>true</code>. If the condition is <code>false</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @param message the failure message * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertTrue(boolean condition, String message) { delegate.assertTrue(condition, message); return this; }
/** * Creates and returns a new async handler, the returned handler controls the completion of the test.<p/> * * When the returned handler is called back with a succeeded result it completes the async operation.<p/> * * When the returned handler is called back with a failed result it fails the test with the cause of the failure.<p/> * @return the async result handler */ public <T> Handler<AsyncResult<T>> asyncAssertSuccess() { Handler<AsyncResult<T>> ret = delegate.asyncAssertSuccess(); return ret; }