Search in sources :

Example 1 with ExplicitlyTaggedSeqOf

use of com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSeqOf in project jasn1 by openmuc.

the class TaggingTest method explicitlyTaggedSeqOfIndefiniteTest.

@Test
public void explicitlyTaggedSeqOfIndefiniteTest() throws Exception {
    byte[] code = toBytes("BF2180308002010302010400000000");
    ExplicitlyTaggedSeqOf seqOf = new ExplicitlyTaggedSeqOf();
    InputStream is = new ByteArrayInputStream(code);
    int numDecodedBytes = seqOf.decode(is);
    assertNotNull(seqOf.getBerInteger());
    assertEquals(-1, is.read());
    assertEquals(code.length, numDecodedBytes);
}
Also used : ExplicitlyTaggedSeqOf(com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSeqOf) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.jupiter.api.Test)

Example 2 with ExplicitlyTaggedSeqOf

use of com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSeqOf in project jasn1 by openmuc.

the class TaggingTest method explicitlyTaggedSeqOfTest.

@Test
public void explicitlyTaggedSeqOfTest() throws Exception {
    ExplicitlyTaggedSeqOf seqOf = new ExplicitlyTaggedSeqOf();
    List<BerInteger> integerList = seqOf.getBerInteger();
    integerList.add(new BerInteger(3));
    integerList.add(new BerInteger(4));
    ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
    seqOf.encode(os);
    assertArrayEquals(toBytes("BF21083006020103020104"), os.getArray());
    seqOf = new ExplicitlyTaggedSeqOf();
    seqOf.decode(new ByteArrayInputStream(os.getArray()));
}
Also used : ExplicitlyTaggedSeqOf(com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSeqOf) ByteArrayInputStream(java.io.ByteArrayInputStream) BerInteger(com.beanit.asn1bean.ber.types.BerInteger) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ExplicitlyTaggedSeqOf (com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSeqOf)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Test (org.junit.jupiter.api.Test)2 ReverseByteArrayOutputStream (com.beanit.asn1bean.ber.ReverseByteArrayOutputStream)1 BerInteger (com.beanit.asn1bean.ber.types.BerInteger)1 InputStream (java.io.InputStream)1