Merge branch 'master' of github.com:andsel/moquette

This commit is contained in:
andsel
2015-09-24 11:31:20 +02:00
12 changed files with 95 additions and 23 deletions
@@ -224,7 +224,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
//Handle will flag
if (msg.isWillFlag()) {
AbstractMessage.QOSType willQos = AbstractMessage.QOSType.values()[msg.getWillQos()];
AbstractMessage.QOSType willQos = AbstractMessage.QOSType.valueOf(msg.getWillQos());
byte[] willPayload = msg.getWillMessage();
ByteBuffer bb = (ByteBuffer) ByteBuffer.allocate(willPayload.length).put(willPayload).flip();
//save the will testament in the clientID store
@@ -391,7 +391,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
}
for (final Subscription sub : subscriptions.matches(topic)) {
AbstractMessage.QOSType qos = publishingQos;
if (qos.ordinal() > sub.getRequestedQos().ordinal()) {
if (qos.byteValue() > sub.getRequestedQos().byteValue()) {
qos = sub.getRequestedQos();
}
@@ -637,7 +637,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
ackMessage.setMessageID(msg.getMessageID());
for (SubscribeMessage.Couple req : msg.subscriptions()) {
AbstractMessage.QOSType qos = AbstractMessage.QOSType.values()[req.getQos()];
AbstractMessage.QOSType qos = AbstractMessage.QOSType.valueOf(req.getQos());
Subscription newSubscription = new Subscription(clientID, req.getTopicFilter(), qos, cleanSession);
boolean valid = subscribeSingleTopic(newSubscription, req.getTopicFilter());
ackMessage.addType(valid ? qos : AbstractMessage.QOSType.FAILURE);
@@ -237,7 +237,7 @@ public class SubscriptionsStore {
for (Subscription sub : matchingSubs) {
Subscription existingSub = subsForClient.get(sub.getClientId());
//update the selected subscriptions if not present or if has a greater qos
if (existingSub == null || existingSub.getRequestedQos().ordinal() < sub.getRequestedQos().ordinal()) {
if (existingSub == null || existingSub.getRequestedQos().byteValue() < sub.getRequestedQos().byteValue()) {
subsForClient.put(sub.getClientId(), sub);
}
}
@@ -113,7 +113,7 @@ public class ServerLowlevelMessagesIntegrationTests {
connectMessage.setWillFlag(true);
connectMessage.setWillMessage(willTestamentMsg.getBytes());
connectMessage.setWillTopic(willTestamentTopic);
connectMessage.setWillQos((byte) QOSType.MOST_ONE.ordinal());
connectMessage.setWillQos(QOSType.MOST_ONE.byteValue());
//Execute
m_client.sendMessage(connectMessage);
@@ -155,7 +155,7 @@ public class ServerLowlevelMessagesIntegrationTests {
connectMessage.setClientID("");
connectMessage.setKeepAlive(keepAlive);
connectMessage.setWillFlag(false);
connectMessage.setWillQos((byte) QOSType.MOST_ONE.ordinal());
connectMessage.setWillQos(QOSType.MOST_ONE.byteValue());
//Execute
m_client.sendMessage(connectMessage);
@@ -199,7 +199,7 @@ public class ProtocolProcessorTest {
public void testSubscribe() {
//Exercise
SubscribeMessage msg = new SubscribeMessage();
msg.addSubscription(new SubscribeMessage.Couple((byte)AbstractMessage.QOSType.MOST_ONE.ordinal(), 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_CLEANSESSION, false);
m_processor.processSubscribe(m_session, msg/*, FAKE_CLIENT_ID, false*/);
@@ -213,7 +213,7 @@ public class ProtocolProcessorTest {
@Test
public void testDoubleSubscribe() {
SubscribeMessage msg = new SubscribeMessage();
msg.addSubscription(new SubscribeMessage.Couple((byte)AbstractMessage.QOSType.MOST_ONE.ordinal(), 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_CLEANSESSION, false);
subscriptions.clearAllSubscriptions();
@@ -234,7 +234,7 @@ public class ProtocolProcessorTest {
@Test
public void testSubscribeWithBadFormattedTopic() {
SubscribeMessage msg = new SubscribeMessage();
msg.addSubscription(new SubscribeMessage.Couple((byte) AbstractMessage.QOSType.MOST_ONE.ordinal(), 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_CLEANSESSION, false);
subscriptions.clearAllSubscriptions();
@@ -329,7 +329,7 @@ public class ProtocolProcessorTest {
//Exercise
SubscribeMessage msg = new SubscribeMessage();
msg.addSubscription(new SubscribeMessage.Couple((byte)QOSType.MOST_ONE.ordinal(), "#"));
msg.addSubscription(new SubscribeMessage.Couple(QOSType.MOST_ONE.byteValue(), "#"));
m_processor.processSubscribe(m_session, msg/*, FAKE_PUBLISHER_ID, false*/);
//Verify