use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class EncodedIrTest method shouldDecodeCorrectMessages.
@Test
public void shouldDecodeCorrectMessages() throws Exception {
final MessageSchema schema = parse(TestUtil.getLocalResource("code-generation-schema.xml"), ParserOptions.DEFAULT);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocateDirect(CAPACITY);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
buffer.flip();
final IrDecoder irDecoder = new IrDecoder(buffer);
final Ir decodedIr = irDecoder.decode();
assertThat(decodedIr.messages().size(), is(ir.messages().size()));
for (final List<Token> decodedTokenList : decodedIr.messages()) {
final List<Token> tokens = ir.getMessage(decodedTokenList.get(0).id());
assertThat(decodedTokenList.size(), is(tokens.size()));
for (int i = 0, size = decodedTokenList.size(); i < size; i++) {
assertEqual(decodedTokenList.get(i), tokens.get(i));
}
}
}
use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class EncodedIrTest method shouldEncodeIr.
@Test
public void shouldEncodeIr() throws Exception {
final MessageSchema schema = parse(TestUtil.getLocalResource("basic-schema.xml"), ParserOptions.DEFAULT);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocateDirect(CAPACITY);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
}
use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class EncodedIrTest method shouldHandleRightSizedBuffer.
@Test
public void shouldHandleRightSizedBuffer() throws Exception {
final MessageSchema schema = parse(TestUtil.getLocalResource("basic-schema.xml"), ParserOptions.DEFAULT);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocateDirect(CAPACITY);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
buffer.flip();
final ByteBuffer readBuffer = ByteBuffer.allocateDirect(buffer.remaining());
readBuffer.put(buffer);
readBuffer.flip();
final IrDecoder irDecoder = new IrDecoder(readBuffer);
irDecoder.decode();
}
use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class EncodedIrTest method shouldDecodeCorrectFrame.
@Test
public void shouldDecodeCorrectFrame() throws Exception {
final MessageSchema schema = parse(TestUtil.getLocalResource("code-generation-schema.xml"), ParserOptions.DEFAULT);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocateDirect(CAPACITY);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
buffer.flip();
final IrDecoder irDecoder = new IrDecoder(buffer);
final Ir decodedIr = irDecoder.decode();
assertThat(decodedIr.id(), is(ir.id()));
assertThat(decodedIr.version(), is(ir.version()));
assertThat(decodedIr.semanticVersion(), is(ir.semanticVersion()));
assertThat(decodedIr.packageName(), is(ir.packageName()));
assertThat(decodedIr.namespaceName(), is(ir.namespaceName()));
}
use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class EncodedIrTest method shouldEncodeThenDecodeIr.
@Test
public void shouldEncodeThenDecodeIr() throws Exception {
final MessageSchema schema = parse(TestUtil.getLocalResource("basic-schema.xml"), ParserOptions.DEFAULT);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocateDirect(CAPACITY);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
buffer.flip();
final IrDecoder decoder = new IrDecoder(buffer);
decoder.decode();
}
Aggregations