use of uk.co.real_logic.sbe.xml.ParserOptions in project simple-binary-encoding by real-logic.
the class GenerateFixBinaryTest method shouldGenerateValidJava.
@Test
public void shouldGenerateValidJava() throws Exception {
System.setProperty(SbeTool.KEYWORD_APPEND_TOKEN, "_");
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("FixBinary.xml"), options);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final JavaGenerator generator = new JavaGenerator(ir, BUFFER_NAME, READ_ONLY_BUFFER_NAME, false, false, false, outputManager);
outputManager.setPackageName(ir.applicableNamespace());
generator.generateMessageHeaderStub();
generator.generateTypeStubs();
generator.generate();
final Map<String, CharSequence> sources = outputManager.getSources();
final String className = "MDIncrementalRefreshTradeSummary42Decoder";
final String fqClassName = ir.applicableNamespace() + "." + className;
final Class<?> aClass = CompilerUtil.compileInMemory(fqClassName, sources);
assertNotNull(aClass);
}
use of uk.co.real_logic.sbe.xml.ParserOptions in project simple-binary-encoding by real-logic.
the class SchemaExtensionTest method setup.
@Before
public void setup() throws Exception {
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("extension-schema.xml"), options);
final IrGenerator irg = new IrGenerator();
ir = irg.generate(schema);
outputManager.clear();
outputManager.setPackageName(ir.applicableNamespace());
generator().generate();
}
use of uk.co.real_logic.sbe.xml.ParserOptions in project simple-binary-encoding by real-logic.
the class JavaGeneratorTest method setUp.
@Before
public void setUp() throws Exception {
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("code-generation-schema.xml"), options);
final IrGenerator irg = new IrGenerator();
ir = irg.generate(schema);
outputManager.clear();
outputManager.setPackageName(ir.applicableNamespace());
}
use of uk.co.real_logic.sbe.xml.ParserOptions in project simple-binary-encoding by real-logic.
the class ConstantCharArrayTest method shouldGenerateConstCharArrayMethods.
@Test
public void shouldGenerateConstCharArrayMethods() throws Exception {
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("issue505.xml"), options);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final StringWriterOutputManager outputManager = new StringWriterOutputManager();
outputManager.setPackageName(ir.applicableNamespace());
final JavaGenerator generator = new JavaGenerator(ir, BUFFER_NAME, READ_ONLY_BUFFER_NAME, false, false, false, outputManager);
generator.generate();
final String sources = outputManager.getSources().toString();
final String expectedOne = " public byte sourceOne()\n" + " {\n" + " return (byte)67;\n" + " }";
assertThat(sources, containsString(expectedOne));
final String expectedTwo = " public byte sourceTwo()\n" + " {\n" + " return (byte)68;\n" + " }";
assertThat(sources, containsString(expectedTwo));
final String expectedThree = " public String sourceThree()\n" + " {\n" + " return \"EF\";\n" + " }";
assertThat(sources, containsString(expectedThree));
final String expectedFour = " public String sourceFour()\n" + " {\n" + " return \"GH\";\n" + " }";
assertThat(sources, containsString(expectedFour));
}
use of uk.co.real_logic.sbe.xml.ParserOptions in project simple-binary-encoding by real-logic.
the class GenerateFixBinaryTest method shouldGenerateAndEncodeIr.
@Test
public void shouldGenerateAndEncodeIr() throws Exception {
System.setProperty(SbeTool.KEYWORD_APPEND_TOKEN, "_");
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
final MessageSchema schema = parse(TestUtil.getLocalResource("FixBinary.xml"), options);
final IrGenerator irg = new IrGenerator();
final Ir ir = irg.generate(schema);
final ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
final IrEncoder irEncoder = new IrEncoder(buffer, ir);
irEncoder.encode();
buffer.flip();
final IrDecoder irDecoder = new IrDecoder(buffer);
final Ir decodedIr = irDecoder.decode();
assertEquals(ir.id(), decodedIr.id());
assertEquals(ir.version(), decodedIr.version());
assertEquals(ir.byteOrder(), decodedIr.byteOrder());
assertEquals(ir.applicableNamespace(), decodedIr.applicableNamespace());
assertEquals(ir.packageName(), decodedIr.packageName());
assertEquals(ir.types().size(), decodedIr.types().size());
assertEquals(ir.messages().size(), decodedIr.messages().size());
}
Aggregations