Looking at the github repo, there is a receive while usage example here 
<https://github.com/akka/akka/blob/master/akka-docs/rst/java/code/docs/testkit/TestKitDocTest.java#L117:L155>
.

I believe you can consider the JavaTestKit class to be your test probe. You 
can instantiate it and assign it to a variable, which you can then call 
getRef() in order to send messages to it later on.

>From the example, it seems that you need to setup your receive while 
conditions in a double brace initialization block 
<http://stackoverflow.com/questions/1958636/what-is-double-brace-initialization-in-java>.
 
So you need to bear this in mind before initializing the test kit.

I hope this helps!

On Tuesday, 6 December 2016 18:10:34 UTC, Allan Brighton wrote:
>
> In the Akka Scala API you can call receiveWhile to receive messages sent 
> to a TestProbe:
>
> val msgs = testProbe.receiveWhile(5.seconds) {
>   case x *=> ...*
>
> } 
>
> In the Java API you can do something similar, but I could not find a way 
> to use ReceiveWhile with a TestProbe:
>
> final CurrentState[] msgs =
>   new ReceiveWhile<CurrentState>(CurrentState.class, duration("5 seconds")) {
>     protected CurrentState match(Object in) {
>       if (in instanceof CurrentState) {
>         CurrentState cs = (CurrentState) in;
>
>         // ...
>         return cs;
>       }
>       throw noMatch();
>     }
>   }.get(); // this extracts the received messages
>
>
> Is there a way to do this in the Java API where the messages are sent to a 
> TestProbe?
>
>
>

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to