Last active
December 31, 2015 18:02
-
-
Save dnvriend/2f0d104b63b5348ddbc6 to your computer and use it in GitHub Desktop.
akka stream v2.0.1 TestSink.expectNextUnordered fails with java.lang.AssertionError: `remaining` may not be called outside of `within` but expectNext runs without any problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dependencies | |
scalaVersion := "2.11.7" | |
libraryDependencies ++= { | |
val akkaVersion = "2.4.1" | |
val akkaStreamAndHttpVersion = "2.0.1" | |
Seq( | |
"com.typesafe.akka" %% "akka-actor" % akkaVersion, | |
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion, | |
"com.typesafe.akka" %% "akka-persistence" % akkaVersion, | |
"com.typesafe.akka" %% "akka-persistence-query-experimental" % akkaVersion, | |
"com.typesafe.akka" %% "akka-stream-experimental" % akkaStreamAndHttpVersion, | |
"com.typesafe.akka" %% "akka-stream-testkit-experimental" % akkaStreamAndHttpVersion % Test, | |
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test, | |
"com.typesafe.akka" %% "akka-persistence-tck" % akkaVersion % Test, | |
"org.scalatest" %% "scalatest" % "2.2.4" % Test | |
) | |
} | |
// the test | |
import akka.actor.ActorSystem | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Source | |
import akka.stream.testkit.scaladsl.TestSink | |
import org.scalatest.{FlatSpec, Matchers} | |
class TestSinkTest extends FlatSpec with Matchers { | |
implicit val system = ActorSystem() | |
implicit val mat = ActorMaterializer() | |
implicit val ec = system.dispatcher | |
"expectNext" should "run with no problems" in { | |
Source(List("my-1", "my-2")) | |
.runWith(TestSink.probe[AnyRef]) | |
.request(3) | |
.expectNext("my-1", "my-2") | |
.expectComplete() | |
} | |
"expectNextUnordered" should "fail with java.lang.AssertionError: `remaining` may not be called outside of `within`" in { | |
intercept[AssertionError] { | |
Source(List("my-1", "my-2")) | |
.runWith(TestSink.probe[AnyRef]) | |
.request(3) | |
.expectNextUnordered("my-1", "my-2") | |
.expectComplete() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment