|
|
@ -18,7 +18,10 @@ package com.corundumstudio.socketio.parser; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import io.netty.buffer.Unpooled; |
|
|
|
import io.netty.util.CharsetUtil; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Ignore; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
import com.corundumstudio.socketio.protocol.JacksonJsonSupport; |
|
|
@ -26,18 +29,19 @@ import com.corundumstudio.socketio.protocol.Packet; |
|
|
|
import com.corundumstudio.socketio.protocol.PacketDecoder; |
|
|
|
import com.corundumstudio.socketio.protocol.PacketType; |
|
|
|
|
|
|
|
@Ignore |
|
|
|
public class DecoderEventPacketTest extends DecoderBaseTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testDecode() throws IOException { |
|
|
|
Packet packet = decoder.decodePacket("5:::{\"name\":\"woot\"}", null); |
|
|
|
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:::{\"name\":\"woot\"}", CharsetUtil.UTF_8), null); |
|
|
|
Assert.assertEquals(PacketType.EVENT, packet.getType()); |
|
|
|
Assert.assertEquals("woot", packet.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testDecodeWithMessageIdAndAck() throws IOException { |
|
|
|
Packet packet = decoder.decodePacket("5:1+::{\"name\":\"tobi\"}", null); |
|
|
|
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:1+::{\"name\":\"tobi\"}", CharsetUtil.UTF_8), null); |
|
|
|
Assert.assertEquals(PacketType.EVENT, packet.getType()); |
|
|
|
// Assert.assertEquals(1, (long)packet.getId()); |
|
|
|
// Assert.assertEquals(Packet.ACK_DATA, packet.getAck()); |
|
|
@ -50,7 +54,7 @@ public class DecoderEventPacketTest extends DecoderBaseTest { |
|
|
|
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); |
|
|
|
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:::{\"name\":\"edwald\",\"args\":[{\"a\": \"b\"},2,\"3\"]}", CharsetUtil.UTF_8), null); |
|
|
|
Assert.assertEquals(PacketType.EVENT, packet.getType()); |
|
|
|
Assert.assertEquals("edwald", packet.getName()); |
|
|
|
// Assert.assertEquals(3, packet.getArgs().size()); |
|
|
|