|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xenqtt.mockbroker.MockBroker
public final class MockBroker
Mock MQTT broker used to test MQTT clients and applications. If debug level logging is enabled all broker events will be logged.
Constructor Summary | |
---|---|
MockBroker()
Creates a broker with the following config: no MockBrokerHandler
15 second message resend interval
port 1883
allows anonymous access
captures broker events
allows 50 in-flight messages
|
|
MockBroker(MockBrokerHandler brokerHandler,
long messageResendIntervalSeconds,
int port,
boolean allowAnonymousAccess,
boolean captureBrokerEvents,
int maxInFlightMessages)
|
Method Summary | |
---|---|
void |
addCredentials(String userName,
String password)
Adds the specified credentials for authentication by ConnectMessage s. |
void |
clearEvents()
Removes all broker events |
List<BrokerEvent> |
getEvents()
|
List<BrokerEvent> |
getEvents(String clientId)
|
int |
getPort()
|
void |
init()
Starts the mock broker |
void |
removeEvents(Collection<BrokerEvent> eventsToRemove)
Removes the specified broker events. |
boolean |
shutdown(long millis)
Shuts down the mock broker |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockBroker()
MockBrokerHandler
public MockBroker(MockBrokerHandler brokerHandler, long messageResendIntervalSeconds, int port, boolean allowAnonymousAccess, boolean captureBrokerEvents, int maxInFlightMessages)
brokerHandler
- Called when events happen. Can be null
if you don't need to do any custom message handling.messageResendIntervalSeconds
- Seconds between attempts to resend a message that is MqttMessage.isAckable()
. 0 to disable message resends.port
- The port for the server to listen on. 0 will choose an arbitrary available port which you can get from getPort()
after
calling init()
.allowAnonymousAccess
- If true then ConnectMessage
with no username/password will be accepted. Otherwise only valid credentials will be accepted.captureBrokerEvents
- If true
then capture all events within the broker; otherwise, do not capture any eventsmaxInFlightMessages
- Maximum number of concurrent publish messages the broker will have in-flight to the client. This is an approximation. The actual maximum
number of in-flight messages may vary slightly.Method Detail |
---|
public void init()
public boolean shutdown(long millis)
millis
- Milliseconds to wait for shutdown to complete. 0 means to wait forever.
public void addCredentials(String userName, String password)
ConnectMessage
s. If password is null
any existing credentials for the user are
removed.
public int getPort()
init()
is called.public List<BrokerEvent> getEvents()
public List<BrokerEvent> getEvents(String clientId)
public void clearEvents()
public void removeEvents(Collection<BrokerEvent> eventsToRemove)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |