Fixed Issue #43
This commit is contained in:
+12
-4
@@ -249,9 +249,9 @@ public class SubscriptionsStore {
|
||||
}
|
||||
}
|
||||
//if last token was a SINGLE then treat it as an empty
|
||||
if (subToken == Token.SINGLE && (i - msgTokens.size() == 1)) {
|
||||
i--;
|
||||
}
|
||||
// if (subToken == Token.SINGLE && (i - msgTokens.size() == 1)) {
|
||||
// i--;
|
||||
// }
|
||||
return i == msgTokens.size();
|
||||
} catch (ParseException ex) {
|
||||
LOG.error(null, ex);
|
||||
@@ -266,7 +266,15 @@ public class SubscriptionsStore {
|
||||
if (splitted.length == 0) {
|
||||
res.add(Token.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
if (topic.endsWith("/")) {
|
||||
//Add a fictious space
|
||||
String[] newSplitted = new String[splitted.length + 1];
|
||||
System.arraycopy(splitted, 0, newSplitted, 0, splitted.length);
|
||||
newSplitted[splitted.length] = "";
|
||||
splitted = newSplitted;
|
||||
}
|
||||
|
||||
for (int i = 0; i < splitted.length; i++) {
|
||||
String s = splitted[i];
|
||||
if (s.isEmpty()) {
|
||||
|
||||
+3
-1
@@ -59,7 +59,7 @@ public class SubscriptionsStoreTest {
|
||||
assertEqualsSeq(asArray(Token.EMPTY, "finance", "stock", "ibm"), tokens);
|
||||
|
||||
tokens = store.splitTopic("/");
|
||||
assertEqualsSeq(asArray(Token.EMPTY), tokens);
|
||||
assertEqualsSeq(asArray(Token.EMPTY, Token.EMPTY), tokens);
|
||||
}
|
||||
|
||||
// @Test(expected = ParseException.class)
|
||||
@@ -295,10 +295,12 @@ public class SubscriptionsStoreTest {
|
||||
public void testMatchTopics_single() {
|
||||
assertTrue(SubscriptionsStore.matchTopics("finance", "+"));
|
||||
assertTrue(SubscriptionsStore.matchTopics("finance/stock", "finance/+"));
|
||||
assertFalse(SubscriptionsStore.matchTopics("finance", "finance/+"));
|
||||
assertTrue(SubscriptionsStore.matchTopics("/finance", "/+"));
|
||||
assertFalse(SubscriptionsStore.matchTopics("/finance", "+"));
|
||||
assertTrue(SubscriptionsStore.matchTopics("/finance", "+/+"));
|
||||
assertTrue(SubscriptionsStore.matchTopics("/finance/stock/ibm", "/finance/+/ibm"));
|
||||
assertTrue(SubscriptionsStore.matchTopics("/", "+/+"));
|
||||
assertFalse(SubscriptionsStore.matchTopics("/finance/stock", "+"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user