use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.
the class DecoderAckPacketTest method testDecodeWithArgs.
@Test
public void testDecodeWithArgs() throws IOException {
initExpectations();
Packet packet = decoder.decodePacket("6:::12+[\"woot\",\"wa\"]", null);
Assert.assertEquals(PacketType.ACK, packet.getType());
Assert.assertEquals(12, (long) packet.getAckId());
// Assert.assertEquals(Arrays.<Object>asList("woot", "wa"), packet.getArgs());
}
use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.
the class DecoderEventPacketTest method testDecodeWithData.
@Test
public void testDecodeWithData() throws IOException {
JacksonJsonSupport jsonSupport = new JacksonJsonSupport();
jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class);
PacketDecoder decoder = new PacketDecoder(jsonSupport, ackManager);
Packet packet = decoder.decodePacket("5:::{\"name\":\"edwald\",\"args\":[{\"a\": \"b\"},2,\"3\"]}", null);
Assert.assertEquals(PacketType.EVENT, packet.getType());
Assert.assertEquals("edwald", packet.getName());
// Assert.assertEquals(3, packet.getArgs().size());
// Map obj = (Map) packet.getArgs().get(0);
// Assert.assertEquals("b", obj.get("a"));
// Assert.assertEquals(2, packet.getArgs().get(1));
// Assert.assertEquals("3", packet.getArgs().get(2));
}
use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.
the class DecoderJsonPacketTest method testUTF8Decode.
@Test
public void testUTF8Decode() throws IOException {
Packet packet = decoder.decodePacket("4:::\"Привет\"", null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("Привет", packet.getData());
}
use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.
the class DecoderJsonPacketTest method testDecode.
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("4:::\"2\"", null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("2", packet.getData());
}
use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.
the class DecoderMessagePacketTest method testDecodeId.
@Test
public void testDecodeId() throws IOException {
Packet packet = decoder.decodePacket("3:1::asdfasdf", null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
// Assert.assertEquals(1, (long)packet.getId());
// Assert.assertTrue(packet.getArgs().isEmpty());
// Assert.assertTrue(packet.getAck().equals(Boolean.TRUE));
}
Aggregations