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());
}
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()));
}
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());
}
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());
}
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);
}
Aggregations