Search in sources :

Example 71 with ByteBuf

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

the class LPDataIOWrapperTest method testDirectBuffer.

@Test
public void testDirectBuffer() throws IOException {
    ByteBuf directBuf = directBuffer();
    LPDataIOWrapper.writeData(directBuf, output -> {
        output.writeInt(12);
        output.writeByte(13);
    });
    LPDataIOWrapper.provideData(directBuf, input -> {
        assertEquals(12, input.readInt());
        assertEquals(13, input.readByte());
    });
    assertEquals(BUFFER_EMPTY_MSG, 0, directBuf.readableBytes());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 72 with ByteBuf

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

the class LPDataIOWrapperTest method testWriteByteInt.

@Test
public void testWriteByteInt() throws Exception {
    int byteValue = 0x6f;
    ByteBuf testBuffer = buffer(Byte.BYTES);
    LPDataIOWrapper.writeData(testBuffer, output -> output.writeByte(byteValue));
    ByteBuf compareBuffer = buffer(Byte.BYTES);
    compareBuffer.writeByte(byteValue);
    assertTrue(ByteBufUtil.equals(testBuffer, compareBuffer));
    testBuffer.release();
    compareBuffer.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 73 with ByteBuf

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

the class LPDataIOWrapperTest method testWriteInt.

@Test
public void testWriteInt() throws Exception {
    int value = 0x6f0f9f3f;
    ByteBuf testBuffer = buffer(Integer.BYTES);
    LPDataIOWrapper.writeData(testBuffer, output -> output.writeInt(value));
    ByteBuf compareBuffer = buffer(Integer.BYTES);
    compareBuffer.writeInt(value);
    assertTrue(ByteBufUtil.equals(testBuffer, compareBuffer));
    testBuffer.release();
    compareBuffer.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 74 with ByteBuf

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

the class TestUtil method getBytesFromInteger.

public static byte[] getBytesFromInteger(int i) {
    ByteBuf b = buffer(Integer.BYTES);
    byte[] data = new byte[Integer.BYTES];
    b.writeInt(i);
    b.readBytes(data);
    b.release();
    return data;
}
Also used : ByteBuf(io.netty.buffer.ByteBuf)

Example 75 with ByteBuf

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

the class StringMarshalTest method shouldSerializeAndDeserializeEmptyString.

@Test
public void shouldSerializeAndDeserializeEmptyString() {
    // given
    final String TEST_STRING = "";
    final ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    // when
    StringMarshal.marshal(buffer, TEST_STRING);
    String reconstructed = StringMarshal.unmarshal(buffer);
    // then
    assertNotSame(TEST_STRING, reconstructed);
    assertEquals(TEST_STRING, reconstructed);
}
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