Hi,
Correct, I upgraded the plugin from 1.0 to 2.0.1 in one go. I changed the
version to 2.0 and it does the same thing. The stacktrace is:
[info] InMemoryReadJournalTest:
[info] ReadJournal
[info] - should support currentPersistenceIds *** FAILED ***
[info] java.lang.AssertionError: `remaining` may not be called outside of
`within`
[info] at akka.testkit.TestKitBase$class.remaining(TestKit.scala:198)
[info] at akka.testkit.TestKit.remaining(TestKit.scala:735)
[info] at
akka.stream.testkit.TestSubscriber$ManualProbe.expectNext(StreamTestKit.scala:254)
[info] at
akka.stream.testkit.TestSubscriber$ManualProbe.expectOneOf$1(StreamTestKit.scala:327)
[info] at
akka.stream.testkit.TestSubscriber$ManualProbe.expectNextUnorderedN(StreamTestKit.scala:332)
[info] at
akka.stream.testkit.TestSubscriber$ManualProbe.expectNextUnordered(StreamTestKit.scala:293)
[info] at
akka.persistence.inmemory.query.InMemoryReadJournalTest$$anonfun$1.apply$mcV$sp(InMemoryReadJournalTest.scala:120)
[info] at
akka.persistence.inmemory.query.InMemoryReadJournalTest$$anonfun$1.apply(InMemoryReadJournalTest.scala:111)
[info] at
akka.persistence.inmemory.query.InMemoryReadJournalTest$$anonfun$1.apply(InMemoryReadJournalTest.scala:111)
[info] at
org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
I think the "problem" lies with StreamTestKit that on line 253 calls the
probe.remaining, and the TestProbe will throw an assertionerror when you do
that, when you have not set the end finitate duration.
/**
* Expect and return a stream element.
*/
def expectNext(): I = probe.receiveOne(probe.remaining) match {
case OnNext(elem) ⇒ elem.asInstanceOf[I]
case other ⇒ throw new AssertionError("expected OnNext, found " +
other)
}
So, we must always call StreamTestKit.await, but this breaks the nice
fluent DSL. The curried function also does not provide self (the
streamtestkit), so there is no nice reference to the instance to put
assertions on.
A way to fix this, is eg. to not call probe.remaining, but to call
probe.remainingOrDefault, which would be backwards compatible with 1.0.
I still think I am missing something here.
I will try to use gist :)
Regards,
Dennis
Op woensdag 23 december 2015 23:08:42 UTC+1 schreef Konrad Malawski:
>
> This sounds a bit weird... I don't think those changed that much in the
> move to 2.0.
> Could you make the problem example a gist (gist.github.com or complete
> snippet in email, ready to copy/paste) I could downlaod and quickly have a
> look? Thanks in advance!
>
> --
> Cheers,
> Konrad 'ktoso’ Malawski
> Akka <http://akka.io> @ Typesafe <http://typesafe.com>
>
> On 23 December 2015 at 22:44:47, Dennis Vriend ([email protected]
> <javascript:>) wrote:
>
> Hi, I have a question about akka stream. I want to migrate a project from
> akka 2.3 to 2.4.1 and akka stream 1.0 to 2.0.1 and I must now refactor
> tests. In the test an akka stream is used with the fluent like DSL in which
> one can expect messages. , an assertion error will be thrown "`remaining`
> may not be called outside of `within`"
>
> The only way I can fix this is to refactor the test so that the
> TestSubscriber will be closed over by the .within(FiniteDuration) method,
> in which the curried function can do the assertion. This is different from
> the 1.0 version of akka-stream.
>
>
> Is this the correct way to use the TestSubscriber from now on or am I
> missing something?
>
> Note: this would break the fluent chain like DSL from akka stream 1.0 in a
> big way, which would be a shame.
>
>
> Example from the 1.0 syntax:
>
>
> currentPersistenceIds(readJournal)
>
> .request(2)
>
> .expectNextUnOrdered("a", "b")
>
> .expectComplete()
>
>
> Using the code above will give the assertion error on akka stream 2.0.
>
>
> To make it work the code must be:
>
>
> val xx = currentPersistenceIds(readJournal)
>
> .request(2)
>
>
> xx.within(10.seconds) {
>
> xx.expectNextUnOrdered("a", "b")
>
> .expectComplete()
>
> }
>
>
> I am sure I am doing something wrong, can someone help me out?
>
>
> Thanks!
>
>
> Dennis
>
>
>
> --
> >>>>>>>>>> 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] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.