### Question:
CorbaObjectWriter { public void writeSequence(CorbaObjectHandler obj) throws CorbaBindingException { if (obj instanceof CorbaOctetSequenceHandler) { byte[] value = ((CorbaOctetSequenceHandler) obj).getValue(); stream.write_ulong(value.length); stream.write_octet_array(value, 0, value.length); } else { CorbaSequenceHandler seqHandler = (CorbaSequenceHandler)obj; List<CorbaObjectHandler> seqElements = seqHandler.getElements(); int length = seqElements.size(); stream.write_ulong(length); for (int i = 0; i < length; ++i) { this.write(seqElements.get(i)); } } } CorbaObjectWriter(OutputStream outStream); void write(CorbaObjectHandler obj); void writeBoolean(Boolean b); void writeChar(Character c); void writeWChar(Character c); void writeOctet(Byte b); void writeShort(Short s); void writeUShort(Integer s); void writeLong(Integer l); void writeULong(Long l); void writeLongLong(Long l); void writeULongLong(java.math.BigInteger l); void writeFloat(Float f); void writeDouble(Double d); void writeString(String s); void writeWString(String s); void writeAny(CorbaAnyHandler anyHandler); void writeEnum(CorbaEnumHandler enumHandler); void writeStruct(CorbaStructHandler structHandler); void writeException(CorbaExceptionHandler exHandler); void writeFixed(CorbaFixedHandler fixedHandler); void writeUnion(CorbaObjectHandler obj); void writeArray(CorbaArrayHandler arrayHandler); void writeSequence(CorbaObjectHandler obj); void writeObjectReference(CorbaObjectReferenceHandler objHandler);  }### Answer:
@Test public void testWriteSequence() { String[] data = {"one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one"}; 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); nestedObj.setValueFromData(data[i]); obj.addElement(nestedObj); } OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); writer.writeSequence(obj); InputStream iStream = oStream.create_input_stream(); int length = iStream.read_long(); for (int i = 0; i < length; ++i) { String val = iStream.read_string(); assertEquals(val, data[i]); } }