Example usage for io.netty.util CharsetUtil UTF_8

List of usage examples for io.netty.util CharsetUtil UTF_8

Introduction

In this page you can find the example usage for io.netty.util CharsetUtil UTF_8.

Prototype

Charset UTF_8

To view the source code for io.netty.util CharsetUtil UTF_8.

Click Source Link

Document

8-bit UTF (UCS Transformation Format)

Usage

From source file:com.corundumstudio.socketio.parser.EncoderConnectionPacketTest.java

License:Apache License

@Test
public void testEncodeDisconnection() throws IOException {
    Packet packet = new Packet(PacketType.DISCONNECT);
    packet.setNsp("/woot");
    ByteBuf result = Unpooled.buffer();/*from  w  w  w.  j a  va 2 s  .c  o m*/
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("0::/woot", result.toString(CharsetUtil.UTF_8));
}

From source file:com.corundumstudio.socketio.parser.EncoderConnectionPacketTest.java

License:Apache License

@Test
public void testEncode() throws IOException {
    Packet packet = new Packet(PacketType.CONNECT);
    packet.setNsp("/tobi");
    ByteBuf result = Unpooled.buffer();//from  w  w  w .  j  a  v  a 2s  .  c om
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("1::/tobi", result.toString(CharsetUtil.UTF_8));
}

From source file:com.corundumstudio.socketio.parser.EncoderConnectionPacketTest.java

License:Apache License

@Test
public void testEncodePacketWithQueryString() throws IOException {
    Packet packet = new Packet(PacketType.CONNECT);
    packet.setNsp("/test");
    //        packet.setQs("?test=1");
    ByteBuf result = Unpooled.buffer();/*from w ww . ja v  a 2 s .  c o m*/
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("1::/test:?test=1", result.toString(CharsetUtil.UTF_8));
}

From source file:com.corundumstudio.socketio.parser.EncoderErrorPacketTest.java

License:Apache License

@Test
public void testEncode() throws IOException {
    Packet packet = new Packet(PacketType.ERROR);
    ByteBuf result = Unpooled.buffer();/*from w  ww. ja v a 2 s  . c o m*/
    encoder.encodePacket(packet, result);
    Assert.assertEquals("7::", result.toString(CharsetUtil.UTF_8));
}

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();//w w w.  j a  va2s . co m
    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();//from  w w  w  .  ja  v a 2 s  .  c o m
    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();//from ww  w.j ava2  s . c  om
    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();/*  w  w w  . jav a2  s .co m*/
    //        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();// w w w  .  j a  va2 s  .c  o m
    //        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();/*  w  w w .j  a  v a 2 s . co m*/
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("5:::{\"name\":\"edwald\",\"args\":[{\"a\":\"b\"},2,\"3\"]}",
            result.toString(CharsetUtil.UTF_8));
}