Search in sources :

Example 1 with SimpleSeq

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SeqContainingAnyDefinedBy(com.beanit.asn1bean.compiler.various_tests.SeqContainingAnyDefinedBy) SimpleSeq(com.beanit.asn1bean.compiler.various_tests.SimpleSeq)

Example 2 with SimpleSeq

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());
}
Also used : BerInteger(com.beanit.asn1bean.ber.types.BerInteger) SeqContainingAnyDefinedBy(com.beanit.asn1bean.compiler.various_tests.SeqContainingAnyDefinedBy) BerAny(com.beanit.asn1bean.ber.types.BerAny) SimpleSeq(com.beanit.asn1bean.compiler.various_tests.SimpleSeq) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

SeqContainingAnyDefinedBy (com.beanit.asn1bean.compiler.various_tests.SeqContainingAnyDefinedBy)2 SimpleSeq (com.beanit.asn1bean.compiler.various_tests.SimpleSeq)2 ReverseByteArrayOutputStream (com.beanit.asn1bean.ber.ReverseByteArrayOutputStream)1 BerAny (com.beanit.asn1bean.ber.types.BerAny)1 BerInteger (com.beanit.asn1bean.ber.types.BerInteger)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Test (org.junit.jupiter.api.Test)1