You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by jr...@apache.org on 2022/11/03 11:24:02 UTC
[incubator-pekko-http] 32/47: testkit: enable Scala 3
This is an automated email from the ASF dual-hosted git repository.
jrudolph pushed a commit to branch scala-3
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-http.git
commit 495adb79682052be0f760e30c4b9da7a14da089c
Author: Johannes Rudolph <jo...@gmail.com>
AuthorDate: Mon Apr 11 14:50:00 2022 +0200
testkit: enable Scala 3
---
.../main/scala/akka/http/scaladsl/testkit/RouteTest.scala | 10 +++++-----
.../akka/http/scaladsl/testkit/RouteTestTimeout.scala | 2 +-
.../http/scaladsl/testkit/ScalatestRouteTestSpec.scala | 3 ++-
.../akka/http/scaladsl/testkit/Specs2RouteTestSpec.scala | 3 ++-
build.sbt | 1 -
project/Dependencies.scala | 15 +++++++++------
6 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTest.scala b/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTest.scala
index 812d499bc..30eb2e597 100644
--- a/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTest.scala
+++ b/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTest.scala
@@ -16,7 +16,7 @@ import akka.http.scaladsl.settings.RoutingSettings
import akka.http.scaladsl.settings.ServerSettings
import akka.http.scaladsl.unmarshalling._
import akka.http.scaladsl.util.FastFuture._
-import akka.stream.SystemMaterializer
+import akka.stream.{ Materializer, SystemMaterializer }
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import akka.util.ConstantFun
@@ -24,7 +24,7 @@ import com.typesafe.config.{ Config, ConfigFactory }
import scala.collection.immutable
import scala.concurrent.duration._
-import scala.concurrent.{ Await, ExecutionContext, Future }
+import scala.concurrent.{ Await, ExecutionContext, ExecutionContextExecutor, Future }
import scala.reflect.ClassTag
import scala.util.DynamicVariable
@@ -47,9 +47,9 @@ trait RouteTest extends RequestBuilding with WSTestRequestBuilding with RouteTes
val config = if (source.isEmpty) ConfigFactory.empty() else ConfigFactory.parseString(source)
config.withFallback(ConfigFactory.load())
}
- implicit val system = createActorSystem()
- implicit def executor = system.dispatcher
- implicit val materializer = SystemMaterializer(system).materializer
+ implicit val system: ActorSystem = createActorSystem()
+ implicit def executor: ExecutionContextExecutor = system.dispatcher
+ implicit val materializer: Materializer = SystemMaterializer(system).materializer
def cleanUp(): Unit = TestKit.shutdownActorSystem(system)
diff --git a/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTestTimeout.scala b/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTestTimeout.scala
index 738bfe745..19276d293 100644
--- a/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTestTimeout.scala
+++ b/akka-http-testkit/src/main/scala/akka/http/scaladsl/testkit/RouteTestTimeout.scala
@@ -11,5 +11,5 @@ import akka.testkit._
case class RouteTestTimeout(duration: FiniteDuration)
object RouteTestTimeout {
- implicit def default(implicit system: ActorSystem) = RouteTestTimeout(1.second.dilated)
+ implicit def default(implicit system: ActorSystem): RouteTestTimeout = RouteTestTimeout(1.second.dilated)
}
diff --git a/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala b/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala
index 93bb0d3c7..4dcde5a86 100644
--- a/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala
+++ b/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala
@@ -14,6 +14,7 @@ import akka.http.scaladsl.model._
import StatusCodes._
import HttpMethods._
import Directives._
+import akka.actor.ActorRef
import akka.stream.scaladsl.Source
import org.scalatest.exceptions.TestFailedException
import headers.`X-Forwarded-Proto`
@@ -101,7 +102,7 @@ class ScalatestRouteTestSpec extends AnyFreeSpec with Matchers with ScalatestRou
case object Command
val service = TestProbe()
val handler = TestProbe()
- implicit def serviceRef = service.ref
+ implicit def serviceRef: ActorRef = service.ref
implicit val askTimeout: Timeout = 1.second.dilated
val result =
diff --git a/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/Specs2RouteTestSpec.scala b/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/Specs2RouteTestSpec.scala
index cf7be39fa..f3405a9c2 100644
--- a/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/Specs2RouteTestSpec.scala
+++ b/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/Specs2RouteTestSpec.scala
@@ -4,6 +4,7 @@
package akka.http.scaladsl.testkit
+import akka.actor.ActorRef
import akka.http.scaladsl.model.HttpMethods._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.model._
@@ -54,7 +55,7 @@ class Specs2RouteTestSpec extends Specification with Specs2RouteTest {
case object Command
val service = TestProbe()
val handler = TestProbe()
- implicit def serviceRef = service.ref
+ implicit def serviceRef: ActorRef = service.ref
implicit val askTimeout: Timeout = 1.second
val result =
diff --git a/build.sbt b/build.sbt
index 157a7f358..1faacbd8e 100644
--- a/build.sbt
+++ b/build.sbt
@@ -251,7 +251,6 @@ lazy val httpTestkit = project("akka-http-testkit")
.enablePlugins(BootstrapGenjavadoc, MultiNodeScalaTest, ScaladocNoVerificationOfDiagrams)
.enablePlugins(ReproducibleBuildsPlugin)
.disablePlugins(MimaPlugin) // testkit, no bin compat guaranteed
- .enablePlugins(NoScala3) // FIXME
lazy val httpTests = project("akka-http-tests")
.settings(commonSettings)
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index b1a20619b..115e2e9da 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -81,7 +81,14 @@ object Dependencies {
object Test {
val sprayJson = Compile.sprayJson % "test" // ApacheV2
val junit = Compile.junit % "test" // Common Public License 1.0
- val specs2 = "org.specs2" %% "specs2-core" % specs2Version % "test" // MIT
+ val specs2 = {
+ val specs2 = "org.specs2" %% "specs2-core" // MIT
+ ScalaVersionDependentModuleID.versioned {
+ case v if v.startsWith("2.") => specs2 % "4.10.6"
+ case _ => specs2 % "4.15.0"
+ }
+ }
+
val scalacheck = "org.scalacheck" %% "scalacheck" % scalaCheckVersion % "test" // New BSD
val junitIntf = "com.github.sbt" % "junit-interface" % "0.13.3" % "test" // MIT
@@ -123,11 +130,7 @@ object Dependencies {
lazy val httpTestkit = Seq(
versionDependentDeps(
- ScalaVersionDependentModuleID.fromPF {
- // FIXME: ultimately, we might update to a Scala 3 compatible version of specs2
- // for now disable specs2 support in the Scala 3 akka-http-testkit
- case v if v startsWith "2." => Test.specs2.withConfigurations(Some("provided; test"))
- }
+ Test.specs2 % "provided; test"
),
l ++= Seq(
Test.junit, Test.junitIntf, Compile.junit % "provided",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org