Skip to content

Commit

Permalink
Updated MQTT5 connection test to verify all optional feature properti…
Browse files Browse the repository at this point in the history
…es are set (#881)
  • Loading branch information
andsel authored Dec 13, 2024
1 parent c555c19 commit bca368b
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.moquette.integration.mqtt5;

import io.moquette.BrokerConstants;
import io.moquette.broker.config.FluentConfig;
import io.moquette.broker.config.IConfig;
import io.moquette.testclient.Client;
import io.netty.handler.codec.mqtt.MqttConnAckMessage;
import io.netty.handler.codec.mqtt.MqttConnectReturnCode;
Expand All @@ -18,6 +20,7 @@

class ConnectAckTest extends AbstractServerIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(ConnectAckTest.class);
public static final int EXPECTED_TOPIC_ALIAS_MX = 7;
private MqttConnAckMessage connAck;

@Override
Expand All @@ -28,6 +31,19 @@ public String clientName() {
@BeforeEach
public void setUp() throws Exception {
super.setUp();
stopServer();
IConfig config = new FluentConfig()
.dataPath(dbPath)
.enablePersistence()
.port(1883)
.disableTelemetry()
.persistentQueueType(FluentConfig.PersistentQueueType.SEGMENTED)
.topicAliasMaximum(EXPECTED_TOPIC_ALIAS_MX)
.build();
startServer(config);

// Reconnect the TCP
lowLevelClient = new Client("localhost").clientId(clientName());

connAck = lowLevelClient.connectV5();
assertEquals(MqttConnectReturnCode.CONNECTION_ACCEPTED, connAck.variableHeader().connectReturnCode(), "Client connected");
Expand All @@ -48,7 +64,7 @@ public void testAckResponseProperties() {
verifyNotSet(MqttPropertyType.MAXIMUM_QOS, ackProps, "Maximum QoS is not set => QoS 2 ready");
verifyProperty(MqttPropertyType.RETAIN_AVAILABLE, ackProps, 1, "Retain feature is available");
verifyNotSet(MqttPropertyType.MAXIMUM_PACKET_SIZE, ackProps, "Maximum packet size is the one defined by specs");
verifyProperty(MqttPropertyType.TOPIC_ALIAS_MAXIMUM, ackProps, 0, "No topic alias available");
verifyProperty(MqttPropertyType.TOPIC_ALIAS_MAXIMUM, ackProps, EXPECTED_TOPIC_ALIAS_MX, "Topic alias is available");
verifyProperty(MqttPropertyType.WILDCARD_SUBSCRIPTION_AVAILABLE, ackProps, 1, "Wildcard subscription feature is available");
verifyProperty(MqttPropertyType.SUBSCRIPTION_IDENTIFIER_AVAILABLE, ackProps, 1, "Subscription feature is available");
verifyProperty(MqttPropertyType.SHARED_SUBSCRIPTION_AVAILABLE, ackProps, 1, "Shared subscription feature is available");
Expand Down

0 comments on commit bca368b

Please sign in to comment.