### Question:
CorbaObjectReader { public void readSequence(CorbaObjectHandler obj) throws CorbaBindingException { if (obj instanceof CorbaOctetSequenceHandler) { int length = stream.read_ulong(); byte[] value = new byte[length]; stream.read_octet_array(value, 0, length); ((CorbaOctetSequenceHandler) obj).setValue(value); } else { CorbaSequenceHandler sequenceObj = (CorbaSequenceHandler)obj; List<CorbaObjectHandler> seqElements = sequenceObj.getElements(); int length = stream.read_ulong(); List<CorbaObjectHandler> elements = new ArrayList<>(length); if (sequenceObj.getTemplateElement() != null) { sequenceObj.clear(); CorbaObjectHandler template = sequenceObj.getTemplateElement(); for (int i = 0; i < length; ++i) { CorbaObjectHandler seqElement; if (i < seqElements.size()) { seqElement = seqElements.get(i); } else { seqElement = initializeCorbaObjectHandler(template); } read(seqElement); elements.add(seqElement); } sequenceObj.setElements(elements); } else { for (int i = 0; i < length; ++i) { read(seqElements.get(i)); } sequenceObj.setElements(seqElements.subList(0, length)); } } } CorbaObjectReader(InputStream inStream); void read(CorbaObjectHandler obj); Boolean readBoolean(); Character readChar(); Character readWChar(); Byte readOctet(); Short readShort(); Integer readUShort(); Integer readLong(); long readULong(); Long readLongLong(); BigInteger readULongLong(); Float readFloat(); Double readDouble(); String readString(); String readWString(); Any readAny(); void readEnum(CorbaObjectHandler obj); void readStruct(CorbaStructHandler structObj); void readException(CorbaExceptionHandler exceptObj); void readFixed(CorbaFixedHandler fixedHandler); void readEnumDiscriminator(CorbaUnionHandler unionHandler, CorbaEnumHandler disc); void readUnion(CorbaUnionHandler unionHandler); void readArray(CorbaArrayHandler arrayObj); void readSequence(CorbaObjectHandler obj); void readObjectReference(CorbaObjectReferenceHandler objRefObj);  }### Answer:
@Test public void testReadSequence() { String[] data = {"one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one"}; OutputStream oStream = orb.create_output_stream(); oStream.write_long(data.length); for (int i = 0; i < data.length; ++i) { oStream.write_string(data[i]); } InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA); QName seqIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "sequence", CorbaConstants.NP_WSDL_CORBA); Sequence seqType = new Sequence(); seqType.setBound(data.length); seqType.setElemtype(stringIdlType); TypeCode seqTC = orb.create_sequence_tc(data.length, orb.get_primitive_tc(TCKind.tk_string)); CorbaSequenceHandler obj = new CorbaSequenceHandler(new QName("Seq"), seqIdlType, seqTC, seqType); for (int i = 0; i < data.length; ++i) { CorbaPrimitiveHandler nestedObj = new CorbaPrimitiveHandler(new QName("item"), stringIdlType, orb.get_primitive_tc(TCKind.tk_string), null); obj.addElement(nestedObj); } reader.readSequence(obj); int length = obj.getElements().size(); for (int i = 0; i < length; ++i) { assertEquals(((CorbaPrimitiveHandler)obj.getElement(i)).getDataFromValue(), data[i]); } }