akka.testkit
Class JavaTestKit.ExpectMsg<T>

java.lang.Object
  extended by akka.testkit.JavaTestKit.ExpectMsg<T>
Enclosing class:
JavaTestKit

public abstract class JavaTestKit.ExpectMsg<T>
extends java.lang.Object

Receive one message from the test actor and assert that the given matching function accepts it. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

The received object as transformed by the matching function can be retrieved with the get method. Use this variant to implement more complicated or conditional processing.

 
 final String out = new ExpectMsg("match hint") {
   protected String match(Object in) {
     if (in instanceof Integer)
       return "match";
     else
       throw noMatch();
   }
 }.get(); // this extracts the received message
 
 


Constructor Summary
JavaTestKit.ExpectMsg(scala.concurrent.duration.Duration max, java.lang.String hint)
           
JavaTestKit.ExpectMsg(java.lang.String hint)
           
 
Method Summary
 T get()
           
protected abstract  T match(java.lang.Object msg)
           
protected  java.lang.RuntimeException noMatch()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaTestKit.ExpectMsg

public JavaTestKit.ExpectMsg(java.lang.String hint)

JavaTestKit.ExpectMsg

public JavaTestKit.ExpectMsg(scala.concurrent.duration.Duration max,
                             java.lang.String hint)
Method Detail

match

protected abstract T match(java.lang.Object msg)

noMatch

protected java.lang.RuntimeException noMatch()

get

public T get()