TestActorRef

org.apache.pekko.testkit.TestActorRef
See theTestActorRef companion object
class TestActorRef[T <: Actor](_system: ActorSystem, _props: Props, _supervisor: ActorRef, name: String)

This special ActorRef is exclusively for use during unit testing in a single-threaded environment. Therefore, it overrides the dispatcher to CallingThreadDispatcher and sets the receiveTimeout to None. Otherwise, it acts just like a normal ActorRef. You may retrieve a reference to the underlying actor to test internal logic.

Attributes

Since

1.1

Companion
object
Source
TestActorRef.scala
Graph
Supertypes
class ActorRef
trait Serializable
trait Comparable[ActorRef]
class Object
trait Matchable
class Any
Show all
Known subtypes
class TestFSMRef[S, D, T]

Members list

Value members

Concrete methods

def receive(o: Any): Unit

Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

Attributes

Source
TestActorRef.scala
def receive(o: Any, sender: ActorRef): Unit

Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

Attributes

Source
TestActorRef.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
ActorRef -> Any
Source
TestActorRef.scala

Retrieve reference to the underlying actor, where the static type matches the factory used inside the constructor. Beware that this reference is discarded by the ActorRef upon restarting the actor (should this reference be linked to a supervisor). The old Actor may of course still be used in post-mortem assertions.

Retrieve reference to the underlying actor, where the static type matches the factory used inside the constructor. Beware that this reference is discarded by the ActorRef upon restarting the actor (should this reference be linked to a supervisor). The old Actor may of course still be used in post-mortem assertions.

Attributes

Source
TestActorRef.scala
def unwatch(subject: ActorRef): ActorRef

Unregisters this actor from being a death monitor of the provided ActorRef This means that this actor will not get a Terminated()-message when the provided actor is permanently terminated.

Unregisters this actor from being a death monitor of the provided ActorRef This means that this actor will not get a Terminated()-message when the provided actor is permanently terminated.

Attributes

Returns

the same ActorRef that is provided to it, to allow for cleaner invocations

Source
TestActorRef.scala
def watch(subject: ActorRef): ActorRef

Registers this actor to be a death monitor of the provided ActorRef This means that this actor will get a Terminated()-message when the provided actor is permanently terminated.

Registers this actor to be a death monitor of the provided ActorRef This means that this actor will get a Terminated()-message when the provided actor is permanently terminated.

Attributes

Returns

the same ActorRef that is provided to it, to allow for cleaner invocations

Source
TestActorRef.scala

Inherited methods

override def !(message: Any)(implicit sender: ActorRef): Unit

Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

If invoked from within an actor then the actor reference is implicitly passed on as the implicit 'sender' argument.

This actor 'sender' reference is then available in the receiving actor in the 'sender()' member variable, if invoked from within an Actor. If not then no sender is available.

 actor ! message

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final def compareTo(other: ActorRef): Int

Comparison takes path and the unique id of the actor cell into account.

Comparison takes path and the unique id of the actor cell into account.

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
final override def equals(that: Any): Boolean

Equals takes path and the unique id of the actor cell into account.

Equals takes path and the unique id of the actor cell into account.

Attributes

Definition Classes
ActorRef -> Any
Inherited from:
ActorRef
Source
ActorRef.scala
def forward(message: Any)(implicit context: ActorContext): Unit

Forwards the message and passes the original sender actor as the sender.

Forwards the message and passes the original sender actor as the sender.

Works, no matter whether originally sent with tell/'!' or ask/'?'.

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
override def getChild(names: Iterator[String]): InternalActorRef

Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location. This method shall return the end result, i.e. not only the next step in the look-up; this will typically involve recursive invocation. A path element of ".." signifies the parent, a trailing "" element must be disregarded. If the requested path does not exist, return Nobody.

Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location. This method shall return the end result, i.e. not only the next step in the look-up; this will typically involve recursive invocation. A path element of ".." signifies the parent, a trailing "" element must be disregarded. If the requested path does not exist, return Nobody.

Attributes

Definition Classes
Inherited from:
l.getParent case""=> l caseany=> l.getSingleChild(any) } if(next.==(Nobody).||(name.isEmpty))nextelserec(next,name) case_=> ref.getChild(name) } if(names.isEmpty)thiselserec(this,names) }">LocalActorRef (hidden)
Source
ActorRef.scala
override def getParent: InternalActorRef

Obtain parent of this ref; used by getChild for ".." paths.

Obtain parent of this ref; used by getChild for ".." paths.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
def getSingleChild(name: String): InternalActorRef

Method for looking up a single child beneath this actor. Override in order to inject “synthetic” actor paths like “/temp”. It is racy if called from the outside.

Method for looking up a single child beneath this actor. Override in order to inject “synthetic” actor paths like “/temp”. It is racy if called from the outside.

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final override def hashCode: Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
ActorRef -> Any
Inherited from:
ActorRef
Source
ActorRef.scala
final def isLocal: Boolean

Attributes

Inherited from:
LocalRef (hidden)
Source
ActorRef.scala
override def provider: ActorRefProvider

Get a reference to the actor ref provider which created this ref.

Get a reference to the actor ref provider which created this ref.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def restart(cause: Throwable): Unit

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

Resumes a suspended actor.

Resumes a suspended actor.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def sendSystemMessage(message: SystemMessage): Unit

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def start(): Unit

Starts the actor after initialization.

Starts the actor after initialization.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def stop(): Unit

Shuts down the actor and its message queue

Shuts down the actor and its message queue

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def suspend(): Unit

Suspends the actor so that it will not process messages until resumed. The suspend request is processed asynchronously to the caller of this method as well as to normal message sends: the only ordering guarantee is that message sends done from the same thread after calling this method will not be processed until resumed.

Suspends the actor so that it will not process messages until resumed. The suspend request is processed asynchronously to the caller of this method as well as to normal message sends: the only ordering guarantee is that message sends done from the same thread after calling this method will not be processed until resumed.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final def tell(msg: Any, sender: ActorRef): Unit

Sends the specified message to this ActorRef, i.e. fire-and-forget semantics, including the sender reference if possible.

Sends the specified message to this ActorRef, i.e. fire-and-forget semantics, including the sender reference if possible.

Pass pekko.actor.ActorRef noSender or null as sender if there is nobody to reply to

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
def underlying: ActorCell

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

Concrete fields

val props: Props

Attributes

Source
TestActorRef.scala

Inherited fields

override val path: ActorPath

Returns the path for this actor (from this actor up to the root actor).

Returns the path for this actor (from this actor up to the root actor).

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala