Browse Source

Fix a todo (#8343)

Helen 1 year ago
parent
commit
6295c67def

+ 0 - 1
instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/server/base/ImmediateHandlerSpringWebFluxServerTest.java

@@ -5,7 +5,6 @@
 
 package server.base;
 
-import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NESTED_PATH;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assumptions.assumeTrue;
 

+ 3 - 1
instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/server/base/ServerTestController.java

@@ -5,6 +5,8 @@
 
 package server.base;
 
+import static server.base.SpringWebFluxServerTest.NESTED_PATH;
+
 import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
 import java.net.URI;
 import java.util.function.Supplier;
@@ -118,7 +120,7 @@ public abstract class ServerTestController {
 
   @GetMapping("/nestedPath")
   public Mono<String> nested_path(ServerHttpRequest request, ServerHttpResponse response) {
-    ServerEndpoint endpoint = ServerEndpoint.NESTED_PATH;
+    ServerEndpoint endpoint = NESTED_PATH;
 
     return wrapControllerMethod(
         endpoint,

+ 2 - 1
instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/server/base/ServerTestRouteFactory.java

@@ -9,6 +9,7 @@ import static org.springframework.web.reactive.function.server.RequestPredicates
 import static org.springframework.web.reactive.function.server.RequestPredicates.path;
 import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
 import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+import static server.base.SpringWebFluxServerTest.NESTED_PATH;
 
 import io.opentelemetry.api.trace.Span;
 import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
@@ -108,7 +109,7 @@ public abstract class ServerTestRouteFactory {
                 route(
                     path("/world"),
                     request -> {
-                      ServerEndpoint endpoint = ServerEndpoint.NESTED_PATH;
+                      ServerEndpoint endpoint = NESTED_PATH;
                       return respond(endpoint, null, null, null);
                     })));
   }

+ 4 - 1
instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/server/base/SpringWebFluxServerTest.java

@@ -6,7 +6,6 @@
 package server.base;
 
 import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
-import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NESTED_PATH;
 import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
 import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.PATH_PARAM;
 
@@ -22,6 +21,10 @@ import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
 
 public abstract class SpringWebFluxServerTest
     extends AbstractHttpServerTest<ConfigurableApplicationContext> {
+
+  protected static final ServerEndpoint NESTED_PATH =
+      new ServerEndpoint("NESTED_PATH", "nestedPath/hello/world", 200, "nested path");
+
   protected abstract Class<?> getApplicationClass();
 
   @RegisterExtension

+ 1 - 4
testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/ServerEndpoint.java

@@ -29,9 +29,6 @@ public class ServerEndpoint {
       new ServerEndpoint("NOT_FOUND", "notFound", 404, "not found");
   public static final ServerEndpoint CAPTURE_HEADERS =
       new ServerEndpoint("CAPTURE_HEADERS", "captureHeaders", 200, "headers captured");
-  // TODO (heya) move it to webflux test module after this has been converted to a class
-  public static final ServerEndpoint NESTED_PATH =
-      new ServerEndpoint("NESTED_PATH", "nestedPath/hello/world", 200, "nested path");
   public static final ServerEndpoint CAPTURE_PARAMETERS =
       new ServerEndpoint("CAPTURE_PARAMETERS", "captureParameters", 200, "parameters captured");
 
@@ -83,7 +80,7 @@ public class ServerEndpoint {
     return name;
   }
 
-  ServerEndpoint(String name, String uri, int status, String body) {
+  public ServerEndpoint(String name, String uri, int status, String body) {
     this.name = name;
     this.uriObj = URI.create(uri);
     this.path = uriObj.getPath();