Search in sources :

Example 26 with DEFAULT_HTTP_HOST

use of io.vertx.core.http.HttpTestBase.DEFAULT_HTTP_HOST in project vert.x by eclipse.

the class JsonTest method testHttp.

@Test
public void testHttp() {
    Vertx vertx = Vertx.vertx();
    try {
        vertx.createHttpServer().requestHandler(req -> {
            req.response().end("hello");
        }).listen(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, onSuccess(s -> {
            HttpClient client = vertx.createHttpClient();
            client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/").compose(req -> req.send().compose(HttpClientResponse::body)).onComplete(onSuccess(body -> {
                assertEquals("hello", body.toString());
                testComplete();
            }));
        }));
        await();
    } finally {
        vertx.close();
    }
}
Also used : HttpClientRequest(io.vertx.core.http.HttpClientRequest) HttpClientResponse(io.vertx.core.http.HttpClientResponse) JsonArray(io.vertx.core.json.JsonArray) EventBus(io.vertx.core.eventbus.EventBus) DEFAULT_HTTP_HOST(io.vertx.core.http.HttpTestBase.DEFAULT_HTTP_HOST) HttpMethod(io.vertx.core.http.HttpMethod) Vertx(io.vertx.core.Vertx) DEFAULT_HTTP_PORT(io.vertx.core.http.HttpTestBase.DEFAULT_HTTP_PORT) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test) VertxTestBase(io.vertx.test.core.VertxTestBase) HttpClient(io.vertx.core.http.HttpClient) HttpClient(io.vertx.core.http.HttpClient) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Aggregations

Vertx (io.vertx.core.Vertx)26 DEFAULT_HTTP_HOST (io.vertx.core.http.HttpTestBase.DEFAULT_HTTP_HOST)26 DEFAULT_HTTP_PORT (io.vertx.core.http.HttpTestBase.DEFAULT_HTTP_PORT)26 VertxTestBase (io.vertx.test.core.VertxTestBase)26 Test (org.junit.Test)26 Buffer (io.vertx.core.buffer.Buffer)24 NetSocket (io.vertx.core.net.NetSocket)24 ReadStream (io.vertx.core.streams.ReadStream)24 HttpHeaderNames (io.netty.handler.codec.http.HttpHeaderNames)23 CloseWebSocketFrame (io.netty.handler.codec.http.websocketx.CloseWebSocketFrame)23 WebSocket13FrameDecoder (io.netty.handler.codec.http.websocketx.WebSocket13FrameDecoder)23 WebSocket13FrameEncoder (io.netty.handler.codec.http.websocketx.WebSocket13FrameEncoder)23 ReferenceCountUtil (io.netty.util.ReferenceCountUtil)23 PlatformDependent (io.netty.util.internal.PlatformDependent)23 AbstractVerticle (io.vertx.core.AbstractVerticle)23 AsyncResult (io.vertx.core.AsyncResult)23 Context (io.vertx.core.Context)23 DeploymentOptions (io.vertx.core.DeploymentOptions)23 Future (io.vertx.core.Future)23 Handler (io.vertx.core.Handler)23