Fixed failing tests

This commit is contained in:
andsel
2018-11-22 22:16:44 +01:00
parent 626d6e786f
commit 9df60774a7
8 changed files with 11 additions and 14 deletions
@@ -19,11 +19,12 @@ import io.moquette.broker.subscriptions.Topic;
import io.netty.handler.codec.mqtt.MqttPublishMessage; import io.netty.handler.codec.mqtt.MqttPublishMessage;
public interface IRetainedRepository { public interface IRetainedRepository {
void cleanRetained(Topic topic); void cleanRetained(Topic topic);
void retain(Topic topic, MqttPublishMessage msg); void retain(Topic topic, MqttPublishMessage msg);
boolean isEmtpy(); boolean isEmpty();
MqttPublishMessage retainedOnTopic(String topic); MqttPublishMessage retainedOnTopic(String topic);
} }
@@ -39,7 +39,7 @@ final class MemoryRetainedRepository implements IRetainedRepository {
} }
@Override @Override
public boolean isEmtpy() { public boolean isEmpty() {
return storage.isEmpty(); return storage.isEmpty();
} }
@@ -79,11 +79,6 @@ public class CTrieSubscriptionDirectory implements ISubscriptionsDirectory {
return Optional.of(inode.mainNode()); return Optional.of(inode.mainNode());
} }
@Override
public List<Subscription> matches(Topic topic) {
return new ArrayList<>(matchQosSharpening(topic));
}
/** /**
* Given a topic string return the clients subscriptions that matches it. Topic string can't * Given a topic string return the clients subscriptions that matches it. Topic string can't
* contain character # and + because they are reserved to listeners subscriptions, and not topic * contain character # and + because they are reserved to listeners subscriptions, and not topic
@@ -113,7 +108,7 @@ public class CTrieSubscriptionDirectory implements ISubscriptionsDirectory {
return new HashSet<>(subsGroupedByClient.values()); return new HashSet<>(subsGroupedByClient.values());
} }
Set<Subscription> recursiveMatch(Topic topic, INode inode) { private Set<Subscription> recursiveMatch(Topic topic, INode inode) {
CNode cnode = inode.mainNode(); CNode cnode = inode.mainNode();
if (Token.MULTI.equals(cnode.token)) { if (Token.MULTI.equals(cnode.token)) {
return cnode.subscriptions; return cnode.subscriptions;
@@ -32,8 +32,6 @@ public interface ISubscriptionsDirectory {
void removeSubscription(Topic topic, String clientID); void removeSubscription(Topic topic, String clientID);
List<Subscription> matches(Topic topic);
int size(); int size();
String dumpTree(); String dumpTree();
@@ -241,7 +241,7 @@ public class PostOfficePublishTest {
.topicName(NEWS_TOPIC).build()); .topicName(NEWS_TOPIC).build());
// Verify // Verify
assertTrue("QoS0 MUST clean retained message for topic", retainedRepository.isEmtpy()); assertTrue("QoS0 MUST clean retained message for topic", retainedRepository.isEmpty());
} }
@Test @Test
@@ -403,7 +403,7 @@ public class PostOfficePublishTest {
.topicName(NEWS_TOPIC).build()); .topicName(NEWS_TOPIC).build());
// Verify // Verify
assertTrue("Retained message for topic /news must be cleared", retainedRepository.isEmtpy()); assertTrue("Retained message for topic /news must be cleared", retainedRepository.isEmpty());
} }
private void assertMessageIsRetained(String expectedTopicName) { private void assertMessageIsRetained(String expectedTopicName) {
@@ -16,13 +16,14 @@
package io.moquette.broker.config; package io.moquette.broker.config;
import io.moquette.broker.config.ConfigurationParser;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.text.ParseException; import java.text.ParseException;
import java.util.Properties; import java.util.Properties;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@@ -62,8 +62,8 @@ public class ServerIntegrationWebSocketTest {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
client.stop(); client.stop();
m_server.stopServer(); m_server.stopServer();
IntegrationUtils.clearTestStorage();
} }
@SuppressWarnings("FutureReturnValueIgnored") @SuppressWarnings("FutureReturnValueIgnored")
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import io.moquette.BrokerConstants; import io.moquette.BrokerConstants;
import io.moquette.integration.IntegrationUtils;
import io.moquette.testclient.RawClient; import io.moquette.testclient.RawClient;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -53,6 +54,7 @@ public class ConnectionIT {
dbFile.delete()); dbFile.delete());
} }
assertFalse(dbFile.exists()); assertFalse(dbFile.exists());
IntegrationUtils.clearTestStorage();
} }
@Test(timeout = 3000) @Test(timeout = 3000)