use of com.beanit.asn1bean.compiler.various_tests.SimpleSeq in project jasn1 by openmuc.
the class AnyTypeTest method decodeAny.
private void decodeAny(byte[] encodedBytes) throws IOException {
SeqContainingAnyDefinedBy seqContainingAnyDefinedBy = new SeqContainingAnyDefinedBy();
seqContainingAnyDefinedBy.decode(new ByteArrayInputStream(encodedBytes));
byte[] bytesContainedByAny = seqContainingAnyDefinedBy.myAny.value;
SimpleSeq simpleSeq = new SimpleSeq();
simpleSeq.decode(new ByteArrayInputStream(bytesContainedByAny));
Assertions.assertEquals(2, simpleSeq.myElement.value.intValue());
}
use of com.beanit.asn1bean.compiler.various_tests.SimpleSeq in project jasn1 by openmuc.
the class AnyTypeTest method encodingAny.
@Test
public void encodingAny() throws Exception {
SimpleSeq simpleSeq = new SimpleSeq(new BerInteger(2));
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
simpleSeq.encode(os);
System.out.println(HexString.fromBytes(os.getArray()));
assertArrayEquals(toBytes("3003800102"), os.getArray());
SeqContainingAnyDefinedBy seqContainingAnyDefinedBy = new SeqContainingAnyDefinedBy(new BerAny(os.getArray()));
os.reset();
seqContainingAnyDefinedBy.encode(os);
System.out.println(HexString.fromBytes(os.getArray()));
assertArrayEquals(toBytes("3007A0053003800102"), os.getArray());
}
Aggregations