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