Search in sources :

Example 6 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class TaggingTest method retaggedChoiceTest.

@Test
public void retaggedChoiceTest() throws Exception {
    RetaggedUntaggedChoice choice = new RetaggedUntaggedChoice();
    choice.setMyInteger(new BerInteger(1));
    ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
    choice.encode(os);
    assertArrayEquals(toBytes("BF2103830101"), os.getArray());
    choice = new RetaggedUntaggedChoice();
    choice.decode(new ByteArrayInputStream(os.getArray()));
    assertNotNull(choice.getMyInteger());
    assertNull(choice.getMyBoolean());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RetaggedUntaggedChoice(com.beanit.asn1bean.compiler.tagging_test.RetaggedUntaggedChoice) BerInteger(com.beanit.asn1bean.ber.types.BerInteger) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 7 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream 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)

Example 8 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class TaggingTest method explicitlyRetaggedIntegerTest.

@Test
public void explicitlyRetaggedIntegerTest() throws Exception {
    ExplicitlyTaggedInteger explicitlyTaggedInteger = new ExplicitlyTaggedInteger(1);
    ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
    explicitlyTaggedInteger.encode(os);
    assertArrayEquals(toBytes("BF2103020101"), os.getArray());
}
Also used : ExplicitlyTaggedInteger(com.beanit.asn1bean.compiler.tagging_test.ExplicitlyTaggedInteger) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 9 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream 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 10 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream 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

ReverseByteArrayOutputStream (com.beanit.asn1bean.ber.ReverseByteArrayOutputStream)51 Test (org.junit.jupiter.api.Test)41 ByteArrayInputStream (java.io.ByteArrayInputStream)25 BerInteger (com.beanit.asn1bean.ber.types.BerInteger)14 BerVisibleString (com.beanit.asn1bean.ber.types.string.BerVisibleString)5 HexString (com.beanit.asn1bean.util.HexString)5 BerOctetString (com.beanit.asn1bean.ber.types.BerOctetString)4 BerUTF8String (com.beanit.asn1bean.ber.types.string.BerUTF8String)4 ProfileElement (com.beanit.asn1bean.compiler.pedefinitions.ProfileElement)4 BerAny (com.beanit.asn1bean.ber.types.BerAny)3 BerBoolean (com.beanit.asn1bean.ber.types.BerBoolean)3 BerNull (com.beanit.asn1bean.ber.types.BerNull)3 ImplicitlyRetaggedTaggedChoice (com.beanit.asn1bean.compiler.tagging_test.ImplicitlyRetaggedTaggedChoice)3 NonExtensibleSequence (com.beanit.asn1bean.compiler.extension_test.non_extensible.NonExtensibleSequence)2 PEHeader (com.beanit.asn1bean.compiler.pedefinitions.PEHeader)2 UInt15 (com.beanit.asn1bean.compiler.pedefinitions.UInt15)2 ArrayList (java.util.ArrayList)2 BerEmbeddedPdv (com.beanit.asn1bean.ber.types.BerEmbeddedPdv)1 BerObjectIdentifier (com.beanit.asn1bean.ber.types.BerObjectIdentifier)1 ExtensibleAccessSequence (com.beanit.asn1bean.compiler.extension_test.extensible_with_access.ExtensibleAccessSequence)1