@@ -0,0 +1,2349 @@
+package net.gcdc.asn1.uper;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.Arrays;%0Aimport java.util.BitSet;%0Aimport java.util.Collection;%0A%0Aimport net.gcdc.asn1.datatypes.Asn1SequenceOf;%0Aimport net.gcdc.asn1.datatypes.Asn1VarSizeBitstring;%0Aimport net.gcdc.asn1.datatypes.Bitstring;%0Aimport net.gcdc.asn1.datatypes.FixedSize;%0Aimport net.gcdc.asn1.datatypes.Sequence;%0Aimport net.gcdc.asn1.datatypes.SizeRange;%0A%0Aimport org.junit.Test;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A/**%0A * Example of encoding the following definitions:%0A %3Cpre%3E%0A ON-PDU DEFINITIONS AUTOMATIC TAGS ::=%0ABEGIN%0AIMPORTS%0A    FOO%0A     FROM ON-API;%0APacket ::= SEQUENCE %7B%0A    foo FOO%0A%7D%0AEND%0A%0AON-API DEFINITIONS AUTOMATIC TAGS ::=%0ABEGIN%0AFOO ::= SEQUENCE %7B%0A    bar BAR,%0A    baz BAZ%0A%7D%0ABAR ::= OCTET STRING (SIZE(3))%0ABAZ ::= BIT STRING (SIZE(8))%0AEND%0A%3C/pre%3E%0A*%0A *%0A */%0Apublic class UperEncoderQuestion1Test %7B%0A    private final static Logger logger = LoggerFactory.getLogger(UperEncoderQuestion1Test.class);%0A%0A    @Sequence%0A    public static class Foo %7B%0A        Bar bar;%0A        Baz baz;%0A%0A        public Foo(Bar bar, Baz baz) %7B this.bar = bar; this.baz = baz; %7D%0A    %7D%0A%0A    @SizeRange(maxValue = 3, minValue = 3)  // @SizeRange with equal bounds is a temporary solution until @FixedSize is implemented for SEQUENCE OF.%0A    public static class Bar extends Asn1SequenceOf%3CByte%3E %7B%0A        // Two constructors -- choose any, or add more.%0A        public Bar(Byte... coll)          %7B this(Arrays.asList(coll)); %7D%0A        public Bar(Collection%3CByte%3E coll) %7B super(coll); %7D%0A    %7D%0A%0A    @Bitstring%0A    @FixedSize(8)%0A    public static class Baz extends Asn1VarSizeBitstring %7B%0A%0A        // Two constructors -- choose any.%0A        public Baz(BitSet bitset)            %7B super(bitset); %7D%0A        public Baz(Collection%3CBoolean%3E coll) %7B super(coll); %7D%0A    %7D%0A%0A    @Test public void QuestionTest() throws IllegalArgumentException, IllegalAccessException %7B%0A       Object pdu =%0A                new Foo(%0A                    new Bar( (byte) 0xff, (byte) 0xff, (byte) 0xff),%0A                    new Baz(BitSet.valueOf(new byte%5B%5D %7B(byte) 0xff%7D))%0A              );%0A        byte%5B%5D encoded = UperEncoder.encode(pdu);%0A        logger.debug(%22data hex: %7B%7D%22, UperEncoder.hexStringFromBytes(encoded));%0A        assertEquals(%22FFFFFFFF%22,%0A                UperEncoder.hexStringFromBytes(encoded));%0A    %7D%0A%7D%0A

Add test with example of encoding Octet String and Bit String