From bdf2b8eafd90b19790a50501e45378acd14b4469 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 19 Mar 2020 18:57:05 -0700 Subject: [PATCH] Fix file formatting (#256) --- .../DatabaseClientDecoratorTest.groovy | 17 -- .../src/test/groovy/RangeQueryTest.groovy | 2 +- .../ExporterAdaptersTest.groovy | 2 +- .../src/test/groovy/UrlConnectionTest.groovy | 2 +- .../log4j-2.0/src/test/resources/log4j2.xml | 4 +- .../src/test/groovy/OkHttp3Test.groovy | 38 ++--- .../test/groovy/server/PlayServerTest.groovy | 148 ++++++++--------- .../TracingClientResponseSubscriber.java | 5 +- .../groovy/client/VertxHttpClientTest.groovy | 56 +++---- .../VertxRxCircuitBreakerWebClientTest.groovy | 84 +++++----- .../groovy/client/VertxRxWebClientTest.groovy | 54 +++---- .../groovy/server/VertxHttpServerTest.groovy | 150 +++++++++--------- 12 files changed, 271 insertions(+), 291 deletions(-) diff --git a/agent-bootstrap/src/test/groovy/io/opentelemetry/auto/bootstrap/instrumentation/decorator/DatabaseClientDecoratorTest.groovy b/agent-bootstrap/src/test/groovy/io/opentelemetry/auto/bootstrap/instrumentation/decorator/DatabaseClientDecoratorTest.groovy index 4f80b7853d..87c1df4228 100644 --- a/agent-bootstrap/src/test/groovy/io/opentelemetry/auto/bootstrap/instrumentation/decorator/DatabaseClientDecoratorTest.groovy +++ b/agent-bootstrap/src/test/groovy/io/opentelemetry/auto/bootstrap/instrumentation/decorator/DatabaseClientDecoratorTest.groovy @@ -18,23 +18,6 @@ package io.opentelemetry.auto.bootstrap.instrumentation.decorator import io.opentelemetry.auto.config.Config import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags - -/* - * Copyright 2020, OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import io.opentelemetry.trace.Span import static io.opentelemetry.auto.test.utils.ConfigUtils.withConfigOverride diff --git a/buildSrc/src/test/groovy/RangeQueryTest.groovy b/buildSrc/src/test/groovy/RangeQueryTest.groovy index 3f6d81d3e6..c103b30dd7 100644 --- a/buildSrc/src/test/groovy/RangeQueryTest.groovy +++ b/buildSrc/src/test/groovy/RangeQueryTest.groovy @@ -18,7 +18,7 @@ class RangeQueryTest extends Specification { final VersionRangeRequest rangeRequest = new VersionRangeRequest() rangeRequest.setRepositories(MuzzlePlugin.MUZZLE_REPOS) rangeRequest.setArtifact(directiveArtifact) - + // This call makes an actual network request, which may fail if network access is limited. final VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest) diff --git a/exporter-adapters/src/test/groovy/io/opentelemetry/auto/exporteradapters/ExporterAdaptersTest.groovy b/exporter-adapters/src/test/groovy/io/opentelemetry/auto/exporteradapters/ExporterAdaptersTest.groovy index 9df46e22b9..d1a0e39389 100644 --- a/exporter-adapters/src/test/groovy/io/opentelemetry/auto/exporteradapters/ExporterAdaptersTest.groovy +++ b/exporter-adapters/src/test/groovy/io/opentelemetry/auto/exporteradapters/ExporterAdaptersTest.groovy @@ -40,7 +40,7 @@ class ExporterAdaptersTest extends Specification { then: file != null - + where: exporter << [loggingExporterJar, jaegerExporterJar] } diff --git a/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy b/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy index c099215e40..66fc4e7d0c 100644 --- a/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy +++ b/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy @@ -14,8 +14,8 @@ * limitations under the License. */ import io.opentelemetry.auto.bootstrap.AgentClassLoader -import io.opentelemetry.auto.config.Config import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecorator +import io.opentelemetry.auto.config.Config import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.SpanTypes import io.opentelemetry.auto.instrumentation.api.Tags diff --git a/instrumentation/log4j/log4j-2.0/src/test/resources/log4j2.xml b/instrumentation/log4j/log4j-2.0/src/test/resources/log4j2.xml index 297a6752dd..261fc7f444 100644 --- a/instrumentation/log4j/log4j-2.0/src/test/resources/log4j2.xml +++ b/instrumentation/log4j/log4j-2.0/src/test/resources/log4j2.xml @@ -3,12 +3,12 @@ - + - + diff --git a/instrumentation/okhttp-3.0/src/test/groovy/OkHttp3Test.groovy b/instrumentation/okhttp-3.0/src/test/groovy/OkHttp3Test.groovy index c9922c7380..ec178596a0 100644 --- a/instrumentation/okhttp-3.0/src/test/groovy/OkHttp3Test.groovy +++ b/instrumentation/okhttp-3.0/src/test/groovy/OkHttp3Test.groovy @@ -24,26 +24,26 @@ import okhttp3.internal.http.HttpMethod class OkHttp3Test extends HttpClientTest { - def client = new OkHttpClient() + def client = new OkHttpClient() - @Override - int doRequest(String method, URI uri, Map headers, Closure callback) { - def body = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), "") : null - def request = new Request.Builder() - .url(uri.toURL()) - .method(method, body) - .headers(Headers.of(headers)).build() - def response = client.newCall(request).execute() - callback?.call() - return response.code() - } + @Override + int doRequest(String method, URI uri, Map headers, Closure callback) { + def body = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), "") : null + def request = new Request.Builder() + .url(uri.toURL()) + .method(method, body) + .headers(Headers.of(headers)).build() + def response = client.newCall(request).execute() + callback?.call() + return response.code() + } - @Override - String component() { - return OkHttpClientDecorator.DECORATE.getComponentName() - } + @Override + String component() { + return OkHttpClientDecorator.DECORATE.getComponentName() + } - boolean testRedirects() { - false - } + boolean testRedirects() { + false + } } diff --git a/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy b/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy index 4a1b56812b..03e7f1d129 100644 --- a/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy +++ b/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy @@ -37,80 +37,80 @@ import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.SUCC import static io.opentelemetry.trace.Span.Kind.INTERNAL class PlayServerTest extends HttpServerTest { - @Override - Server startServer(int port) { - def router = - new RoutingDsl() - .GET(SUCCESS.getPath()).routeTo({ - controller(SUCCESS) { - Results.status(SUCCESS.getStatus(), SUCCESS.getBody()) - } - } as Supplier) - .GET(QUERY_PARAM.getPath()).routeTo({ - controller(QUERY_PARAM) { - Results.status(QUERY_PARAM.getStatus(), QUERY_PARAM.getBody()) - } - } as Supplier) - .GET(REDIRECT.getPath()).routeTo({ - controller(REDIRECT) { - Results.found(REDIRECT.getBody()) - } - } as Supplier) - .GET(ERROR.getPath()).routeTo({ - controller(ERROR) { - Results.status(ERROR.getStatus(), ERROR.getBody()) - } - } as Supplier) - .GET(EXCEPTION.getPath()).routeTo({ - controller(EXCEPTION) { - throw new Exception(EXCEPTION.getBody()) - } - } as Supplier) - - return Server.forRouter(router.build(), port) - } - - @Override - void stopServer(Server server) { - server.stop() - } - - @Override - String component() { - return NettyHttpServerDecorator.DECORATE.getComponentName() - } - - @Override - boolean hasHandlerSpan() { - true - } - - boolean testExceptionBody() { - // I can't figure out how to set a proper exception handler to customize the response body. - false - } - - @Override - void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) { - trace.span(index) { - operationName "play.request" - spanKind INTERNAL - errored endpoint == ERROR || endpoint == EXCEPTION - childOf((SpanData) parent) - tags { - "$MoreTags.SPAN_TYPE" SpanTypes.HTTP_SERVER - "$Tags.COMPONENT" PlayHttpServerDecorator.DECORATE.getComponentName() - "$MoreTags.NET_PEER_IP" { it == null || it == "127.0.0.1" } // Optional - "$Tags.HTTP_URL" String - "$Tags.HTTP_METHOD" String - "$Tags.HTTP_STATUS" Long - if (endpoint == EXCEPTION) { - errorTags(Exception, EXCEPTION.body) - } - if (endpoint.query) { - "$MoreTags.HTTP_QUERY" endpoint.query - } - } + @Override + Server startServer(int port) { + def router = + new RoutingDsl() + .GET(SUCCESS.getPath()).routeTo({ + controller(SUCCESS) { + Results.status(SUCCESS.getStatus(), SUCCESS.getBody()) } + } as Supplier) + .GET(QUERY_PARAM.getPath()).routeTo({ + controller(QUERY_PARAM) { + Results.status(QUERY_PARAM.getStatus(), QUERY_PARAM.getBody()) + } + } as Supplier) + .GET(REDIRECT.getPath()).routeTo({ + controller(REDIRECT) { + Results.found(REDIRECT.getBody()) + } + } as Supplier) + .GET(ERROR.getPath()).routeTo({ + controller(ERROR) { + Results.status(ERROR.getStatus(), ERROR.getBody()) + } + } as Supplier) + .GET(EXCEPTION.getPath()).routeTo({ + controller(EXCEPTION) { + throw new Exception(EXCEPTION.getBody()) + } + } as Supplier) + + return Server.forRouter(router.build(), port) + } + + @Override + void stopServer(Server server) { + server.stop() + } + + @Override + String component() { + return NettyHttpServerDecorator.DECORATE.getComponentName() + } + + @Override + boolean hasHandlerSpan() { + true + } + + boolean testExceptionBody() { + // I can't figure out how to set a proper exception handler to customize the response body. + false + } + + @Override + void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) { + trace.span(index) { + operationName "play.request" + spanKind INTERNAL + errored endpoint == ERROR || endpoint == EXCEPTION + childOf((SpanData) parent) + tags { + "$MoreTags.SPAN_TYPE" SpanTypes.HTTP_SERVER + "$Tags.COMPONENT" PlayHttpServerDecorator.DECORATE.getComponentName() + "$MoreTags.NET_PEER_IP" { it == null || it == "127.0.0.1" } // Optional + "$Tags.HTTP_URL" String + "$Tags.HTTP_METHOD" String + "$Tags.HTTP_STATUS" Long + if (endpoint == EXCEPTION) { + errorTags(Exception, EXCEPTION.body) + } + if (endpoint.query) { + "$MoreTags.HTTP_QUERY" endpoint.query + } + } } + } } diff --git a/instrumentation/spring-webflux-5.0/src/main/java8/io/opentelemetry/auto/instrumentation/springwebflux/client/TracingClientResponseSubscriber.java b/instrumentation/spring-webflux-5.0/src/main/java8/io/opentelemetry/auto/instrumentation/springwebflux/client/TracingClientResponseSubscriber.java index edcb17fb05..dee46b3dad 100644 --- a/instrumentation/spring-webflux-5.0/src/main/java8/io/opentelemetry/auto/instrumentation/springwebflux/client/TracingClientResponseSubscriber.java +++ b/instrumentation/spring-webflux-5.0/src/main/java8/io/opentelemetry/auto/instrumentation/springwebflux/client/TracingClientResponseSubscriber.java @@ -46,10 +46,7 @@ public class TracingClientResponseSubscriber implements CoreSubscriber(span); - this.parentSpan = - parentSpan == null - ? DefaultSpan.getInvalid() - : parentSpan; + this.parentSpan = parentSpan == null ? DefaultSpan.getInvalid() : parentSpan; } @Override diff --git a/instrumentation/vertx-testing/src/test/groovy/client/VertxHttpClientTest.groovy b/instrumentation/vertx-testing/src/test/groovy/client/VertxHttpClientTest.groovy index 73b0db5551..fe4bc79b3f 100644 --- a/instrumentation/vertx-testing/src/test/groovy/client/VertxHttpClientTest.groovy +++ b/instrumentation/vertx-testing/src/test/groovy/client/VertxHttpClientTest.groovy @@ -30,37 +30,37 @@ import java.util.concurrent.CompletableFuture @Timeout(10) class VertxHttpClientTest extends HttpClientTest { - @Shared - Vertx vertx = Vertx.vertx(new VertxOptions()) - @Shared - HttpClient httpClient = vertx.createHttpClient() + @Shared + Vertx vertx = Vertx.vertx(new VertxOptions()) + @Shared + HttpClient httpClient = vertx.createHttpClient() - @Override - int doRequest(String method, URI uri, Map headers, Closure callback) { - CompletableFuture future = new CompletableFuture<>() - def request = httpClient.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } - request.handler { response -> - callback?.call() - future.complete(response) - } - request.end() - - return future.get().statusCode() + @Override + int doRequest(String method, URI uri, Map headers, Closure callback) { + CompletableFuture future = new CompletableFuture<>() + def request = httpClient.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") + headers.each { request.putHeader(it.key, it.value) } + request.handler { response -> + callback?.call() + future.complete(response) } + request.end() - @Override - String component() { - return NettyHttpClientDecorator.DECORATE.getComponentName() - } + return future.get().statusCode() + } - @Override - boolean testRedirects() { - false - } + @Override + String component() { + return NettyHttpClientDecorator.DECORATE.getComponentName() + } - @Override - boolean testConnectionFailure() { - false - } + @Override + boolean testRedirects() { + false + } + + @Override + boolean testConnectionFailure() { + false + } } diff --git a/instrumentation/vertx-testing/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy b/instrumentation/vertx-testing/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy index e34b4279ab..7a57329024 100644 --- a/instrumentation/vertx-testing/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy +++ b/instrumentation/vertx-testing/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy @@ -31,52 +31,52 @@ import java.util.concurrent.CompletableFuture @Timeout(10) class VertxRxCircuitBreakerWebClientTest extends HttpClientTest { - @Shared - Vertx vertx = Vertx.vertx(new VertxOptions()) - @Shared - WebClient client = WebClient.create(vertx) - @Shared - CircuitBreaker breaker = CircuitBreaker.create("my-circuit-breaker", vertx, - new CircuitBreakerOptions() - .setTimeout(-1) // Disable the timeout otherwise it makes each test take this long. - ) + @Shared + Vertx vertx = Vertx.vertx(new VertxOptions()) + @Shared + WebClient client = WebClient.create(vertx) + @Shared + CircuitBreaker breaker = CircuitBreaker.create("my-circuit-breaker", vertx, + new CircuitBreakerOptions() + .setTimeout(-1) // Disable the timeout otherwise it makes each test take this long. + ) - @Override - int doRequest(String method, URI uri, Map headers, Closure callback) { - def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } + @Override + int doRequest(String method, URI uri, Map headers, Closure callback) { + def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") + headers.each { request.putHeader(it.key, it.value) } - def future = new CompletableFuture() + def future = new CompletableFuture() - breaker.executeCommand({ command -> - request.rxSend().doOnSuccess { - command.complete(it) - }.doOnError { - command.fail(it) - }.subscribe() - }, { - callback?.call() - if (it.succeeded()) { - future.complete(it.result().statusCode()) - } else { - future.completeExceptionally(it.cause()) - } - }) - return future.get() - } + breaker.executeCommand({ command -> + request.rxSend().doOnSuccess { + command.complete(it) + }.doOnError { + command.fail(it) + }.subscribe() + }, { + callback?.call() + if (it.succeeded()) { + future.complete(it.result().statusCode()) + } else { + future.completeExceptionally(it.cause()) + } + }) + return future.get() + } - @Override - String component() { - return NettyHttpClientDecorator.DECORATE.getComponentName() - } + @Override + String component() { + return NettyHttpClientDecorator.DECORATE.getComponentName() + } - @Override - boolean testRedirects() { - false - } + @Override + boolean testRedirects() { + false + } - @Override - boolean testConnectionFailure() { - false - } + @Override + boolean testConnectionFailure() { + false + } } diff --git a/instrumentation/vertx-testing/src/test/groovy/client/VertxRxWebClientTest.groovy b/instrumentation/vertx-testing/src/test/groovy/client/VertxRxWebClientTest.groovy index fd05d3d36c..d9761b93f5 100644 --- a/instrumentation/vertx-testing/src/test/groovy/client/VertxRxWebClientTest.groovy +++ b/instrumentation/vertx-testing/src/test/groovy/client/VertxRxWebClientTest.groovy @@ -27,35 +27,35 @@ import spock.lang.Timeout @Timeout(10) class VertxRxWebClientTest extends HttpClientTest { - @Shared - Vertx vertx = Vertx.vertx(new VertxOptions()) - @Shared - WebClient client = WebClient.create(vertx) + @Shared + Vertx vertx = Vertx.vertx(new VertxOptions()) + @Shared + WebClient client = WebClient.create(vertx) - @Override - int doRequest(String method, URI uri, Map headers, Closure callback) { - def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } - return request - .rxSend() - .doOnSuccess { response -> callback?.call() } - .map { it.statusCode() } - .toObservable() - .blockingFirst() - } + @Override + int doRequest(String method, URI uri, Map headers, Closure callback) { + def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") + headers.each { request.putHeader(it.key, it.value) } + return request + .rxSend() + .doOnSuccess { response -> callback?.call() } + .map { it.statusCode() } + .toObservable() + .blockingFirst() + } - @Override - String component() { - return NettyHttpClientDecorator.DECORATE.getComponentName() - } + @Override + String component() { + return NettyHttpClientDecorator.DECORATE.getComponentName() + } - @Override - boolean testRedirects() { - false - } + @Override + boolean testRedirects() { + false + } - @Override - boolean testConnectionFailure() { - false - } + @Override + boolean testConnectionFailure() { + false + } } diff --git a/instrumentation/vertx-testing/src/test/groovy/server/VertxHttpServerTest.groovy b/instrumentation/vertx-testing/src/test/groovy/server/VertxHttpServerTest.groovy index e6b325b4b3..430ae63c6e 100644 --- a/instrumentation/vertx-testing/src/test/groovy/server/VertxHttpServerTest.groovy +++ b/instrumentation/vertx-testing/src/test/groovy/server/VertxHttpServerTest.groovy @@ -34,84 +34,84 @@ import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.REDI import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.SUCCESS class VertxHttpServerTest extends HttpServerTest { - public static final String CONFIG_HTTP_SERVER_PORT = "http.server.port" + public static final String CONFIG_HTTP_SERVER_PORT = "http.server.port" + + @Override + Vertx startServer(int port) { + def server = Vertx.vertx(new VertxOptions() + // Useful for debugging: + // .setBlockedThreadCheckInterval(Integer.MAX_VALUE) + .setClusterPort(port)) + final CompletableFuture future = new CompletableFuture<>() + server.deployVerticle(verticle().name, + new DeploymentOptions() + .setConfig(new JsonObject().put(CONFIG_HTTP_SERVER_PORT, port)) + .setInstances(3)) { res -> + if (!res.succeeded()) { + throw new RuntimeException("Cannot deploy server Verticle", res.cause()) + } + future.complete(null) + } + + future.get() + return server + } + + protected Class verticle() { + return VertxWebTestServer + } + + @Override + void stopServer(Vertx server) { + server.close() + } + + @Override + String component() { + return NettyHttpServerDecorator.DECORATE.getComponentName() + } + + @Override + boolean testExceptionBody() { + false + } + + static class VertxWebTestServer extends AbstractVerticle { @Override - Vertx startServer(int port) { - def server = Vertx.vertx(new VertxOptions() - // Useful for debugging: - // .setBlockedThreadCheckInterval(Integer.MAX_VALUE) - .setClusterPort(port)) - final CompletableFuture future = new CompletableFuture<>() - server.deployVerticle(verticle().name, - new DeploymentOptions() - .setConfig(new JsonObject().put(CONFIG_HTTP_SERVER_PORT, port)) - .setInstances(3)) { res -> - if (!res.succeeded()) { - throw new RuntimeException("Cannot deploy server Verticle", res.cause()) - } - future.complete(null) + void start(final Future startFuture) { + final int port = config().getInteger(CONFIG_HTTP_SERVER_PORT) + final Router router = Router.router(vertx) + + router.route(SUCCESS.path).handler { ctx -> + controller(SUCCESS) { + ctx.response().setStatusCode(SUCCESS.status).end(SUCCESS.body) } - - future.get() - return server - } - - protected Class verticle() { - return VertxWebTestServer - } - - @Override - void stopServer(Vertx server) { - server.close() - } - - @Override - String component() { - return NettyHttpServerDecorator.DECORATE.getComponentName() - } - - @Override - boolean testExceptionBody() { - false - } - - static class VertxWebTestServer extends AbstractVerticle { - - @Override - void start(final Future startFuture) { - final int port = config().getInteger(CONFIG_HTTP_SERVER_PORT) - final Router router = Router.router(vertx) - - router.route(SUCCESS.path).handler { ctx -> - controller(SUCCESS) { - ctx.response().setStatusCode(SUCCESS.status).end(SUCCESS.body) - } - } - router.route(QUERY_PARAM.path).handler { ctx -> - controller(QUERY_PARAM) { - ctx.response().setStatusCode(QUERY_PARAM.status).end(ctx.request().query()) - } - } - router.route(REDIRECT.path).handler { ctx -> - controller(REDIRECT) { - ctx.response().setStatusCode(REDIRECT.status).putHeader("location", REDIRECT.body).end() - } - } - router.route(ERROR.path).handler { ctx -> - controller(ERROR) { - ctx.response().setStatusCode(ERROR.status).end(ERROR.body) - } - } - router.route(EXCEPTION.path).handler { ctx -> - controller(EXCEPTION) { - throw new Exception(EXCEPTION.body) - } - } - - vertx.createHttpServer() - .requestHandler { router.accept(it) } - .listen(port) { startFuture.complete() } + } + router.route(QUERY_PARAM.path).handler { ctx -> + controller(QUERY_PARAM) { + ctx.response().setStatusCode(QUERY_PARAM.status).end(ctx.request().query()) } + } + router.route(REDIRECT.path).handler { ctx -> + controller(REDIRECT) { + ctx.response().setStatusCode(REDIRECT.status).putHeader("location", REDIRECT.body).end() + } + } + router.route(ERROR.path).handler { ctx -> + controller(ERROR) { + ctx.response().setStatusCode(ERROR.status).end(ERROR.body) + } + } + router.route(EXCEPTION.path).handler { ctx -> + controller(EXCEPTION) { + throw new Exception(EXCEPTION.body) + } + } + + vertx.createHttpServer() + .requestHandler { router.accept(it) } + .listen(port) { startFuture.complete() } } + } }