From be153f0764ced5b78ee74be1c9d30caa3b5b84be Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 2 Oct 2024 21:50:34 +0100 Subject: [PATCH] make pekko test code more scala 3 friendly (#12384) --- .../v1_0/PekkoHttpClientInstrumentationTest.scala | 3 +-- .../pekkohttp/v1_0/PekkoHttpServerRouteTest.scala | 2 -- .../pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala | 2 -- .../v1_0/PekkoHttpTestServerSourceWebServer.scala | 8 +++----- .../pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala | 8 +++----- .../pekkohttp/v1_0/PekkoHttpTestWebServer.scala | 8 +++----- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpClientInstrumentationTest.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpClientInstrumentationTest.scala index eef1b31345..c686d00b6a 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpClientInstrumentationTest.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpClientInstrumentationTest.scala @@ -43,8 +43,7 @@ class PekkoHttpClientInstrumentationTest HttpClientInstrumentationExtension.forAgent() val system: ActorSystem = ActorSystem.create() - implicit val materializer: ActorMaterializer = - ActorMaterializer.create(system) + val materializer: ActorMaterializer = ActorMaterializer.create(system) override def buildRequest( method: String, diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerRouteTest.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerRouteTest.scala index e01f6eee04..cbaaa79704 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerRouteTest.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerRouteTest.scala @@ -25,7 +25,6 @@ import org.apache.pekko.http.scaladsl.server.Directives.{ pathPrefix, pathSingleSlash } -import org.apache.pekko.stream.ActorMaterializer import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.extension.RegisterExtension import org.junit.jupiter.api.{AfterAll, Test, TestInstance} @@ -42,7 +41,6 @@ class PekkoHttpServerRouteTest { private val client: WebClient = WebClient.of() implicit val system: ActorSystem = ActorSystem("my-system") - implicit val materializer: ActorMaterializer = ActorMaterializer() private def buildAddress(port: Int): URI = try new URI("http://localhost:" + port + "/") diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala index 9de77dd353..eda85362dc 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala @@ -10,7 +10,6 @@ import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.Http.ServerBinding import org.apache.pekko.http.scaladsl.model.HttpMethods.GET import org.apache.pekko.http.scaladsl.model._ -import org.apache.pekko.stream.ActorMaterializer import io.opentelemetry.instrumentation.testing.junit.http.{ AbstractHttpServerTest, ServerEndpoint @@ -22,7 +21,6 @@ import scala.concurrent.{Await, ExecutionContextExecutor, Future} object PekkoHttpTestAsyncWebServer { implicit val system: ActorSystem = ActorSystem("my-system") - implicit val materializer: ActorMaterializer = ActorMaterializer() // needed for the future flatMap/onComplete in the end implicit val executionContext: ExecutionContextExecutor = system.dispatcher val asyncHandler: HttpRequest => Future[HttpResponse] = { diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestServerSourceWebServer.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestServerSourceWebServer.scala index 6b3e1b2db8..0cac71e890 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestServerSourceWebServer.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestServerSourceWebServer.scala @@ -13,16 +13,14 @@ import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.Http.ServerBinding import org.apache.pekko.http.scaladsl.model.StatusCodes.Found import org.apache.pekko.http.scaladsl.server.Directives._ -import org.apache.pekko.stream.ActorMaterializer import org.apache.pekko.stream.scaladsl.Sink -import scala.concurrent.Await +import scala.concurrent.{Await, ExecutionContext} object PekkoHttpTestServerSourceWebServer { - implicit val system = ActorSystem("my-system") - implicit val materializer = ActorMaterializer() + implicit val system: ActorSystem = ActorSystem("my-system") // needed for the future flatMap/onComplete in the end - implicit val executionContext = system.dispatcher + implicit val executionContext: ExecutionContext = system.dispatcher var route = get { concat( diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala index 66499a3a71..9016fd3784 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala @@ -10,7 +10,6 @@ import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.Http.ServerBinding import org.apache.pekko.http.scaladsl.model.HttpMethods.GET import org.apache.pekko.http.scaladsl.model._ -import org.apache.pekko.stream.ActorMaterializer import io.opentelemetry.instrumentation.testing.junit.http.{ AbstractHttpServerTest, ServerEndpoint @@ -18,13 +17,12 @@ import io.opentelemetry.instrumentation.testing.junit.http.{ import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint._ import java.util.function.Supplier -import scala.concurrent.Await +import scala.concurrent.{Await, ExecutionContext} object PekkoHttpTestSyncWebServer { - implicit val system = ActorSystem("my-system") - implicit val materializer = ActorMaterializer() + implicit val system: ActorSystem = ActorSystem("my-system") // needed for the future flatMap/onComplete in the end - implicit val executionContext = system.dispatcher + implicit val executionContext: ExecutionContext = system.dispatcher val syncHandler: HttpRequest => HttpResponse = { case HttpRequest(GET, uri: Uri, _, _, _) => { val endpoint = ServerEndpoint.forPath(uri.path.toString()) diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestWebServer.scala b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestWebServer.scala index e9c66cdaf8..94cb0f877a 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestWebServer.scala +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestWebServer.scala @@ -13,15 +13,13 @@ import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.Http.ServerBinding import org.apache.pekko.http.scaladsl.model.StatusCodes.Found import org.apache.pekko.http.scaladsl.server.Directives._ -import org.apache.pekko.stream.ActorMaterializer -import scala.concurrent.Await +import scala.concurrent.{Await, ExecutionContext} object PekkoHttpTestWebServer { - implicit val system = ActorSystem("my-system") - implicit val materializer = ActorMaterializer() + implicit val system: ActorSystem = ActorSystem("my-system") // needed for the future flatMap/onComplete in the end - implicit val executionContext = system.dispatcher + implicit val executionContext: ExecutionContext = system.dispatcher var route = get { concat(