SwitchableLoggedBehavior

org.apache.pekko.remote.transport.TestTransport.SwitchableLoggedBehavior
class SwitchableLoggedBehavior[A, B](defaultBehavior: A => B, logCallback: A => Unit) extends A => B

Test utility to make behavior of functions that return some Future[B] controllable from tests. This tool is able to overwrite default behavior with any generic behavior, including failure, and exposes control to the timing of the completion of the returned future.

The utility is implemented as a stack of behaviors, where the behavior on the top of the stack represents the currently active behavior. The bottom of the stack always contains the defaultBehavior which can not be popped out.

Value parameters

defaultBehavior

The original behavior that might be overwritten. It is always possible to restore this behavior

logCallback

Function that will be called independently of the current active behavior type parameter A:

  • Parameter type of the wrapped function. If it takes multiple parameters it must be wrapped in a tuple. type parameter B:
  • Type parameter of the future that the original function returns.

Attributes

Source
TestTransport.scala
Graph
Supertypes
trait A => Future[B]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply(params: A): Future[B]

Applies the current behavior, and invokes the callback.

Applies the current behavior, and invokes the callback.

Value parameters

params

The parameters of this behavior.

Attributes

Returns

The result of this behavior wrapped in a future.

Source
TestTransport.scala
def pop(): Unit

Restores the previous behavior.

Restores the previous behavior.

Attributes

Source
TestTransport.scala
def push(behavior: A => B): Unit

Changes the current behavior to the provided one.

Changes the current behavior to the provided one.

Value parameters

behavior

Function that takes a parameter type A and returns a Future[B].

Attributes

Source
TestTransport.scala
def pushConstant(c: B): Unit

Changes the behavior to return a completed future with the given constant value.

Changes the behavior to return a completed future with the given constant value.

Value parameters

c

The constant the future will be completed with.

Attributes

Source
TestTransport.scala

Enables control of the completion of the previously active behavior. Wraps the previous behavior in a new one, returns a control promise that starts the original behavior after the control promise is completed.

Enables control of the completion of the previously active behavior. Wraps the previous behavior in a new one, returns a control promise that starts the original behavior after the control promise is completed.

Attributes

Returns

A promise, which delays the completion of the original future until after this promise is completed.

Source
TestTransport.scala

Changes the current behavior to return a failed future containing the given Throwable.

Changes the current behavior to return a failed future containing the given Throwable.

Value parameters

e

The throwable the failed future will contain.

Attributes

Source
TestTransport.scala

Inherited methods

def andThen[A](g: (Future[B]) => A): A => A

Attributes

Inherited from:
Function1
def compose[A](g: A => A): A => Future[B]

Attributes

Inherited from:
Function1
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
Function1 -> Any
Inherited from:
Function1