Renamed subscribe and unsubscribe topic to topicFilter
This commit is contained in:
+2
-2
@@ -106,7 +106,7 @@ public class SubscribeDecoderTest {
|
||||
ByteBuf topicBuffer = Unpooled.buffer(4);
|
||||
topicBuffer.writeShort(messageID);
|
||||
for (SubscribeMessage.Couple couple : topics) {
|
||||
topicBuffer.writeBytes(Utils.encodeString(couple.getTopic()));
|
||||
topicBuffer.writeBytes(Utils.encodeString(couple.getTopicFilter()));
|
||||
topicBuffer.writeByte(couple.getQos());
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class SubscribeDecoderTest {
|
||||
private void initPollutedTopic(ByteBuf buff, int messageID, SubscribeMessage.Couple topic) throws IllegalAccessException {
|
||||
ByteBuf topicBuffer = Unpooled.buffer(4);
|
||||
topicBuffer.writeShort(messageID);
|
||||
topicBuffer.writeBytes(Utils.encodeString(topic.getTopic()));
|
||||
topicBuffer.writeBytes(Utils.encodeString(topic.getTopicFilter()));
|
||||
topicBuffer.writeByte(0xF0 | topic.getQos());
|
||||
|
||||
buff.clear().writeByte(AbstractMessage.SUBSCRIBE << 4 | (byte)0x02)
|
||||
|
||||
+2
-2
@@ -65,9 +65,9 @@ public class SubscribeEncoderTest {
|
||||
assertEquals((byte)0xBB, m_out.readByte());
|
||||
|
||||
//Variable part
|
||||
verifyString(c1.getTopic(), m_out);
|
||||
verifyString(c1.getTopicFilter(), m_out);
|
||||
assertEquals(c1.getQos(), m_out.readByte());
|
||||
verifyString(c2.getTopic(), m_out);
|
||||
verifyString(c2.getTopicFilter(), m_out);
|
||||
assertEquals(c2.getQos(), m_out.readByte());
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.UnsubscribeMessage;
|
||||
@@ -65,9 +66,7 @@ public class UnsubscribeDecoderTest {
|
||||
assertFalse(m_results.isEmpty());
|
||||
UnsubscribeMessage message = (UnsubscribeMessage)m_results.get(0);
|
||||
assertNotNull(message);
|
||||
assertEquals(2, message.topics().size());
|
||||
assertEquals(topic1, message.topics().get(0));
|
||||
assertEquals(topic2, message.topics().get(1));
|
||||
assertEquals(Arrays.asList(topic1, topic2), message.topicFilters());
|
||||
assertEquals(AbstractMessage.UNSUBSCRIBE, message.getMessageType());
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ public class UnsubscribeEncoderTest {
|
||||
|
||||
//variable part
|
||||
String topic1 = "/topic";
|
||||
m_msg.addTopic(topic1);
|
||||
m_msg.addTopicFilter(topic1);
|
||||
|
||||
//Exercise
|
||||
m_encoder.encode(m_mockedContext, m_msg, m_out);
|
||||
@@ -76,8 +76,8 @@ public class UnsubscribeEncoderTest {
|
||||
//variable part
|
||||
String topic1 = "a/b";
|
||||
String topic2 = "a/b/c";
|
||||
m_msg.addTopic(topic1);
|
||||
m_msg.addTopic(topic2);
|
||||
m_msg.addTopicFilter(topic1);
|
||||
m_msg.addTopicFilter(topic2);
|
||||
|
||||
//Exercise
|
||||
m_encoder.encode(m_mockedContext, m_msg, m_out);
|
||||
|
||||
Reference in New Issue
Block a user