Hi,
I try to write my first Akka Stream project which periodically fetch data
from a remote server via Akka Http and the superpool.
Now, if I run my test with the akka stream testkit I get back a
java.lang.AssertionError.
See below. But if I run the test with built in sources and sinks all works
fine.
Please help me to understand this behaviour.
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val executionContext = system.dispatcher
//This code fails with an AssertionError
"Grabber" >> {
"load data from remote server" >> {
val sourceUnderTest: Source[(Try[HttpResponse], Int), Unit] = new
Grabber().source //system and materializer wil be passed as implicits
val sub = sourceUnderTest
.runWith(TestSink.probe[(Try[HttpResponse], Int)])
.request(n = 1)
.expectNext()
sub._1 must beSuccessfulTry.which(_.status === StatusCodes.OK)
}
}
//This Code works fine
"Grabber" >> {
"load data from remote server" >> {
val sourceUnderTest: Source[(Try[HttpResponse], Int), Unit] = new
Grabber().source
val sink = Flow[(Try[HttpResponse],Int)].toMat(Sink.head)(Keep.right)
val res = for {
response <- sourceUnderTest.runWith(sink)
} yield response._1 must beSuccessfulTry.which(_.status === StatusCodes
.OK)
Await.result(res, Duration.Inf)
}
}
java.lang.AssertionError: assertion failed: timeout (3 seconds) during
expectMsgClass waiting for class akka.stream.testkit.StreamTestKit$OnNext
at scala.Predef$.assert(Predef.scala:165)
at akka.testkit.TestKitBase$class.expectMsgClass_internal(TestKit.scala:
423)
at akka.testkit.TestKitBase$class.expectMsgType(TestKit.scala:396)
at akka.testkit.TestKit.expectMsgType(TestKit.scala:718)
at akka.stream.testkit.TestSubscriber$ManualProbe.expectNext(
StreamTestKit.scala:223)
at RemoteSpec$$anonfun$1$$anonfun$apply$1.apply(RemoteSpec.scala:41)
at RemoteSpec$$anonfun$1$$anonfun$apply$1.apply(RemoteSpec.scala:36)
at org.specs2.matcher.MatchResult$$anon$12$$anonfun$asResult$1.apply(
MatchResult.scala:310)
at org.specs2.matcher.MatchResult$$anon$12$$anonfun$asResult$1.apply(
MatchResult.scala:310)
at org.specs2.execute.ResultExecution$class.execute(ResultExecution.
scala:25)
at org.specs2.execute.ResultExecution$.execute(ResultExecution.scala:120
)
at org.specs2.execute.Result$$anon$10.asResult(Result.scala:227)
at org.specs2.execute.AsResult$.apply(AsResult.scala:25)
at org.specs2.matcher.MatchResult$$anon$12.asResult(MatchResult.scala:
310)
at org.specs2.execute.AsResult$.apply(AsResult.scala:25)
at org.specs2.main.CommandLineAsResult$$anon$1.asResult(
CommandLineAsResult.scala:17)
at org.specs2.main.CommandLineAsResult$$anonfun$apply$1.apply(
CommandLineAsResult.scala:21)
at org.specs2.main.CommandLineAsResult$$anonfun$apply$1.apply(
CommandLineAsResult.scala:21)
at org.specs2.specification.dsl.mutable.
ExampleDsl1$BlockExample$$anonfun$$greater$greater$1.apply(ExampleDsl.scala:
39)
at org.specs2.specification.dsl.mutable.
ExampleDsl1$BlockExample$$anonfun$$greater$greater$1.apply(ExampleDsl.scala:
39)
at org.specs2.specification.core.
Execution$$anonfun$withEnv$1$$anonfun$apply$3.apply(Execution.scala:132)
at org.specs2.execute.ResultExecution$class.execute(ResultExecution.
scala:25)
at org.specs2.execute.ResultExecution$.execute(ResultExecution.scala:120
)
at org.specs2.execute.Result$$anon$10.asResult(Result.scala:227)
at org.specs2.execute.AsResult$.apply(AsResult.scala:25)
at org.specs2.specification.core.Execution$$anonfun$withEnv$1.apply(
Execution.scala:132)
at org.specs2.specification.core.Execution$$anonfun$withEnv$1.apply(
Execution.scala:132)
at org.specs2.specification.core.
Execution$$anonfun$execute$2$$anonfun$apply$2.apply(Execution.scala:73)
at org.specs2.specification.core.
Execution$$anonfun$execute$2$$anonfun$apply$2.apply(Execution.scala:73)
at org.specs2.specification.core.Execution.setResult(Execution.scala:81)
at org.specs2.specification.core.Execution$$anonfun$execute$2.apply(
Execution.scala:73)
at org.specs2.specification.core.Execution$$anonfun$execute$2.apply(
Execution.scala:72)
at scala.Option.fold(Option.scala:158)
at org.specs2.specification.core.Execution.execute(Execution.scala:72)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$executeFragment$1$$anonfun$apply$15.apply(Executor.
scala:146)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$executeFragment$1$$anonfun$apply$15.apply(Executor.
scala:144)
at org.specs2.specification.core.Fragment.updateExecution(Fragment.scala
:49)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$executeFragment$1.apply(Executor.scala:144)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$executeFragment$1.apply(Executor.scala:143)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$sequencedExecution$1$$anonfun$9.apply(Executor.
scala:131)
at org.specs2.specification.process.
DefaultExecutor$$anonfun$sequencedExecution$1$$anonfun$9.apply(Executor.
scala:131)
at scalaz.concurrent.Task$.Try(Task.scala:386)
at org.specs2.data.Processes$$anonfun$start$1.apply(Processes.scala:96)
at org.specs2.data.Processes$$anonfun$start$1.apply(Processes.scala:96)
at scalaz.concurrent.Future$$anonfun$apply$15$$anon$4.call(Future.scala:
380)
at scalaz.concurrent.Future$$anonfun$apply$15$$anon$4.call(Future.scala:
380)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.