### Question:
CorbaObjectWriter { public void writeException(CorbaExceptionHandler exHandler) throws CorbaBindingException { Exception exType = (Exception)exHandler.getType(); List<CorbaObjectHandler> exMembers = exHandler.getMembers(); stream.write_string(exType.getRepositoryID()); for (int i = 0; i < exMembers.size(); ++i) { this.write(exMembers.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 testWriteException() { short code = 12345; String message = "54321"; String reposID = "IDL:org.apache.cxf.TestException/1.0"; QName exceptIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "exception", CorbaConstants.NP_WSDL_CORBA); QName shortIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA); QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA); Exception exceptType = new Exception(); exceptType.setName("TestException"); exceptType.setRepositoryID(reposID); MemberType m1 = new MemberType(); m1.setIdltype(shortIdlType); m1.setName("code"); MemberType m2 = new MemberType(); m2.setIdltype(stringIdlType); m2.setName("message"); exceptType.getMember().add(m1); exceptType.getMember().add(m2); StructMember[] exceptMembers = new StructMember[2]; exceptMembers[0] = new StructMember("code", orb.get_primitive_tc(TCKind.tk_short), null); exceptMembers[1] = new StructMember("message", orb.get_primitive_tc(TCKind.tk_string), null); TypeCode exceptTC = orb.create_exception_tc(reposID, "TestException", exceptMembers); CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType, exceptTC, exceptType); CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName("code"), shortIdlType, exceptMembers[0].type, null); member1.setValueFromData(Short.toString(code)); CorbaPrimitiveHandler member2 = new CorbaPrimitiveHandler(new QName("message"), stringIdlType, exceptMembers[1].type, null); member2.setValueFromData(message); obj.addMember(member1); obj.addMember(member2); OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); writer.writeException(obj); InputStream iStream = oStream.create_input_stream(); String readId = iStream.read_string(); assertEquals(readId, reposID); short readCode = iStream.read_short(); assertTrue(readCode == code); String readMessage = iStream.read_string(); assertEquals(readMessage, message); }