parent
d3590de13c
commit
626db733b9
|
@ -8,10 +8,8 @@ public class SimpleServerVerticle extends AbstractVerticle {
|
|||
@Override
|
||||
public void start(Future<Void> future) {
|
||||
vertx.createHttpServer()
|
||||
.requestHandler(request -> {
|
||||
request.response()
|
||||
.end("Welcome to Vert.x Intro");
|
||||
})
|
||||
.requestHandler(
|
||||
r -> r.response().end("Welcome to Vert.x Intro"))
|
||||
.listen(config().getInteger("http.port", 8080), result -> {
|
||||
if (result.succeeded()) {
|
||||
future.complete();
|
||||
|
|
|
@ -13,7 +13,7 @@ import io.vertx.ext.unit.TestContext;
|
|||
import io.vertx.ext.unit.junit.VertxUnitRunner;
|
||||
|
||||
@RunWith(VertxUnitRunner.class)
|
||||
public class RestServiceVerticleTest {
|
||||
public class RestServiceVerticleIntegrationTest {
|
||||
|
||||
private Vertx vertx;
|
||||
|
|
@ -1,27 +1,23 @@
|
|||
package com.baeldung;
|
||||
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.ext.unit.Async;
|
||||
import io.vertx.ext.unit.TestContext;
|
||||
import io.vertx.ext.unit.junit.VertxUnitRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import io.vertx.core.DeploymentOptions;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.unit.Async;
|
||||
import io.vertx.ext.unit.TestContext;
|
||||
import io.vertx.ext.unit.junit.VertxUnitRunner;
|
||||
|
||||
@RunWith(VertxUnitRunner.class)
|
||||
public class SimpleServerVerticleTest {
|
||||
public class SimpleServerVerticleIntegrationTest {
|
||||
private Vertx vertx;
|
||||
|
||||
@Before
|
||||
public void setup(TestContext testContext) {
|
||||
vertx = Vertx.vertx();
|
||||
|
||||
vertx.deployVerticle(SimpleServerVerticle.class.getName(),
|
||||
testContext.asyncAssertSuccess());
|
||||
vertx.deployVerticle(SimpleServerVerticle.class.getName(), testContext.asyncAssertSuccess());
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -33,14 +29,15 @@ public class SimpleServerVerticleTest {
|
|||
public void whenReceivedResponse_thenSuccess(TestContext testContext) {
|
||||
final Async async = testContext.async();
|
||||
|
||||
vertx.createHttpClient()
|
||||
.getNow(8080, "localhost", "/", response -> {
|
||||
response.handler(responseBody -> {
|
||||
testContext.assertTrue(responseBody.toString()
|
||||
vertx
|
||||
.createHttpClient()
|
||||
.getNow(8080, "localhost", "/",
|
||||
response -> response.handler(responseBody -> {
|
||||
testContext.assertTrue(responseBody
|
||||
.toString()
|
||||
.contains("Welcome"));
|
||||
async.complete();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue