Search in sources :

Example 1 with ExplicitlyTaggedSequence

use of org.openmuc.jasn1.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);
    Assert.assertArrayEquals(DatatypeConverter.parseHexBinary("BF210830060201010101FF"), os.getArray());
    sequence = new ExplicitlyTaggedSequence();
    sequence.decode(new ByteArrayInputStream(os.getArray()));
    Assert.assertNotNull(sequence.getMyInteger());
    Assert.assertNotNull(sequence.getMyBoolean());
}
Also used : ExplicitlyTaggedSequence(org.openmuc.jasn1.compiler.tagging_test.ExplicitlyTaggedSequence) BerBoolean(org.openmuc.jasn1.ber.types.BerBoolean) ByteArrayInputStream(java.io.ByteArrayInputStream) BerInteger(org.openmuc.jasn1.ber.types.BerInteger) ReverseByteArrayOutputStream(org.openmuc.jasn1.ber.ReverseByteArrayOutputStream) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Test (org.junit.Test)1 ReverseByteArrayOutputStream (org.openmuc.jasn1.ber.ReverseByteArrayOutputStream)1 BerBoolean (org.openmuc.jasn1.ber.types.BerBoolean)1 BerInteger (org.openmuc.jasn1.ber.types.BerInteger)1 ExplicitlyTaggedSequence (org.openmuc.jasn1.compiler.tagging_test.ExplicitlyTaggedSequence)1