2014-08-21 16:07:09 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2014 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.stream.tck
|
|
|
|
|
|
2014-10-06 14:04:05 +02:00
|
|
|
import scala.concurrent.duration._
|
|
|
|
|
|
2014-08-21 16:07:09 +02:00
|
|
|
import akka.actor.ActorSystem
|
2014-10-06 14:04:05 +02:00
|
|
|
import akka.stream.MaterializerSettings
|
|
|
|
|
import akka.stream.scaladsl2.FlowMaterializer
|
2014-08-21 16:07:09 +02:00
|
|
|
import akka.stream.testkit.AkkaSpec
|
|
|
|
|
import akka.stream.testkit.StreamTestKit
|
|
|
|
|
import org.reactivestreams.Publisher
|
|
|
|
|
import org.reactivestreams.tck.{ PublisherVerification, TestEnvironment }
|
|
|
|
|
import org.scalatest.testng.TestNGSuiteLike
|
|
|
|
|
import org.testng.annotations.AfterClass
|
|
|
|
|
|
|
|
|
|
abstract class AkkaPublisherVerification[T](val system: ActorSystem, env: TestEnvironment, publisherShutdownTimeout: Long)
|
|
|
|
|
extends PublisherVerification[T](env, publisherShutdownTimeout)
|
|
|
|
|
with TestNGSuiteLike {
|
|
|
|
|
|
|
|
|
|
/** Readable way to ignore TCK specs; Return this for `createErrorStatePublisher` to skip tests including it */
|
|
|
|
|
final def ignored: Publisher[T] = null
|
|
|
|
|
|
|
|
|
|
def this(system: ActorSystem, printlnDebug: Boolean) {
|
|
|
|
|
this(system, new TestEnvironment(Timeouts.defaultTimeoutMillis(system), printlnDebug), Timeouts.publisherShutdownTimeoutMillis)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def this(printlnDebug: Boolean) {
|
|
|
|
|
this(ActorSystem(classOf[IterablePublisherTest].getSimpleName, AkkaSpec.testConf), printlnDebug)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def this() {
|
|
|
|
|
this(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
implicit val materializer = FlowMaterializer(MaterializerSettings(system).copy(maxInputBufferSize = 512))(system)
|
|
|
|
|
|
|
|
|
|
override def skipStochasticTests() = true // TODO maybe enable?
|
|
|
|
|
|
|
|
|
|
@AfterClass
|
|
|
|
|
def shutdownActorSystem(): Unit = {
|
|
|
|
|
system.shutdown()
|
|
|
|
|
system.awaitTermination(10.seconds)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def createErrorStatePublisher(): Publisher[T] =
|
|
|
|
|
StreamTestKit.errorPublisher(new Exception("Unable to serve subscribers right now!"))
|
|
|
|
|
}
|