Skip to content

Commit

Permalink
added sendForward test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmrolfs committed Oct 11, 2014
1 parent e4ab709 commit 50aad7c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions akka/src/test/scala/peds/akka/envelope/EnvelopeSendingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class TestActor( target: ActorRef ) extends EnvelopingActor with ActorLogging {
override def receive: Receive = bare orElse around( wrapped )

def bare: Receive = { case Envelope( "INITIAL", h ) => target ! Envelope( "REPLY", h ) }
def wrapped: Receive = { case "ACTOR" => target send "REPLY" }
def wrapped: Receive = {
case "ACTOR" => target send "REPLY"
case "FORWARD" => target sendForward "REPLY"
}

override def unhandled( message: Any ): Unit = target ! TestActor.Unhandled( message )
}
Expand Down Expand Up @@ -50,9 +53,10 @@ with ImplicitSender
import peds.commons.util._

test( "EnvelopeSending should wrap a message with an envelope with unknown from non-actor" ) {
source send "INITIAL"
source.send( "INITIAL" )( probe.ref )
target.expectMsgPF( max = d, hint = "initial send" ) {
case Envelope( "REPLY", h ) => {
assert( target.sender() == source )
assert( h.fromComponentType == ComponentType.unknown )
assert( h.fromComponentPath == ComponentPath.unknown )
assert( h.toComponentPath == ComponentPath( source.path ) )
Expand All @@ -66,9 +70,27 @@ with ImplicitSender
}

test( "EnvelopeSending should wrap a message with an envelope with source from actor" ) {
source send "ACTOR"
source.send( "ACTOR" )( probe.ref )
target.expectMsgPF( max = d, hint = "actor send" ) {
case Envelope( "REPLY", h ) => {
assert( target.sender() == source )
assert( h.fromComponentType == ComponentType( classOf[TestActor].safeSimpleName ) )
assert( h.fromComponentPath == ComponentPath( source.path ) )
assert( h.toComponentPath == ComponentPath( target.ref.path ) )
assert( h.messageType == MessageType( classOf[String].safeSimpleName ) )
assert( h.workId != WorkId.unknown )
assert( h.messageNumber == MessageNumber( 1 ) )
assert( h.version == EnvelopeVersion( 1 ) )
assert( h.properties == Map.empty )
}
}
}

test( "EnvelopeSending should wrap a forwarded message with an envelope with source from actor" ) {
source.send( "FORWARD" )( probe.ref )
target.expectMsgPF( max = d, hint = "actor send" ) {
case Envelope( "REPLY", h ) => {
assert( target.sender() == probe.ref )
assert( h.fromComponentType == ComponentType( classOf[TestActor].safeSimpleName ) )
assert( h.fromComponentPath == ComponentPath( source.path ) )
assert( h.toComponentPath == ComponentPath( target.ref.path ) )
Expand Down

0 comments on commit 50aad7c

Please sign in to comment.