Package io.netty.channel.embedded

Examples of io.netty.channel.embedded.EmbeddedChannel.alloc()


    @Test
    public void readResponseTest() throws Exception {
        EmbeddedChannel embedder = new EmbeddedChannel(new DnsResponseDecoder());
        for (byte[] p: packets) {
            ByteBuf packet = embedder.alloc().buffer(512).writeBytes(p);
            embedder.writeInbound(new DatagramPacket(packet, null, new InetSocketAddress(0)));
            DnsResponse decoded = embedder.readInbound();
            ByteBuf raw = Unpooled.wrappedBuffer(p);
            Assert.assertEquals("Invalid id, expected: " + raw.getUnsignedShort(0) + ", actual: "
                    + decoded.header().id(), raw.getUnsignedShort(0), decoded.header().id());
View Full Code Here


    public ExpectedException exception = ExpectedException.none();

    @Test
    public void readMalormedResponseTest() throws Exception {
        EmbeddedChannel embedder = new EmbeddedChannel(new DnsResponseDecoder());
        ByteBuf packet = embedder.alloc().buffer(512).writeBytes(malformedLoopPacket);
        exception.expect(CorruptedFrameException.class);
        embedder.writeInbound(new DatagramPacket(packet, null, new InetSocketAddress(0)));
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.