package io.vertx.vertx_mlv; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import io.vertx.core.Vertx; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; @RunWith(VertxUnitRunner.class) public class HelloWorldTest { private final static int PORT = 8081; private final static String HOST = "localhost"; private final static String PATH_HELLO = "/hello/"; private final static String PATH_BYEBYE = "/byebye/"; private Vertx vertx; @Before public void before(final TestContext context) { vertx = Vertx.vertx(); vertx.deployVerticle(HelloWorld.class.getName(), context.asyncAssertSuccess()); } @After public void after(final TestContext context) { vertx.close(context.asyncAssertSuccess()); } @Test public void testHelloWorld(final TestContext context) { final Async async = context.async(); vertx.createHttpClient() .getNow(PORT, HOST, PATH_HELLO, response -> { response.handler(body -> { context.assertTrue(body.toString().contains("Hello World")); async.complete(); }); }); } @Test public void testByeByeWorld(final TestContext context) { final Async async = context.async(); vertx.createHttpClient() .getNow(PORT, HOST, PATH_BYEBYE, response -> { response.handler(body -> { context.assertTrue(body.toString().contains("Bye Bye World")); async.complete(); }); }); } }