-
Notifications
You must be signed in to change notification settings - Fork 876
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert vertx-web-3.0 test case from groovy to java (#12826)
- Loading branch information
Showing
8 changed files
with
112 additions
and
107 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
.../vertx-web-3.0/javaagent/src/latestDepTest/groovy/server/VertxLatestHttpServerTest.groovy
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...Test/java/io/opentelemetry/javaagent/instrumentation/vertx/VertxLatestHttpServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.vertx; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Vertx; | ||
|
||
class VertxLatestHttpServerTest extends AbstractVertxHttpServerTest { | ||
|
||
@Override | ||
protected Class<? extends AbstractVerticle> verticle() { | ||
return VertxLatestWebServer.class; | ||
} | ||
|
||
@Override | ||
protected void stopServer(Vertx server) throws Exception { | ||
server.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 0 additions & 83 deletions
83
...ion/vertx/vertx-web-3.0/testing/src/main/groovy/server/AbstractVertxHttpServerTest.groovy
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
...in/java/io/opentelemetry/javaagent/instrumentation/vertx/AbstractVertxHttpServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.vertx; | ||
|
||
import io.opentelemetry.instrumentation.api.internal.HttpConstants; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest; | ||
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions; | ||
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint; | ||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.DeploymentOptions; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.VertxOptions; | ||
import io.vertx.core.json.JsonObject; | ||
import java.util.Objects; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
abstract class AbstractVertxHttpServerTest extends AbstractHttpServerTest<Vertx> { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); | ||
|
||
@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.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 | ||
protected Vertx setupServer() | ||
throws ExecutionException, InterruptedException, TimeoutException, NoSuchMethodException { | ||
Vertx server = | ||
Vertx.vertx( | ||
new VertxOptions() | ||
// Useful for debugging: | ||
// .setBlockedThreadCheckInterval(Integer.MAX_VALUE) | ||
); | ||
CompletableFuture<Void> future = new CompletableFuture<>(); | ||
|
||
server.deployVerticle( | ||
verticle().getName(), | ||
new DeploymentOptions() | ||
.setConfig( | ||
new JsonObject().put(AbstractVertxWebServer.CONFIG_HTTP_SERVER_PORT, (Object) port)) | ||
.setInstances(3), | ||
res -> { | ||
if (!res.succeeded()) { | ||
throw new IllegalStateException("Cannot deploy server Verticle", res.cause()); | ||
} | ||
future.complete(null); | ||
}); | ||
|
||
future.get(30, TimeUnit.SECONDS); | ||
return server; | ||
} | ||
|
||
@Override | ||
protected void stopServer(Vertx server) throws Exception { | ||
server.close(); | ||
} | ||
|
||
protected abstract Class<? extends AbstractVerticle> verticle(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters