Search in sources :

Example 1 with MessageHeaderDecoder

use of uk.co.real_logic.sbe.ir.generated.MessageHeaderDecoder in project simple-binary-encoding by real-logic.

the class CompositeElementsGenerationTest method shouldDecodeCorrectly.

@Test
public void shouldDecodeCorrectly() {
    final ByteBuffer encodedMsgBuffer = ByteBuffer.allocate(MSG_BUFFER_CAPACITY);
    encodeTestMessage(encodedMsgBuffer);
    final DirectBuffer decodeBuffer = new UnsafeBuffer(encodedMsgBuffer);
    final MessageHeaderDecoder hdrDecoder = new MessageHeaderDecoder();
    final MsgDecoder msgDecoder = new MsgDecoder();
    hdrDecoder.wrap(decodeBuffer, 0);
    msgDecoder.wrap(decodeBuffer, hdrDecoder.encodedLength(), MSG_ENCODER.sbeBlockLength(), MSG_ENCODER.sbeSchemaVersion());
    assertThat(hdrDecoder.blockLength(), is(22));
    assertThat(hdrDecoder.templateId(), is(1));
    assertThat(hdrDecoder.schemaId(), is(3));
    assertThat(hdrDecoder.version(), is(0));
    assertThat(msgDecoder.structure().enumOne(), is(EnumOne.Value10));
    assertThat(msgDecoder.structure().zeroth(), is((short) 42));
    assertThat(msgDecoder.structure().setOne().bit0(), is(false));
    assertThat(msgDecoder.structure().setOne().bit16(), is(true));
    assertThat(msgDecoder.structure().setOne().bit26(), is(false));
    assertThat(msgDecoder.structure().inner().first(), is(101L));
    assertThat(msgDecoder.structure().inner().second(), is(202L));
    assertThat(msgDecoder.encodedLength(), is(22));
}
Also used : DirectBuffer(org.agrona.DirectBuffer) MessageHeaderDecoder(uk.co.real_logic.sbe.ir.generated.MessageHeaderDecoder) MsgDecoder(composite.elements.MsgDecoder) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

MsgDecoder (composite.elements.MsgDecoder)1 ByteBuffer (java.nio.ByteBuffer)1 DirectBuffer (org.agrona.DirectBuffer)1 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)1 Test (org.junit.Test)1 MessageHeaderDecoder (uk.co.real_logic.sbe.ir.generated.MessageHeaderDecoder)1