Removed unusefull SubscriptionsStore.clearAllSubscriptions used only in tests
This commit is contained in:
-28
@@ -90,21 +90,6 @@ public class SubscriptionsStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SubscriptionTreeCollector implements IVisitor<List<Subscription>> {
|
|
||||||
|
|
||||||
private List<Subscription> m_allSubscriptions = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visit(TreeNode node, int deep) {
|
|
||||||
m_allSubscriptions.addAll(node.subscriptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Subscription> getResult() {
|
|
||||||
return m_allSubscriptions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private AtomicReference<TreeNode> subscriptions = new AtomicReference<>(new TreeNode(null));
|
private AtomicReference<TreeNode> subscriptions = new AtomicReference<>(new TreeNode(null));
|
||||||
private ISessionsStore m_sessionsStore;
|
private ISessionsStore m_sessionsStore;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SubscriptionsStore.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SubscriptionsStore.class);
|
||||||
@@ -209,19 +194,6 @@ public class SubscriptionsStore {
|
|||||||
m_sessionsStore.removeSubscription(topic, clientID);
|
m_sessionsStore.removeSubscription(topic, clientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* It's public because needed in tests :-( bleah
|
|
||||||
*/
|
|
||||||
public void clearAllSubscriptions() {
|
|
||||||
SubscriptionTreeCollector subsCollector = new SubscriptionTreeCollector();
|
|
||||||
bfsVisit(subscriptions.get(), subsCollector, 0);
|
|
||||||
|
|
||||||
List<Subscription> allSubscriptions = subsCollector.getResult();
|
|
||||||
for (Subscription subscription : allSubscriptions) {
|
|
||||||
removeSubscription(subscription.getTopicFilter(), subscription.getClientId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit the topics tree to remove matching subscriptions with clientID.
|
* Visit the topics tree to remove matching subscriptions with clientID.
|
||||||
* It's a mutating structure operation so create a new subscription tree (partial or total).
|
* It's a mutating structure operation so create a new subscription tree (partial or total).
|
||||||
|
|||||||
@@ -216,13 +216,12 @@ public class ProtocolProcessorTest {
|
|||||||
msg.addSubscription(new SubscribeMessage.Couple(AbstractMessage.QOSType.MOST_ONE.byteValue(), FAKE_TOPIC));
|
msg.addSubscription(new SubscribeMessage.Couple(AbstractMessage.QOSType.MOST_ONE.byteValue(), FAKE_TOPIC));
|
||||||
m_session.setAttribute(NettyChannel.ATTR_KEY_CLIENTID, FAKE_CLIENT_ID);
|
m_session.setAttribute(NettyChannel.ATTR_KEY_CLIENTID, FAKE_CLIENT_ID);
|
||||||
m_session.setAttribute(NettyChannel.ATTR_KEY_CLEANSESSION, false);
|
m_session.setAttribute(NettyChannel.ATTR_KEY_CLEANSESSION, false);
|
||||||
subscriptions.clearAllSubscriptions();
|
|
||||||
assertEquals(0, subscriptions.size());
|
assertEquals(0, subscriptions.size());
|
||||||
|
|
||||||
m_processor.processSubscribe(m_session, msg/*, FAKE_CLIENT_ID, false*/);
|
m_processor.processSubscribe(m_session, msg);
|
||||||
|
|
||||||
//Exercise
|
//Exercise
|
||||||
m_processor.processSubscribe(m_session, msg/*, FAKE_CLIENT_ID, false*/);
|
m_processor.processSubscribe(m_session, msg);
|
||||||
|
|
||||||
//Verify
|
//Verify
|
||||||
assertEquals(1, subscriptions.size());
|
assertEquals(1, subscriptions.size());
|
||||||
@@ -237,7 +236,6 @@ public class ProtocolProcessorTest {
|
|||||||
msg.addSubscription(new SubscribeMessage.Couple(AbstractMessage.QOSType.MOST_ONE.byteValue(), BAD_FORMATTED_TOPIC));
|
msg.addSubscription(new SubscribeMessage.Couple(AbstractMessage.QOSType.MOST_ONE.byteValue(), BAD_FORMATTED_TOPIC));
|
||||||
m_session.setAttribute(NettyChannel.ATTR_KEY_CLIENTID, FAKE_CLIENT_ID);
|
m_session.setAttribute(NettyChannel.ATTR_KEY_CLIENTID, FAKE_CLIENT_ID);
|
||||||
m_session.setAttribute(NettyChannel.ATTR_KEY_CLEANSESSION, false);
|
m_session.setAttribute(NettyChannel.ATTR_KEY_CLEANSESSION, false);
|
||||||
subscriptions.clearAllSubscriptions();
|
|
||||||
assertEquals(0, subscriptions.size());
|
assertEquals(0, subscriptions.size());
|
||||||
|
|
||||||
//Exercise
|
//Exercise
|
||||||
|
|||||||
Reference in New Issue
Block a user