-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix subscription identifier out of bounds of mqtt5 specification
Signed-off-by: Gary Tse <[email protected]>
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ient.test/src/test/java/org/eclipse/paho/mqttv5/client/internal/MqttSessionStateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.eclipse.paho.mqttv5.client.internal; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class MqttSessionStateTest { | ||
|
||
@Test | ||
public void testClearSessionState() { | ||
MqttSessionState state = new MqttSessionState(); | ||
state.clearSessionState(); | ||
assertTrue("Clear session state resets subscription identifier", 1 == state.getNextSubscriptionIdentifier()); | ||
} | ||
|
||
/** | ||
* Test that the subscription identifier is bounded between 1 and 268,435,455 | ||
*/ | ||
@Test | ||
public void testSubscriptionIdIsBounded() { | ||
MqttSessionState state = new MqttSessionState(); | ||
for (int i = 1; i <= 268_435_456; i++) { | ||
assertTrue("Subscription identifier minimum bound", state.getNextSubscriptionIdentifier()>=1); | ||
assertTrue("Subscription identifier maximum bound", state.getNextSubscriptionIdentifier()<=268_435_455); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters