Package akka.testkit

Class 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<String>("match hint") {
       protected String match(Object in) {
         if (in instanceof Integer)
           return "match";
         else
           throw noMatch();
       }
     }.get(); // this extracts the received message
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      ExpectMsg​(java.lang.String hint)  
      ExpectMsg​(scala.concurrent.duration.Duration max, java.lang.String hint)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      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

      • ExpectMsg

        public ExpectMsg​(java.lang.String hint)
      • ExpectMsg

        public 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()