Search in sources :

Example 1 with ExplicitlyTaggedSequence

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

the class TaggingTest method explicitlyTaggedSequenceIndefiniteTest.

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

Example 2 with ExplicitlyTaggedSequence

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

the class TaggingTest method explicitlyTaggedSequenceTest.

@Test
public void explicitlyTaggedSequenceTest() throws Exception {
    ExplicitlyTaggedSequence sequence = new ExplicitlyTaggedSequence();
    sequence.setMyInteger(new BerInteger(1));
    sequence.setMyBoolean(new BerBoolean(true));
    ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
    sequence.encode(os);
    byte[] code = toBytes("BF210830060201010101FF");
    assertArrayEquals(code, os.getArray());
    sequence = new ExplicitlyTaggedSequence();
    int numDecodedBytes = sequence.decode(new ByteArrayInputStream(os.getArray()));
    assertNotNull(sequence.getMyInteger());
    assertNotNull(sequence.getMyBoolean());
    assertEquals(code.length, numDecodedBytes);
}
Also used : ExplicitlyTaggedSequence(com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSequence) 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)

Aggregations

ExplicitlyTaggedSequence (com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedSequence)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