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());
}
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();
}
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();
}
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;
}
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);
}
Aggregations