Class TestTransport.SwitchableLoggedBehavior<A,B>

  extended by akka.remote.transport.TestTransport.SwitchableLoggedBehavior<A,B>
All Implemented Interfaces:
Enclosing class:

public static class TestTransport.SwitchableLoggedBehavior<A,B>
extends java.lang.Object
implements scala.Function1<A,scala.concurrent.Future<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 completition 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.

Constructor Summary
TestTransport.SwitchableLoggedBehavior(scala.Function1<A,scala.concurrent.Future<B>> defaultBehavior, scala.Function1<A,scala.runtime.BoxedUnit> logCallback)
Method Summary
 scala.concurrent.Future<B> apply(A params)
          Applies the current behavior, and invokes the callback.
 void pop()
          Restores the previous behavior.
 void push(scala.Function1<A,scala.concurrent.Future<B>> behavior)
          Changes the current behavior to the provided one.
 void pushConstant(B c)
          Changes the behavior to return a completed future with the given constant value.
 scala.concurrent.Promise<scala.runtime.BoxedUnit> pushDelayed()
          Enables control of the completion of the previously active behavior.
 void pushError(java.lang.Throwable e)
          Changes the current behavior to return a failed future containing the given Throwable.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface scala.Function1
andThen, andThen$mcDD$sp, andThen$mcDF$sp, andThen$mcDI$sp, andThen$mcDJ$sp, andThen$mcFD$sp, andThen$mcFF$sp, andThen$mcFI$sp, andThen$mcFJ$sp, andThen$mcID$sp, andThen$mcIF$sp, andThen$mcII$sp, andThen$mcIJ$sp, andThen$mcJD$sp, andThen$mcJF$sp, andThen$mcJI$sp, andThen$mcJJ$sp, andThen$mcVD$sp, andThen$mcVF$sp, andThen$mcVI$sp, andThen$mcVJ$sp, andThen$mcZD$sp, andThen$mcZF$sp, andThen$mcZI$sp, andThen$mcZJ$sp, apply$mcDD$sp, apply$mcDF$sp, apply$mcDI$sp, apply$mcDJ$sp, apply$mcFD$sp, apply$mcFF$sp, apply$mcFI$sp, apply$mcFJ$sp, apply$mcID$sp, apply$mcIF$sp, apply$mcII$sp, apply$mcIJ$sp, apply$mcJD$sp, apply$mcJF$sp, apply$mcJI$sp, apply$mcJJ$sp, apply$mcVD$sp, apply$mcVF$sp, apply$mcVI$sp, apply$mcVJ$sp, apply$mcZD$sp, apply$mcZF$sp, apply$mcZI$sp, apply$mcZJ$sp, compose, compose$mcDD$sp, compose$mcDF$sp, compose$mcDI$sp, compose$mcDJ$sp, compose$mcFD$sp, compose$mcFF$sp, compose$mcFI$sp, compose$mcFJ$sp, compose$mcID$sp, compose$mcIF$sp, compose$mcII$sp, compose$mcIJ$sp, compose$mcJD$sp, compose$mcJF$sp, compose$mcJI$sp, compose$mcJJ$sp, compose$mcVD$sp, compose$mcVF$sp, compose$mcVI$sp, compose$mcVJ$sp, compose$mcZD$sp, compose$mcZF$sp, compose$mcZI$sp, compose$mcZJ$sp, toString

Constructor Detail


public TestTransport.SwitchableLoggedBehavior(scala.Function1<A,scala.concurrent.Future<B>> defaultBehavior,
                                              scala.Function1<A,scala.runtime.BoxedUnit> logCallback)
Method Detail


public void push(scala.Function1<A,scala.concurrent.Future<B>> behavior)
Changes the current behavior to the provided one.

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


public void pushConstant(B c)
Changes the behavior to return a completed future with the given constant value.

c - The constant the future will be completed with.


public void pushError(java.lang.Throwable e)
Changes the current behavior to return a failed future containing the given Throwable.

e - The throwable the failed future will contain.


public scala.concurrent.Promise<scala.runtime.BoxedUnit> pushDelayed()
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.

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


public void pop()
Restores the previous behavior.


public scala.concurrent.Future<B> apply(A params)
Applies the current behavior, and invokes the callback.

Specified by:
apply in interface scala.Function1<A,scala.concurrent.Future<B>>
params - The parameters of this behavior.
The result of this behavior wrapped in a future.