@Test public void shouldHandleBasicFileWithGroup() throws Exception { parse(TestUtil.getLocalResource("basic-group-schema.xml"), ParserOptions.DEFAULT); }
@Test public void shouldHandleBasicFileWithVariableLengthData() throws Exception { parse(TestUtil.getLocalResource("basic-variable-length-schema.xml"), ParserOptions.DEFAULT); }
@Test public void shouldHandleEmbeddedLengthForData() throws Exception { parse(TestUtil.getLocalResource("embedded-length-and-count-schema.xml"), ParserOptions.DEFAULT); /* should parse correctly */ } }
@Test public void shouldHandleBasicFile() throws Exception { parse(TestUtil.getLocalResource("basic-schema.xml"), ParserOptions.DEFAULT); }
@Test public void shouldHandleConstantHeaderField() throws Exception { parse(TestUtil.getLocalResource("basic-schema-constant-header-field.xml"), ParserOptions.DEFAULT); }
@Test public void shouldCalculateDataOffsetWithPaddingFromBlockLength() throws Exception { final MessageSchema schema = parse(TestUtil.getLocalResource( "block-length-schema.xml"), ParserOptions.DEFAULT); final List<Field> fields = schema.getMessage(4).fields(); assertThat(valueOf(fields.get(0).computedOffset()), is(valueOf(0))); assertThat(valueOf(fields.get(0).type().encodedLength()), is(valueOf(8))); assertThat(valueOf(fields.get(1).computedOffset()), is(valueOf(64))); assertThat(valueOf(fields.get(1).type().encodedLength()), is(valueOf(-1))); }
@Test public void shouldCalculateCompositeSizeWithOffsetsSpecified() throws Exception { final MessageSchema schema = parse(TestUtil.getLocalResource( "composite-offsets-schema.xml"), ParserOptions.DEFAULT); final CompositeType header = schema.messageHeader(); assertThat(valueOf(header.encodedLength()), is(valueOf(12))); }
@Test public void shouldCalculateDimensionSizeWithOffsetsSpecified() throws Exception { final MessageSchema schema = parse(TestUtil.getLocalResource( "composite-offsets-schema.xml"), ParserOptions.DEFAULT); final CompositeType dimensions = schema.getMessage(1).fields().get(0).dimensionType(); assertThat(valueOf(dimensions.encodedLength()), is(valueOf(8))); } }
@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(); }
@Test public void shouldExitAfterTypes() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 2 errors"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).build(); parse(TestUtil.getLocalResource("error-handler-types-schema.xml"), options); }
@Test public void shouldExitAfterMessage() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 13 errors"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-message-schema.xml"), options); }
@Test public void shouldExitAfterMessageWhenGroupDimensionsNotComposite() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 1 errors"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-group-dimensions-schema.xml"), options); }
@Test public void shouldTestForCyclicRefs() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("ref types cannot create circular dependencies"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("cyclic-refs-schema.xml"), options); } }
@Test public void shouldExitAfterTypesWhenDupTypesDefined() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 1 warnings"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-types-dup-schema.xml"), options); }
@Test public void shouldExitInvalidFieldNames() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 16 warnings"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-invalid-name.xml"), options); }
@Test public void shouldExitAfterMessageWhenDupMessageIdsDefined() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 1 errors"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-dup-message-schema.xml"), options); }
@Test public void shouldExitAfterTypesWhenCompositeOffsetsIncorrect() throws Exception { exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("had 2 errors"); final ParserOptions options = ParserOptions.builder().suppressOutput(true).warningsFatal(true).build(); parse(TestUtil.getLocalResource("error-handler-invalid-composite-offsets-schema.xml"), options); }
@Test public void shouldGenerateCorrectIrForCompositeRefs() throws Exception { final MessageSchema schema = parse(getLocalResource("issue496.xml"), ParserOptions.DEFAULT); final IrGenerator irg = new IrGenerator(); final Ir ir = irg.generate(schema); assertNotNull(ir.getType("compositeOne")); assertNotNull(ir.getType("compositeTwo")); assertNotNull(ir.getType("compositeThree")); } }
@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()); }
@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(); }