Skip to content

Commit

Permalink
⬆️ use play 3 also in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoballekens committed Jun 7, 2024
1 parent f9015c1 commit f883f49
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 324 deletions.
20 changes: 10 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import sbt.Keys.thisProjectRef

ThisBuild / organization := "io.waylay.kairosdb"

val playWsVersion = "2.1.11"
val playWsVersion = "3.0.3"
val playJsonVersion = "3.0.3"
val specs2Version = "4.20.6"

val dockerTestkitVersion = "0.12.0"
val scalaTestVersion = "3.2.18"
val playVersion = "2.8.21" // test only
val playVersion = "3.0.3" // test only

val scala2_12 = "2.12.19"
val scala2_13 = "2.13.14"
Expand Down Expand Up @@ -40,17 +40,17 @@ lazy val root = (project in file("."))
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.1",
"org.playframework" %% "play-json" % playJsonVersion,
"com.typesafe.play" %% "play-ws-standalone" % playWsVersion,
"com.typesafe.play" %% "play-ws-standalone-json" % playWsVersion,
"org.playframework" %% "play-ws-standalone" % playWsVersion,
"org.playframework" %% "play-ws-standalone-json" % playWsVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"io.lemonlabs" %% "scala-uri" % "4.0.3",
// TEST
"org.specs2" %% "specs2-core" % specs2Version % Test,
"org.specs2" %% "specs2-junit" % specs2Version % Test,
"de.leanovate.play-mockws" %% "play-mockws" % "2.8.1" % Test,
"com.typesafe.play" %% "play-ahc-ws" % playVersion % TestAndIntegrationTest, // neede for play-mockws
"com.typesafe.play" %% "play-test" % playVersion % TestAndIntegrationTest, // play-mockws depends on some types in this dependency
"com.typesafe.play" %% "play-ahc-ws-standalone" % playWsVersion % TestAndIntegrationTest,
"de.leanovate.play-mockws" %% "play-mockws-3-0" % "3.0.4" % Test,
"org.playframework" %% "play-ahc-ws" % playVersion % TestAndIntegrationTest, // neede for play-mockws
"org.playframework" %% "play-test" % playVersion % TestAndIntegrationTest, // play-mockws depends on some types in this dependency
"org.playframework" %% "play-ahc-ws-standalone" % playWsVersion % TestAndIntegrationTest,
// INTEGRATION TESTS
// TODO investigate if we can do this with specs2
"org.scalatest" %% "scalatest-wordspec" % scalaTestVersion % TestAndIntegrationTest,
Expand Down Expand Up @@ -85,7 +85,7 @@ val publishScalaDoc = (ref: ProjectRef) =>

val runIntegrationTest = (ref: ProjectRef) =>
ReleaseStep(
action = releaseStepTaskAggregated(test in IntegrationTest in ref)
action = releaseStepTaskAggregated(ref / IntegrationTest / test)
)

releaseProcess := {
Expand Down Expand Up @@ -114,6 +114,6 @@ lazy val examples = project
.dependsOn(root)
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-ahc-ws-standalone" % playWsVersion
"org.playframework" %% "play-ahc-ws-standalone" % playWsVersion
)
)
9 changes: 5 additions & 4 deletions src/it/scala/integration/IntegrationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package integration

import akka.stream.testkit.NoMaterializer
import com.spotify.docker.client.messages.HostConfig
import com.typesafe.scalalogging.StrictLogging
import com.whisk.docker.testkit.{ContainerGroup, ContainerSpec, DockerReadyChecker}
import com.whisk.docker.testkit.scalatest.DockerTestKitForAll
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.testkit.NoMaterializer
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.matchers.must.Matchers
Expand Down Expand Up @@ -37,13 +38,13 @@ trait IntegrationSpec extends AnyWordSpec with Matchers with ScalaFutures with S
.getOrElse(throw new IllegalStateException(s"Missing container mapped port for $DefaultKairosDbPort"))
}

implicit val pc = PatienceConfig(Span(2000, Seconds), Span(1, Second))
implicit val pc: PatienceConfig = PatienceConfig(Span(2000, Seconds), Span(1, Second))
//override def dockerInitPatienceInterval = PatienceConfig(scaled(Span(30, Seconds)), scaled(Span(10, Millis)))

override val managedContainers: ContainerGroup = ContainerGroup(Seq(kairosdbContainer.toContainer))

implicit val materializer = NoMaterializer
val wsClient = StandaloneAhcWSClient()
implicit val materializer: Materializer = NoMaterializer
val wsClient: StandaloneAhcWSClient = StandaloneAhcWSClient()

override def afterAll(): Unit = {
wsClient.close()
Expand Down
23 changes: 10 additions & 13 deletions src/main/scala/io/waylay/kairosdb/driver/KairosDB.scala
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package io.waylay.kairosdb.driver

import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream

import io.waylay.kairosdb.driver.models._
import io.waylay.kairosdb.driver.models.HealthCheckResult._
import io.lemonlabs.uri.typesafe.dsl._
import com.typesafe.scalalogging.StrictLogging
import io.lemonlabs.uri.typesafe.dsl._
import io.waylay.kairosdb.driver.KairosDB._
import io.waylay.kairosdb.driver.models.HealthCheckResult._
import io.waylay.kairosdb.driver.models.QueryMetricTagsResponse.TagQueryResponse
import io.waylay.kairosdb.driver.models.json.Formats._
import io.waylay.kairosdb.driver.models.QueryResponse.Response
import io.waylay.kairosdb.driver.models._
import io.waylay.kairosdb.driver.models.json.Formats._
import play.api.libs.json._
import play.api.libs.ws.{StandaloneWSClient, StandaloneWSRequest, StandaloneWSResponse, WSAuthScheme}
import play.api.libs.ws.DefaultBodyWritables._
import play.api.libs.ws.JsonBodyWritables._
import play.api.libs.ws.JsonBodyReadables._
import play.api.libs.ws.JsonBodyWritables._
import play.api.libs.ws.{StandaloneWSClient, StandaloneWSRequest, StandaloneWSResponse, WSAuthScheme}

import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream
import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}
import scala.concurrent.duration._
import scala.collection.immutable.Seq
import scala.collection.compat._

object KairosDB {

Expand All @@ -37,7 +34,7 @@ object KairosDB {
}

class KairosDB(wsClient: StandaloneWSClient, config: KairosDBConfig, executionContext: ExecutionContext) extends StrictLogging {
implicit val ec = executionContext
implicit val ec: ExecutionContext = executionContext
val url = config.url

def listMetricNames: Future[Seq[MetricName]] = {
Expand Down
6 changes: 2 additions & 4 deletions src/main/scala/io/waylay/kairosdb/driver/models/Models.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.waylay.kairosdb.driver.models

import java.time.Instant
import io.lemonlabs.uri.{Uri, Url, UrlWithAuthority}
import io.lemonlabs.uri.{Uri, Url}
import io.waylay.kairosdb.driver.models.KairosQuery.{Order, QueryTag}
import io.waylay.kairosdb.driver.models.QueryResponse.TagResult
import io.waylay.kairosdb.driver.models.TimeRange.KairosTimeUnit

import scala.collection.immutable.Seq
import scala.collection.compat._
import java.time.Instant

/**
* Metric names are case sensitive and can only contain the following characters: alphanumeric characters, period ”.”,
Expand Down
Loading

0 comments on commit f883f49

Please sign in to comment.