public void setUp() throws Exception { super.setUp(); disableThreadChecks(); executor = Executors.newFixedThreadPool(10); }
protected void tearDown() throws Exception { tearingDown = true; afterAsyncTestBase(); }
protected <T> Handler<AsyncResult<T>> onFailure(Consumer<Throwable> consumer) { return result -> { assertFalse(result.succeeded()); consumer.accept(result.cause()); }; }
protected void fail(Throwable cause) { checkThread(); handleThrowable(cause); }
public static void assertWaitUntil(BooleanSupplier supplier) { assertWaitUntil(supplier, 10000); }
protected void testComplete() { if (tearingDown) { throw new IllegalStateException("testComplete called after test has completed"); } checkThread(); if (testCompleteCalled) { throw new IllegalStateException("testComplete() already called"); } testCompleteCalled = true; latch.countDown(); }
protected <T> Handler<AsyncResult<T>> onSuccess(Consumer<T> consumer) { return result -> { if (result.failed()) { result.cause().printStackTrace(); fail(result.cause().getMessage()); } else { consumer.accept(result.result()); } }; }
protected void close(Vertx vertx) throws Exception { CountDownLatch latch = new CountDownLatch(1); vertx.close(ar -> { latch.countDown(); }); awaitLatch(latch); } }
protected void awaitLatch(CountDownLatch latch) throws InterruptedException { assertTrue(latch.await(10, TimeUnit.SECONDS)); }
protected void await() { await(2, TimeUnit.MINUTES); }
protected void assertFalse(String message, boolean condition) { checkThread(); try { Assert.assertFalse(message, condition); } catch (AssertionError e) { handleThrowable(e); } }
protected void assertWaitUntil(BooleanSupplier supplier, String reason) { AsyncTestBase.assertWaitUntil(supplier, 20000, reason); }
protected synchronized void complete() { if (tearingDown) { throw new IllegalStateException("testComplete called after test has completed"); } checkThread(); if (testCompleteCalled) { throw new IllegalStateException("already complete"); } latch.countDown(); if (latch.getCount() == 0) { testCompleteCalled = true; } }
protected <T> Handler<AsyncResult<T>> onSuccess(Consumer<T> consumer) { return result -> { if (result.failed()) { result.cause().printStackTrace(); fail(result.cause().getMessage()); } else { consumer.accept(result.result()); } }; }
protected void close(Vertx vertx) throws Exception { CountDownLatch latch = new CountDownLatch(1); vertx.close(ar -> { latch.countDown(); }); awaitLatch(latch); } }
protected void awaitLatch(CountDownLatch latch) throws InterruptedException { assertTrue(latch.await(10, TimeUnit.SECONDS)); }
protected void await() { await(2, TimeUnit.MINUTES); }
protected void assertArrayEquals(Object[] expecteds, Object[] actuals) { checkThread(); try { Assert.assertArrayEquals(expecteds, actuals); } catch (AssertionError e) { handleThrowable(e); } }
@Before public void before() throws Exception { setUp(); }
protected void assertWaitUntil(BooleanSupplier supplier, long timeout) { AsyncTestBase.assertWaitUntil(supplier, timeout); }