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