Extracted the persistence dependency from SubscriptionsStore

This commit is contained in:
selva.andre
2014-06-30 22:46:11 +02:00
parent 1afa7601c9
commit 90cfe1ac23
5 changed files with 27 additions and 23 deletions
@@ -17,6 +17,7 @@ package org.dna.mqtt.moquette.messaging.spi.impl;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -152,7 +153,7 @@ public class ProtocolProcessorTest {
m_mockAuthenticator = new MockAuthenticator(users);
subscriptions = new SubscriptionsStore();
subscriptions.init(m_storageService);
subscriptions.init(Collections.<Subscription>emptyList());
m_processor = new ProtocolProcessor();
m_processor.init(subscriptions, m_storageService, m_mockAuthenticator);
}
@@ -261,7 +262,7 @@ public class ProtocolProcessorTest {
};
//simulate a connect that register a clientID to an IoSession
subs.init(m_storageService);
subs.init(Collections.<Subscription>emptyList());
m_processor.init(subs, m_storageService, null);
ConnectMessage connectMessage = new ConnectMessage();
connectMessage.setProcotolVersion((byte)3);
@@ -300,7 +301,7 @@ public class ProtocolProcessorTest {
};
//simulate a connect that register a clientID to an IoSession
subs.init(m_storageService);
subs.init(Collections.<Subscription>emptyList());
m_processor.init(subs, m_storageService, null);
MockReceiverChannel firstReceiverSession = new MockReceiverChannel();
@@ -408,7 +409,7 @@ public class ProtocolProcessorTest {
}
}
};
subs.init(new MemoryStorageService());
subs.init(Collections.<Subscription>emptyList());
//simulate a connect that register a clientID to an IoSession
m_processor.init(subs, m_storageService, null);
@@ -19,6 +19,7 @@ import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.dna.mqtt.moquette.messaging.spi.impl.MemoryStorageService;
@@ -55,7 +56,7 @@ public class SubscriptionsStoreTest {
pageFactory.open();
PageFile pageFile = pageFactory.getPageFile();
MultiIndexFactory multiIndexFactory = new MultiIndexFactory(pageFile);
store.init(new MemoryStorageService());
store.init(Collections.<Subscription>emptyList());
}
@After
@@ -252,7 +253,7 @@ public class SubscriptionsStoreTest {
private void assertMatch(String subscription, String topic) {
store = new SubscriptionsStore();
store.init(new MemoryStorageService());
store.init(Collections.<Subscription>emptyList());
Subscription sub = new Subscription("FAKE_CLI_ID_1", subscription, AbstractMessage.QOSType.MOST_ONE, false);
store.add(sub);
assertFalse(store.matches(topic).isEmpty());
@@ -260,7 +261,7 @@ public class SubscriptionsStoreTest {
private void assertNotMatch(String subscription, String topic) {
store = new SubscriptionsStore();
store.init(new MemoryStorageService());
store.init(Collections.<Subscription>emptyList());
Subscription sub = new Subscription("FAKE_CLI_ID_1", subscription, AbstractMessage.QOSType.MOST_ONE, false);
store.add(sub);
assertTrue(store.matches(topic).isEmpty());
@@ -345,7 +346,7 @@ public class SubscriptionsStoreTest {
@Test
public void removeSubscription_withDifferentClients_subscribedSameTopic() {
SubscriptionsStore aStore = new SubscriptionsStore();
aStore.init(new MemoryStorageService());
aStore.init(Collections.<Subscription>emptyList());
//subscribe a not active clientID1 to /topic
Subscription slashSub = new Subscription("FAKE_CLI_ID_1", "/topic", AbstractMessage.QOSType.MOST_ONE, false);
aStore.add(slashSub);