Skip to content

Commit

Permalink
fix gradle building issues for plugin-tester-java
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyPlane committed Oct 26, 2023
1 parent b38d823 commit 7978c17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions plugin-tester-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
id 'scala'
id 'com.lightbend.akka.grpc.gradle' version "${akkaGrpcVersion}"
}

akkaGrpc {
generateClient = true
generateServer = true
Expand All @@ -37,11 +38,13 @@ repositories {

def scalaVersion = org.gradle.util.VersionNumber.parse(System.getenv("TRAVIS_SCALA_VERSION") ?: "2.13")
def scalaBinaryVersion = "${scalaVersion.major}.${scalaVersion.minor}"
def akkaHttpVersion = "10.5.0"
def akkaVersion = "2.9.0"

dependencies {
implementation group: 'ch.megard', name: "akka-http-cors_${scalaBinaryVersion}", version: '1.1.3'
testImplementation "com.typesafe.akka:akka-stream-testkit_${scalaBinaryVersion}:${akkaVersion}"
testImplementation "com.typesafe.akka:akka-http-spray-json_${scalaBinaryVersion}:${akkaHttpVersion}"
implementation "com.typesafe.akka:akka-pki_${scalaBinaryVersion}:${akkaVersion}"
testImplementation "org.scalatest:scalatest_${scalaBinaryVersion}:3.2.12"
testImplementation "org.scalatestplus:junit-4-12_${scalaBinaryVersion}:3.2.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,39 @@

package example.myapp.shelf

import akka.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.client.RequestBuilding.Get
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.unmarshalling.Unmarshal
import com.typesafe.config.ConfigFactory
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.matchers.should.Matchers
import org.scalatest.time.Span
import org.scalatest.wordspec.AnyWordSpecLike
import spray.json.JsObject
import spray.json.DefaultJsonProtocol._
import spray.json.JsObject

import scala.concurrent.ExecutionContextExecutor
import scala.compat.java8.FutureConverters._
import scala.concurrent.duration._

class ShelfServiceHttpTranscodingSpec
extends ScalaTestWithActorTestKit(config = "akka.http.server.enable-http2 = on")
with AnyWordSpecLike
with BeforeAndAfterAll {
implicit val ec: ExecutionContextExecutor = system.executionContext
class ShelfServiceHttpTranscodingSpec extends AnyWordSpecLike with Matchers with ScalaFutures with BeforeAndAfterAll {

implicit val patience: PatienceConfig =
PatienceConfig(5.seconds, Span(100, org.scalatest.time.Millis))

implicit val serverSystem: ActorSystem = {
// important to enable HTTP/2 in server ActorSystem's config
val conf =
ConfigFactory.parseString("akka.http.server.enable-http2 = on").withFallback(ConfigFactory.defaultApplication())
val sys = ActorSystem("ShelfServer", conf)
// make sure servers are bound before using client
ShelfServer.run(sys).toCompletableFuture.get
sys
}

val serverWithHttpTranscoding = ShelfServer.run(system.classicSystem).toScala.futureValue
implicit val ec: ExecutionContextExecutor = serverSystem.dispatcher

"a gRPC server with HTTP transcoding enabled" should {

Expand Down

0 comments on commit 7978c17

Please sign in to comment.