Search in sources :

Example 1 with ExplicitlyTaggedSet

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

the class TaggingTest method explicitlyTaggedSetTest.

@Test
public void explicitlyTaggedSetTest() throws Exception {
    ExplicitlyTaggedSet set = new ExplicitlyTaggedSet();
    set.setMyInteger(new BerInteger(1));
    set.setMyBoolean(new BerBoolean(true));
    ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
    set.encode(os);
    assertArrayEquals(toBytes("BF210a3108a1030201010101FF"), os.getArray());
    set = new ExplicitlyTaggedSet();
    set.decode(new ByteArrayInputStream(os.getArray()));
    assertNotNull(set.getMyInteger());
    assertNotNull(set.getMyBoolean());
}
Also used : ExplicitlyTaggedSet(com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSet) BerBoolean(com.beanit.asn1bean.ber.types.BerBoolean) ByteArrayInputStream(java.io.ByteArrayInputStream) BerInteger(com.beanit.asn1bean.ber.types.BerInteger) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 2 with ExplicitlyTaggedSet

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

the class TaggingTest method explicitlyTaggedSetIndefiniteTest.

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

Aggregations

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