Updated the way packet type is set and added TC

This commit is contained in:
Ziver Koc 2018-11-08 18:12:56 +01:00
parent f8a46f2089
commit edd8ee0341
17 changed files with 173 additions and 52 deletions

View file

@ -0,0 +1,32 @@
package zutil.net.mqtt;
import org.junit.Test;
import zutil.net.mqtt.MqttBroker.MqttConnectionThread;
import zutil.net.mqtt.packet.MqttPacketDisconnect;
import zutil.net.mqtt.packet.MqttPacketPingReq;
import zutil.net.mqtt.packet.MqttPacketPingResp;
import java.io.IOException;
import static org.junit.Assert.*;
public class MqttBrokerTest {
@Test
public void ping() throws IOException {
MqttConnectionThread thread = new MqttConnectionThread();
MqttPacketPingReq pingPacket = new MqttPacketPingReq();
assertEquals(MqttPacketPingResp.class, thread.handleMqttPacket(pingPacket).getClass());
}
@Test
public void disconnect() throws IOException {
MqttConnectionThread thread = new MqttConnectionThread();
MqttPacketDisconnect disconnectPacket = new MqttPacketDisconnect();
assertEquals(null, thread.handleMqttPacket(disconnectPacket));
assertTrue(thread.isShutdown());
}
}