Added first implementation for topic tree subscriptions.
This commit is contained in:
+22
@@ -4,6 +4,7 @@ import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.dna.mqtt.moquette.messaging.spi.impl.SubscriptionsStore.Token;
|
||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -31,6 +32,9 @@ public class SubscriptionsStoreTest {
|
||||
|
||||
tokens = store.splitTopic("/finance/stock/ibm");
|
||||
assertEqualsSeq(asArray(Token.EMPTY, "finance", "stock", "ibm"), tokens);
|
||||
|
||||
tokens = store.splitTopic("/");
|
||||
assertEqualsSeq(asArray(Token.EMPTY), tokens);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +81,24 @@ public class SubscriptionsStoreTest {
|
||||
store.splitTopic("finance+");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchSimple() {
|
||||
store.add(new Subscription(null, "/", AbstractMessage.QOSType.MOST_ONE));
|
||||
assertTrue(store.matches("finance").isEmpty());
|
||||
|
||||
store.add(new Subscription(null, "/finance", AbstractMessage.QOSType.MOST_ONE));
|
||||
assertTrue(store.matches("finance").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchSimpleMulti() {
|
||||
store.add(new Subscription(null, "#", AbstractMessage.QOSType.MOST_ONE));
|
||||
assertFalse(store.matches("finance").isEmpty());
|
||||
|
||||
store.add(new Subscription(null, "finance/#", AbstractMessage.QOSType.MOST_ONE));
|
||||
assertFalse(store.matches("finance").isEmpty());
|
||||
}
|
||||
|
||||
|
||||
private static Token[] asArray(Object... l) {
|
||||
Token[] tokens = new Token[l.length];
|
||||
|
||||
Reference in New Issue
Block a user