Fixed tests
This commit is contained in:
+14
-5
@@ -1,11 +1,16 @@
|
|||||||
package org.dna.mqtt.moquette.messaging.spi.impl;
|
package org.dna.mqtt.moquette.messaging.spi.impl;
|
||||||
|
|
||||||
import org.dna.mqtt.moquette.messaging.spi.INotifier;
|
import org.dna.mqtt.moquette.messaging.spi.INotifier;
|
||||||
|
import org.dna.mqtt.moquette.messaging.spi.impl.events.PublishEvent;
|
||||||
|
import org.dna.mqtt.moquette.messaging.spi.impl.events.SubscribeEvent;
|
||||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage.QOSType;
|
import org.dna.mqtt.moquette.proto.messages.AbstractMessage.QOSType;
|
||||||
|
import org.junit.After;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +31,8 @@ public class SimpleMessagingTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSubscribe() {
|
public void testSubscribe() {
|
||||||
//Exercise
|
//Exercise
|
||||||
messaging.subscribe(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
SubscribeEvent evt = new SubscribeEvent(new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE));
|
||||||
|
messaging.processSubscribe(evt);
|
||||||
|
|
||||||
//Verify
|
//Verify
|
||||||
Subscription expectedSubscription = new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
Subscription expectedSubscription = new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
||||||
@@ -35,10 +41,11 @@ public class SimpleMessagingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoubleSubscribe() {
|
public void testDoubleSubscribe() {
|
||||||
messaging.subscribe(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
SubscribeEvent evt = new SubscribeEvent(new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE));
|
||||||
|
messaging.processSubscribe(evt);
|
||||||
|
|
||||||
//Exercise
|
//Exercise
|
||||||
messaging.subscribe(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
messaging.processSubscribe(evt);
|
||||||
|
|
||||||
//Verify
|
//Verify
|
||||||
Subscription subscription = new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
Subscription subscription = new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
||||||
@@ -47,12 +54,14 @@ public class SimpleMessagingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublish() {
|
public void testPublish() {
|
||||||
messaging.subscribe(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE);
|
SubscribeEvent evt = new SubscribeEvent(new Subscription(FAKE_CLIENT_ID, FAKE_TOPIC, QOSType.MOST_ONE));
|
||||||
|
messaging.processSubscribe(evt);
|
||||||
INotifier notifier = mock(INotifier.class);
|
INotifier notifier = mock(INotifier.class);
|
||||||
messaging.setNotifier(notifier);
|
messaging.setNotifier(notifier);
|
||||||
|
|
||||||
//Exercise
|
//Exercise
|
||||||
messaging.publish(FAKE_TOPIC, "Hello".getBytes(), QOSType.MOST_ONE, false);
|
PublishEvent pubEvt = new PublishEvent(FAKE_TOPIC, QOSType.MOST_ONE, "Hello".getBytes(), false);
|
||||||
|
messaging.processPublish(pubEvt);
|
||||||
|
|
||||||
//Verify
|
//Verify
|
||||||
ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class);
|
ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class);
|
||||||
|
|||||||
Reference in New Issue
Block a user