Open
Description
Running from the example for Postgres I am getting a ClassNotFoundException. I have tried both Specs2 and ScalaTest and get the same results.
Any insights?
StackTrace:
[info] com.banno.transaction.exporter.history.PostgresServiceSpec *** ABORTED ***
[info] java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
[info] at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:122)
[info] at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91)
[info] at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:69)
[info] at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:80)
[info] at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:81)
[info] at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:297)
[info] at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:76)
[info] at com.spotify.docker.client.DefaultDockerClient.resource(DefaultDockerClient.java:2602)
[info] at com.spotify.docker.client.DefaultDockerClient.listImages(DefaultDockerClient.java:624)
[info] at com.whisk.docker.impl.spotify.SpotifyDockerCommandExecutor.$anonfun$listImages$1(SpotifyDockerCommandExecutor.scala:184)
TestCode:
import java.sql.DriverManager
import scala.concurrent.ExecutionContext
import scala.util.Try
import com.whisk.docker._
trait DockerPostgresService extends DockerKit {
import scala.concurrent.duration._
import DockerPostgresService._
def PostgresAdvertisedPort = 5432
def PostgresExposedPort = 44444
val PostgresUser = "nph"
val PostgresPassword = "suitup"
val postgresContainer = DockerContainer("postgres:9.5.3")
.withPorts((PostgresAdvertisedPort, Some(PostgresExposedPort)))
.withEnv(s"POSTGRES_USER=$PostgresUser", s"POSTGRES_PASSWORD=$PostgresPassword")
.withReadyChecker(
new PostgresReadyChecker(PostgresUser, PostgresPassword, Some(PostgresExposedPort))
.looped(15, 1.second)
)
abstract override def dockerContainers: List[DockerContainer] =
postgresContainer :: super.dockerContainers
}
object DockerPostgresService {
class PostgresReadyChecker(user: String, password: String, port: Option[Int] = None)
extends DockerReadyChecker {
override def apply(container: DockerContainerState)
(implicit docker: DockerCommandExecutor,
ec: ExecutionContext) =
container
.getPorts()
.map(ports =>
Try {
Class.forName("org.postgresql.Driver")
val url = s"jdbc:postgresql://${docker.host}:${port.getOrElse(ports.values.head)}/"
Option(DriverManager.getConnection(url, user, password)).map(_.close).isDefined
}.getOrElse(false))
}
}
import com.whisk.docker.DockerKit
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time._
import org.scalatest.{BeforeAndAfterAll, Suite}
//import org.slf4j.LoggerFactory
trait DockerTestKit extends BeforeAndAfterAll with ScalaFutures with DockerKit { self: Suite =>
// private lazy val log = LoggerFactory.getLogger(this.getClass)
def dockerInitPatienceInterval =
PatienceConfig(scaled(Span(20, Seconds)), scaled(Span(10, Millis)))
def dockerPullImagesPatienceInterval =
PatienceConfig(scaled(Span(1200, Seconds)), scaled(Span(250, Millis)))
override def beforeAll(): Unit = {
super.beforeAll()
startAllOrFail()
}
override def afterAll(): Unit = {
stopAllQuietly()
super.afterAll()
}
}
import com.spotify.docker.client.DefaultDockerClient
import com.whisk.docker.impl.spotify.SpotifyDockerFactory
import org.scalatest.time.{Second, Seconds, Span}
import org.scalatest.{FlatSpec, Matchers}
class PostgresServiceSpec
extends FlatSpec
with Matchers
with DockerTestKit
with DockerPostgresService {
implicit val pc = PatienceConfig(Span(20, Seconds), Span(1, Second))
override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(
DefaultDockerClient.fromEnv().build())
"postgres node" should "be ready with log line checker" in {
isContainerReady(postgresContainer).futureValue shouldBe true
}
}
Metadata
Metadata
Assignees
Labels
No labels