From 6dea1167781fb51c1839720ff11a7d77ad9b87af Mon Sep 17 00:00:00 2001 From: "shalk(xiao kun)" Date: Wed, 4 Dec 2024 21:17:13 +0800 Subject: [PATCH] refine ut --- .../vertx}/VertxLatestHttpServerTest.java | 2 +- .../vertx}/VertxLatestWebServer.java | 2 +- .../vertx}/VertxHttpServerTest.java | 2 +- .../vertx}/VertxWebServer.java | 2 +- .../vertx}/AbstractVertxHttpServerTest.java | 28 ++++++++----------- .../vertx}/AbstractVertxWebServer.java | 2 +- 6 files changed, 17 insertions(+), 21 deletions(-) rename instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/VertxLatestHttpServerTest.java (88%) rename instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/VertxLatestWebServer.java (93%) rename instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/VertxHttpServerTest.java (83%) rename instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/VertxWebServer.java (93%) rename instrumentation/vertx/vertx-web-3.0/testing/src/main/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/AbstractVertxHttpServerTest.java (82%) rename instrumentation/vertx/vertx-web-3.0/testing/src/main/java/{server => io/opentelemetry/javaagent/instrumentation/vertx}/AbstractVertxWebServer.java (98%) diff --git a/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestHttpServerTest.java b/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestHttpServerTest.java similarity index 88% rename from instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestHttpServerTest.java rename to instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestHttpServerTest.java index 2693c14725b0..f13cff89107c 100644 --- a/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestHttpServerTest.java +++ b/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestHttpServerTest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; +package io.opentelemetry.javaagent.instrumentation.vertx; import io.vertx.core.AbstractVerticle; import io.vertx.core.Vertx; diff --git a/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestWebServer.java b/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestWebServer.java similarity index 93% rename from instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestWebServer.java rename to instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestWebServer.java index af850c913aeb..fa268df6cea7 100644 --- a/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/server/VertxLatestWebServer.java +++ b/instrumentation/vertx/vertx-web-3.0/javaagent/src/latestDepTest/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestWebServer.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; +package io.opentelemetry.javaagent.instrumentation.vertx; import io.vertx.core.Promise; import io.vertx.core.http.HttpServerResponse; diff --git a/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxHttpServerTest.java b/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxHttpServerTest.java similarity index 83% rename from instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxHttpServerTest.java rename to instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxHttpServerTest.java index 8da399021e64..1281d3e1c546 100644 --- a/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxHttpServerTest.java +++ b/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxHttpServerTest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; +package io.opentelemetry.javaagent.instrumentation.vertx; import io.vertx.core.AbstractVerticle; diff --git a/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxWebServer.java b/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxWebServer.java similarity index 93% rename from instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxWebServer.java rename to instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxWebServer.java index aad9975810b2..860af9122088 100644 --- a/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/server/VertxWebServer.java +++ b/instrumentation/vertx/vertx-web-3.0/javaagent/src/version3Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxWebServer.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; +package io.opentelemetry.javaagent.instrumentation.vertx; import io.vertx.core.Future; import io.vertx.core.http.HttpServerResponse; diff --git a/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxHttpServerTest.java b/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxHttpServerTest.java similarity index 82% rename from instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxHttpServerTest.java rename to instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxHttpServerTest.java index 4a1a95173ff4..72a20a538950 100644 --- a/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxHttpServerTest.java +++ b/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxHttpServerTest.java @@ -3,9 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; - -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION; +package io.opentelemetry.javaagent.instrumentation.vertx; import io.opentelemetry.instrumentation.api.internal.HttpConstants; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; @@ -32,23 +30,21 @@ abstract class AbstractVertxHttpServerTest extends AbstractHttpServerTest @Override protected void configure(HttpServerTestOptions options) { + super.configure(options); options.setTestPathParam(true); // server spans are ended inside of the controller spans options.setVerifyServerSpanEndTime(false); options.setContextPath("/vertx-app"); - options.setExpectedException(new IllegalStateException(EXCEPTION.getBody())); - super.configure(options); - } - - @Override - public String expectedHttpRoute(ServerEndpoint endpoint, String method) { - if (Objects.equals(method, HttpConstants._OTHER)) { - return getContextPath() + endpoint.getPath(); - } - if (Objects.equals(endpoint, ServerEndpoint.NOT_FOUND)) { - return getContextPath(); - } - return super.expectedHttpRoute(endpoint, method); + options.setExpectedHttpRoute( + (endpoint, method) -> { + if (Objects.equals(method, HttpConstants._OTHER)) { + return getContextPath() + endpoint.getPath(); + } + if (Objects.equals(endpoint, ServerEndpoint.NOT_FOUND)) { + return getContextPath(); + } + return super.expectedHttpRoute(endpoint, method); + }); } @Override diff --git a/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxWebServer.java b/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxWebServer.java similarity index 98% rename from instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxWebServer.java rename to instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxWebServer.java index d312dff8f274..8546e12e2966 100644 --- a/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/server/AbstractVertxWebServer.java +++ b/instrumentation/vertx/vertx-web-3.0/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxWebServer.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package server; +package io.opentelemetry.javaagent.instrumentation.vertx; import static io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest.controller; import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;