Skip to content

Commit

Permalink
=test Fix keystore loading on Windows in RemotingSpec.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Sep 9, 2023
1 parent d0099a1 commit b37b5cd
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
package org.apache.pekko.remote.classic

import java.io.NotSerializableException
import java.nio.file.Paths
import java.util.concurrent.ThreadLocalRandom

import scala.annotation.nowarn
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration._
import scala.util.control.NonFatal

import scala.annotation.nowarn
import com.typesafe.config._

import org.apache.pekko
import pekko.actor._
import pekko.event.AddressTerminatedTopic
Expand Down Expand Up @@ -77,8 +77,8 @@ object RemotingSpec {

val cfg: Config = ConfigFactory.parseString(s"""
common-ssl-settings {
key-store = "${getClass.getClassLoader.getResource("keystore").getPath}"
trust-store = "${getClass.getClassLoader.getResource("truststore").getPath}"
key-store = "${resourcePath("keystore")}"
trust-store = "${resourcePath("truststore")}"
key-store-password = "changeme"
key-password = "changeme"
trust-store-password = "changeme"
Expand Down Expand Up @@ -142,6 +142,13 @@ object RemotingSpec {
EventFilter.warning(start = "AssociationError"),
EventFilter.warning(pattern = "received dead letter.*")))
}

private def resourcePath(resourceName: String): String = {
val normalizedPath = Paths.get(getClass.getClassLoader.getResource(resourceName).toURI).normalize()
// Make it works on Windows
normalizedPath.toString.replace('\\', '/')
}

}

@nowarn
Expand Down

0 comments on commit b37b5cd

Please sign in to comment.