Search in sources :

Example 61 with ByteBuf

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project MinecraftForge by MinecraftForge.

the class TestNetStuff method testByteBufUtilsByteReversals.

@Test
public void testByteBufUtilsByteReversals() {
    ByteBuf buf = Unpooled.buffer(5, 5);
    ByteBufUtils.writeVarInt(buf, 1, 1);
    assertEquals("1 is 1", 1, ByteBufUtils.readVarInt(buf, 1));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 127, 1);
    assertEquals("127 is 127", 127, ByteBufUtils.readVarInt(buf, 1));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 128, 2);
    assertEquals("128 is 128", 128, ByteBufUtils.readVarInt(buf, 2));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16383, 2);
    assertEquals("16383 is 16383", 16383, ByteBufUtils.readVarInt(buf, 2));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 16384, 3);
    assertEquals("16384 is 16384", 16384, ByteBufUtils.readVarInt(buf, 3));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097151, 3);
    assertEquals("2097151 is 2097151", 2097151, ByteBufUtils.readVarInt(buf, 3));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 2097152, 4);
    assertEquals("2097152 is 2097152", 2097152, ByteBufUtils.readVarInt(buf, 4));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435455, 4);
    assertEquals("268435455 is 268435455", 268435455, ByteBufUtils.readVarInt(buf, 4));
    buf.clear();
    ByteBufUtils.writeVarInt(buf, 268435456, 5);
    assertEquals("268435456 is 268435456", 268435456, ByteBufUtils.readVarInt(buf, 5));
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 62 with ByteBuf

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.

the class LPBCPipeRenderState method writeData_LP.

@Override
public void writeData_LP(LPDataOutput output) {
    output.writeBoolean(true);
    ByteBuf buf = Unpooled.buffer(128);
    writeData(buf);
    output.writeByteBuf(buf);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf)

Example 63 with ByteBuf

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.

the class LPBCPipeRenderState method readData_LP.

@Override
public void readData_LP(LPDataInput input) {
    if (input.readBoolean()) {
        ByteBuf buf = input.readByteBuf();
        readData(buf);
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf)

Example 64 with ByteBuf

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.

the class LPDataIOWrapperTest method testReadShort.

@Test
public void testReadShort() throws Exception {
    short value = 12;
    ByteBuf dataBuffer = buffer(Short.BYTES);
    dataBuffer.writeShort(value);
    LPDataIOWrapper.provideData(dataBuffer, input -> {
        assertEquals(value, input.readShort());
        assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes());
    });
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 65 with ByteBuf

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.

the class LPDataIOWrapperTest method testReadDouble.

@Test
public void testReadDouble() throws Exception {
    double value = 0.1234567890123456F;
    ByteBuf dataBuffer = buffer(Double.BYTES);
    dataBuffer.writeDouble(value);
    LPDataIOWrapper.provideData(dataBuffer, input -> {
        assertEquals(value, input.readDouble(), 0.000000000000001);
        assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes());
    });
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)5080 Test (org.junit.Test)1813 Test (org.junit.jupiter.api.Test)680 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)377 ArrayList (java.util.ArrayList)301 IOException (java.io.IOException)297 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)200 CompositeByteBuf (io.netty.buffer.CompositeByteBuf)182 ByteBuffer (java.nio.ByteBuffer)167 InetSocketAddress (java.net.InetSocketAddress)145 ByteBuf (org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)144 Test (org.testng.annotations.Test)140 Channel (io.netty.channel.Channel)137 List (java.util.List)134 ChannelFuture (io.netty.channel.ChannelFuture)128 Map (java.util.Map)118 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)107 Position (org.traccar.model.Position)105 DeviceSession (org.traccar.DeviceSession)100 NetworkMessage (org.traccar.NetworkMessage)93