use of com.beanit.asn1bean.ber.types.BerBoolean 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.types.BerBoolean 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);
}
use of com.beanit.asn1bean.ber.types.BerBoolean in project jasn1 by openmuc.
the class TaggingTest method sequenceOfDirectTypesTest.
@Test
public void sequenceOfDirectTypesTest() throws Exception {
SequenceOfDirectTypes sequence = new SequenceOfDirectTypes();
sequence.setUntaggedInt(new BerInteger(1));
sequence.setExplicitlyTaggedInt(new BerInteger(2));
sequence.setImplicitlyTaggedInt(new BerInteger(3));
SequenceOfDirectTypes.UntaggedChoice untaggedChoice = new SequenceOfDirectTypes.UntaggedChoice();
untaggedChoice.setMyBoolean(new BerBoolean(true));
sequence.setUntaggedChoice(untaggedChoice);
SequenceOfDirectTypes.TaggedChoice taggedChoice = new SequenceOfDirectTypes.TaggedChoice();
taggedChoice.setMyInteger(new BerInteger(4));
sequence.setTaggedChoice(taggedChoice);
sequence.setTaggedAny(new BerAny(new byte[] { 2, 1, 1 }));
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(1000);
sequence.encode(os);
assertArrayEquals(toBytes("BF2B18020101A1030201028201038401FFA503830104A603020101"), os.getArray());
sequence = new SequenceOfDirectTypes();
sequence.decode(new ByteArrayInputStream(os.getArray()));
assertEquals(1, sequence.getUntaggedInt().value.intValue());
assertEquals(2, sequence.getExplicitlyTaggedInt().value.intValue());
assertEquals(3, sequence.getImplicitlyTaggedInt().value.intValue());
assertTrue(untaggedChoice.getMyBoolean().value);
assertEquals(4, sequence.getTaggedChoice().getMyInteger().value.intValue());
assertArrayEquals(toBytes("020101"), sequence.getTaggedAny().value);
assertNull(sequence.getUntaggedChoice2());
}
Aggregations