Module org.snmp4j

Class DummyTransport<A extends IpAddress>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, TransportMapping<A>

    public class DummyTransport<A extends IpAddress>
    extends AbstractTransportMapping<A>
    The DummyTransport is a test TransportMapping for Command Generators which actually does not sent messages over the network. Instead it provides the message transparently as incoming message over the DummyTransport.DummyTransportResponder on a virtual listen address, regardless to which outbound address the message was sent. The messages are returned even if the listenAddress is left null.
    Since:
    2.0
    Author:
    Frank Fock
    • Constructor Detail

      • DummyTransport

        public DummyTransport()
      • DummyTransport

        public DummyTransport​(A senderAddress)
      • DummyTransport

        public DummyTransport​(A senderAddress,
                              A receiverAddress)
    • Method Detail

      • getListenAddress

        public A getListenAddress()
        Description copied from interface: TransportMapping
        Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.
        Returns:
        the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.
      • setListenAddress

        public void setListenAddress​(A listenAddress)
      • sendMessage

        public void sendMessage​(A address,
                                byte[] message,
                                TransportStateReference tmStateReference,
                                long timeoutMillis,
                                int retries)
                         throws java.io.IOException
        Description copied from interface: TransportMapping
        Sends a message to the supplied address using this transport.
        Specified by:
        sendMessage in interface TransportMapping<A extends IpAddress>
        Specified by:
        sendMessage in class AbstractTransportMapping<A extends IpAddress>
        Parameters:
        address - an Address instance denoting the target address.
        message - the whole message as an array of bytes.
        tmStateReference - the (optional) transport model state reference as defined by RFC 5590 section 6.1.
        timeoutMillis - maximum number of milli seconds the connection creation might take (if connection based).
        retries - maximum retries during connection creation.
        Throws:
        java.io.IOException - if any underlying IO operation fails.
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: TransportMapping
        Closes the transport an releases all bound resources synchronously.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface TransportMapping<A extends IpAddress>
        Specified by:
        close in class AbstractTransportMapping<A extends IpAddress>
        Throws:
        java.io.IOException - if any IO operation for the close fails.
      • isListening

        public boolean isListening()
        Description copied from interface: TransportMapping
        Returns true if the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.
        Returns:
        true if this transport mapping is listening for messages.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object