private void internalPublishNotRetainedTo(String topic) { internalPublishTo(topic, AT_MOST_ONCE, false); }
private void internalPublishRetainedTo(String topic) { internalPublishTo(topic, AT_MOST_ONCE, true); }
@Test public void testClientSubscribeBeforeRetainedQoS1IsSent() { subscribe(AT_LEAST_ONCE, "/topic", connection); // Exercise internalPublishTo("/topic", AT_LEAST_ONCE, true); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, AT_LEAST_ONCE, PAYLOAD); }
@Test public void testClientSubscribeBeforeNotRetainedQoS2IsSent() { subscribe(EXACTLY_ONCE, "/topic", connection); // Exercise internalPublishTo("/topic", EXACTLY_ONCE, false); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, EXACTLY_ONCE, PAYLOAD); }
@Test public void testClientSubscribeBeforeRetainedQoS2IsSent() { subscribe(EXACTLY_ONCE, "/topic", connection); // Exercise internalPublishTo("/topic", EXACTLY_ONCE, true); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, EXACTLY_ONCE, PAYLOAD); }
@Test public void testClientSubscribeAfterRetainedQoS2IsSent() { // Exercise internalPublishTo("/topic", EXACTLY_ONCE, true); subscribe(EXACTLY_ONCE, "/topic", connection); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, EXACTLY_ONCE, PAYLOAD); }
@Test public void testClientSubscribeBeforeNotRetainedQoS1IsSent() { subscribe(AT_LEAST_ONCE, "/topic", connection); // Exercise internalPublishTo("/topic", AT_LEAST_ONCE, false); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, AT_LEAST_ONCE, PAYLOAD); }
@Test public void testClientSubscribeAfterNotRetainedQoS1IsSent() { // Exercise internalPublishTo("/topic", AT_LEAST_ONCE, false); subscribe(AT_LEAST_ONCE, "/topic", connection); // Verify verifyNoPublishIsReceived(channel); }
@Test public void testClientSubscribeAfterRetainedQoS1IsSent() { // Exercise internalPublishTo("/topic", AT_LEAST_ONCE, true); subscribe(AT_LEAST_ONCE, "/topic", connection); // Verify ConnectionTestUtils.verifyPublishIsReceived(channel, AT_LEAST_ONCE, PAYLOAD); }
@Test public void testClientSubscribeAfterNotRetainedQoS2IsSent() { // Exercise internalPublishTo("/topic", EXACTLY_ONCE, false); subscribe(EXACTLY_ONCE, "/topic", connection); // Verify verifyNoPublishIsReceived(channel); }
@Test public void testClientSubscribeAfterDisconnected() { subscribe(AT_MOST_ONCE, "foo", connection); connection.processDisconnect(null); internalPublishTo("foo", AT_MOST_ONCE, false); verifyNoPublishIsReceived(channel); }
@Test public void testClientSubscribeWithoutCleanSession() { subscribe(AT_MOST_ONCE, "foo", connection); connection.processDisconnect(null); assertEquals(1, subscriptions.size()); MQTTConnection anotherConn = createMQTTConnection(CONFIG); MqttConnectMessage connectMessage = MqttMessageBuilders.connect() .clientId(FAKE_CLIENT_ID) .cleanSession(false) .build(); anotherConn.processConnect(connectMessage); ConnectionTestUtils.assertConnectAccepted((EmbeddedChannel) anotherConn.channel); assertEquals(1, subscriptions.size()); internalPublishTo("foo", MqttQoS.AT_MOST_ONCE, false); ConnectionTestUtils.verifyPublishIsReceived((EmbeddedChannel) anotherConn.channel, AT_MOST_ONCE, PAYLOAD); }