@Override public void run() { try { TestCase.create("my_test", TestContext::async).awaitSuccess(); } catch (IllegalStateException e) { ise.set(true); } finally { latch.countDown(); } } };
/** * Create a test case. * @param name the test case name * @param testCase the test case * @return the created test case */ public static io.vertx.rxjava.ext.unit.TestCase create(String name, Handler<io.vertx.rxjava.ext.unit.TestContext> testCase) { io.vertx.rxjava.ext.unit.TestCase ret = io.vertx.rxjava.ext.unit.TestCase.newInstance(io.vertx.ext.unit.TestCase.create(name, new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { testCase.handle(io.vertx.rxjava.ext.unit.TestContext.newInstance(event)); } })); return ret; }
/** * Create a test case. * @param name the test case name * @param testCase the test case * @return the created test case */ public static io.vertx.rxjava.ext.unit.TestCase create(String name, Handler<io.vertx.rxjava.ext.unit.TestContext> testCase) { io.vertx.rxjava.ext.unit.TestCase ret = io.vertx.rxjava.ext.unit.TestCase.newInstance(io.vertx.ext.unit.TestCase.create(name, new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { testCase.handle(io.vertx.rxjava.ext.unit.TestContext.newInstance(event)); } })); return ret; }
@org.junit.Test public void testAssert() { TestCase.create("my_test", context -> { }).awaitSuccess(); }
@org.junit.Test public void testAssertTimeout() { try { TestCase.create("my_test", TestContext::async).awaitSuccess(300, TimeUnit.MILLISECONDS); fail(); } catch (IllegalStateException ignore) { } }
@org.junit.Test public void testAssertRuntimeException() { RuntimeException failure = new RuntimeException(); try { TestCase.create("my_test", context -> { throw failure; }).awaitSuccess(); fail(); } catch (RuntimeException err) { assertSame(failure, err); } }
@org.junit.Test public void testAssertFailure() { try { TestCase.create("my_test", context -> context.fail("the_failure")).awaitSuccess(); fail(); } catch (AssertionError err) { assertEquals("the_failure", err.getMessage()); } }