Added topic + sign parsing for single level wildcard
This commit is contained in:
+5
-1
@@ -96,7 +96,11 @@ public class SubscriptionsStore {
|
|||||||
res.add(Token.MULTI);
|
res.add(Token.MULTI);
|
||||||
} else if (s.contains("#")) {
|
} else if (s.contains("#")) {
|
||||||
throw new ParseException("Bad format of topic, invalid subtopic name: " + s, i);
|
throw new ParseException("Bad format of topic, invalid subtopic name: " + s, i);
|
||||||
}else {
|
} else if (s.equals("+")) {
|
||||||
|
res.add(Token.SINGLE);
|
||||||
|
} else if (s.contains("+")) {
|
||||||
|
throw new ParseException("Bad format of topic, invalid subtopic name: " + s, i);
|
||||||
|
} else {
|
||||||
res.add(new Token(s));
|
res.add(new Token(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -59,6 +59,25 @@ public class SubscriptionsStoreTest {
|
|||||||
store.splitTopic("finance#");
|
store.splitTopic("finance#");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSplitTopicSingleValid() throws ParseException {
|
||||||
|
List tokens = store.splitTopic("finance/stock/+");
|
||||||
|
assertEqualsSeq(asArray("finance", "stock", Token.SINGLE), tokens);
|
||||||
|
|
||||||
|
tokens = store.splitTopic("+");
|
||||||
|
assertEqualsSeq(asArray(Token.SINGLE), tokens);
|
||||||
|
|
||||||
|
tokens = store.splitTopic("finance/+/ibm");
|
||||||
|
assertEqualsSeq(asArray("finance", Token.SINGLE, "ibm"), tokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = ParseException.class)
|
||||||
|
public void testSplitTopicSingleNotAferSeparatorNotValid() throws ParseException {
|
||||||
|
store.splitTopic("finance+");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Token[] asArray(Object... l) {
|
private static Token[] asArray(Object... l) {
|
||||||
Token[] tokens = new Token[l.length];
|
Token[] tokens = new Token[l.length];
|
||||||
for (int i = 0; i < l.length; i++) {
|
for (int i = 0; i < l.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user