List of usage examples for io.netty.buffer ByteBuf toString
public abstract String toString(Charset charset);
From source file:com.corundumstudio.socketio.parser.EncoderErrorPacketTest.java
License:Apache License
@Test public void testEncodeWithReason() throws IOException { Packet packet = new Packet(PacketType.ERROR); packet.setReason(ErrorReason.TRANSPORT_NOT_SUPPORTED); ByteBuf result = Unpooled.buffer(); encoder.encodePacket(packet, result); Assert.assertEquals("7:::0", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderErrorPacketTest.java
License:Apache License
@Test public void testEncodeWithReasonAndAdvice() throws IOException { Packet packet = new Packet(PacketType.ERROR); packet.setReason(ErrorReason.UNAUTHORIZED); packet.setAdvice(ErrorAdvice.RECONNECT); ByteBuf result = Unpooled.buffer(); encoder.encodePacket(packet, result); Assert.assertEquals("7:::2+0", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderErrorPacketTest.java
License:Apache License
@Test public void testEncodeWithEndpoint() throws IOException { Packet packet = new Packet(PacketType.ERROR); packet.setEndpoint("/woot"); ByteBuf result = Unpooled.buffer(); encoder.encodePacket(packet, result); Assert.assertEquals("7::/woot", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderEventPacketTest.java
License:Apache License
@Test public void testEncode() throws IOException { Packet packet = new Packet(PacketType.EVENT); packet.setName("woot"); ByteBuf result = Unpooled.buffer(); // encoder.encodePacket(packet, result); Assert.assertEquals("5:::{\"name\":\"woot\"}", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderEventPacketTest.java
License:Apache License
@Test public void testEncodeWithMessageIdAndAck() throws IOException { Packet packet = new Packet(PacketType.EVENT); // packet.setId(1L); // packet.setAck(Packet.ACK_DATA); packet.setName("tobi"); ByteBuf result = Unpooled.buffer(); // encoder.encodePacket(packet, result); Assert.assertEquals("5:1+::{\"name\":\"tobi\"}", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderEventPacketTest.java
License:Apache License
@Test public void testEncodeWithData() throws IOException { Packet packet = new Packet(PacketType.EVENT); packet.setName("edwald"); // packet.setArgs(Arrays.asList(Collections.singletonMap("a", "b"), 2, "3")); ByteBuf result = Unpooled.buffer(); // encoder.encodePacket(packet, result); Assert.assertEquals("5:::{\"name\":\"edwald\",\"args\":[{\"a\":\"b\"},2,\"3\"]}", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderJsonPacketTest.java
License:Apache License
@Test public void testEncode() throws IOException { Packet packet = new Packet(PacketType.JSON); packet.setData("2"); ByteBuf result = Unpooled.buffer(); encoder.encodePacket(packet, result); Assert.assertEquals("4:::\"2\"", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderJsonPacketTest.java
License:Apache License
@Test public void testEncodeWithMessageIdAndAckData() throws IOException { Packet packet = new Packet(PacketType.JSON); packet.setId(1L);/* w ww .j a v a 2 s . c om*/ packet.setAck(Packet.ACK_DATA); packet.setData(Collections.singletonMap("a", "b")); ByteBuf result = Unpooled.buffer(); encoder.encodePacket(packet, result); Assert.assertEquals("4:1+::{\"a\":\"b\"}", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderMessagePacketTest.java
License:Apache License
@Test public void testEncode() throws IOException { Packet packet = new Packet(PacketType.MESSAGE); packet.setData("woot"); ByteBuf result = Unpooled.buffer(); // encoder.encodePacket(packet, result); Assert.assertEquals("3:::woot", result.toString(CharsetUtil.UTF_8)); }
From source file:com.corundumstudio.socketio.parser.EncoderMessagePacketTest.java
License:Apache License
@Test public void testEncodeWithIdAndEndpoint() throws IOException { Packet packet = new Packet(PacketType.MESSAGE); // packet.setId(5L); // packet.setAck(true); packet.setNsp("/tobi"); ByteBuf result = Unpooled.buffer(); // encoder.encodePacket(packet, result); Assert.assertEquals("3:5:/tobi", result.toString(CharsetUtil.UTF_8)); }