Package com.framed.core.remote
Class MockTransport
java.lang.Object
com.framed.core.remote.MockTransport
- All Implemented Interfaces:
Transport
A mock implementation of the
Transport interface for testing purposes.
This class simulates message sending and publishing without actual network communication. It stores sent messages in memory and immediately dispatches them to registered handlers.
Features:
- Simulates
send(String, int, String, Object)andpublish(String, int, String, Object)calls. - Maintains a list of sent messages for verification in tests.
- Supports handler registration and immediate message dispatch.
- No-op lifecycle methods
start()andshutdown().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of sent and published messages for verification.voidSimulates publishing a message to all subscribers of the specified address.voidRegisters a handler for messages received on the specified address.voidSimulates sending a message to a specific host and port.voidshutdown()No-op for mock implementation.voidstart()No-op for mock implementation.
-
Constructor Details
-
MockTransport
public MockTransport()
-
-
Method Details
-
send
Simulates sending a message to a specific host and port. Adds the message tosentMessagesand dispatches it to registered handlers. -
publish
Simulates publishing a message to all subscribers of the specified address. Adds the message tosentMessagesand dispatches it to registered handlers. -
start
public void start()No-op for mock implementation. -
shutdown
public void shutdown()No-op for mock implementation. -
register
Registers a handler for messages received on the specified address. -
getSentMessages
Returns the list of sent and published messages for verification.- Returns:
- a list of message logs in the format "SEND:address:message" or "PUBLISH:address:message"
-