@Test
public void testConsume() throws Exception {
MQTT mqtt = new MQTT();
BlockingConnection publisherConnection = mqtt.blockingConnection();
Topic topic = new Topic(TEST_TOPIC, QoS.AT_MOST_ONCE);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(numberOfMessages);
publisherConnection.connect();
for (int i = 0; i < numberOfMessages; i++) {
String payload = "Message " + i;
publisherConnection.publish(topic.name().toString(), payload.getBytes(), QoS.AT_LEAST_ONCE, false);
}
mock.await(5, TimeUnit.SECONDS);
mock.assertIsSatisfied();
}