Class TestTransport.AssociationRegistry

  • Enclosing class:

    public static class TestTransport.AssociationRegistry
    extends java.lang.Object
    Shared state among TestTransport instances. Coordinates the transports and the means of communication between them.
    • Constructor Detail

      • AssociationRegistry

        public AssociationRegistry()
    • Method Detail

      • clearLog

        public void clearLog()
        Clears the activity log.
      • existsAssociation

        public boolean existsAssociation​(Address initiatorAddress,
                                         Address remoteAddress)
        Tests if an association was registered.

        initiatorAddress - The initiator of the association.
        remoteAddress - The other address of the association.

        True if there is an association for the given addresses.
      • getRemoteReadHandlerFor

        public scala.Option<AssociationHandle.HandleEventListener> getRemoteReadHandlerFor​(TestAssociationHandle localHandle)
        Returns the event handler corresponding to the remote endpoint of the given local handle. In other words it returns the listener that will receive InboundPayload events when
        is called on the given handle. @param localHandle The handle @return The option that contains the Future for the listener if exists.
      • logActivity

        public void logActivity​(TestTransport.Activity activity)
        Logs a transport activity.

        activity - Activity to be logged.
      • logSnapshot

        public scala.collection.immutable.Seq<TestTransport.Activity> logSnapshot()
        Takes a thread-safe snapshot of the current state of the activity log.

        Collection containing activities ordered left-to-right according to time (first element is earliest).
      • registerListenerPair

        public void registerListenerPair​(scala.Tuple2<Address,​Address> key,
                                         scala.Tuple2<AssociationHandle.HandleEventListener,​AssociationHandle.HandleEventListener> listeners)
        Registers a Future of two handle event listeners corresponding to the two endpoints of an association.

        key - Ordered pair of addresses representing an association. First element must be the address of the initiator.
        listeners - The future containing the listeners that will be responsible for handling the events of the two endpoints of the association. Elements in the pair must be in the same order as the addresses in the key parameter.
      • registerTransport

        public void registerTransport​(TestTransport transport,
                                      scala.concurrent.Future<Transport.AssociationEventListener> associationEventListenerFuture)
        Records a mapping between an address and the corresponding (transport, associationEventListener) pair.

        transport - The transport that is to be registered. The address of this transport will be used as key.
        associationEventListenerFuture - The future that will be completed with the listener that will handle the events for the given transport.
      • reset

        public void reset()
        Resets the state of the registry. ''Warning!'' This method is not atomic.
      • transportFor

        public scala.Option<scala.Tuple2<TestTransport,​scala.concurrent.Future<Transport.AssociationEventListener>>> transportFor​(Address address)
        Returns the Transport bound to the given address.

        address - The address bound to the transport.
        The transport if exists.
      • transportsReady

        public boolean transportsReady​(scala.collection.immutable.Seq<Address> addresses)
        Indicates if all given transports were successfully registered. No associations can be established between transports that are not yet registered.

        addresses - The listen addresses of transports that participate in the test case.
        True if all transports are successfully registered.