Updated the way packet type is set and added TC
This commit is contained in:
parent
f8a46f2089
commit
edd8ee0341
17 changed files with 173 additions and 52 deletions
32
test/zutil/net/mqtt/MqttBrokerTest.java
Normal file
32
test/zutil/net/mqtt/MqttBrokerTest.java
Normal 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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue