Exemplo n.º 1
0
  @Test
  public void shouldUnmarshalTaggedListWithSuffix() throws IOException {
    ByteArrayBitStreamWriter writer = new ByteArrayBitStreamWriter();
    writer.writeByte(0x8C);
    writer.writeByte(8);
    writer.writeShort(500);
    writer.writeShort(600);
    writer.writeShort(700);
    writer.writeShort(800);
    writer.writeInt(999);
    writer.close();

    byte[] bytes = writer.toByteArray();
    assertThat(bytes.length, is(14));

    Unmarshaller unmarshaller = dadlContext.createUnmarshaller();
    TaggedListWithSuffix tlws = unmarshaller.unmarshal(bytes, TaggedListWithSuffix.class);

    assertThat(tlws, is(notNullValue()));
    TaggedList tl = tlws.getTaggedList();
    assertThat(tl.getIndexes().size(), is(4));
    assertThat(tl.getIndexes(), contains(500, 600, 700, 800));
    assertThat(tlws.getSuffix(), is(999));
  }
Exemplo n.º 2
0
  @Test
  public void shouldUnmarshalBcdSequence() throws Exception {
    ByteArrayBitStreamWriter writer = new ByteArrayBitStreamWriter();
    writer.writeShort(4096);
    writer.writeBits(1, 4);
    writer.writeBits(2, 4);
    writer.writeBits(3, 4);
    writer.writeBits(4, 4);
    writer.close();
    byte[] bytes = writer.toByteArray();
    assertThat(bytes.length, is(4));

    Unmarshaller unmarshaller = dadlContext.createUnmarshaller();
    BcdSequence bcdSequence = unmarshaller.unmarshal(bytes, BcdSequence.class);
    assertThat(bcdSequence.getI16(), is(4096));
    assertThat(bcdSequence.getBcd(), is(1234));
  }