### Question:
CorbaConduit implements Conduit { public void close(Message message) throws IOException { if (message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT) != null) { BindingOperationInfo boi = message.getExchange().getBindingOperationInfo(); OperationType opType = boi.getExtensor(OperationType.class); try { if (message instanceof CorbaMessage) { buildRequest((CorbaMessage)message, opType); } message.getContent(OutputStream.class).close(); } catch (Exception ex) { LOG.log(Level.SEVERE, "Could not build the corba request"); throw new CorbaBindingException(ex); } } } CorbaConduit(EndpointInfo ei, EndpointReferenceType ref, OrbConfig config); OrbConfig getOrbConfig(); synchronized void prepareOrb(); void prepare(Message message); void close(Message message); EndpointReferenceType getTarget(); void close(); void setMessageObserver(MessageObserver observer); final EndpointReferenceType getTargetReference(EndpointReferenceType t); final String getAddress(); void buildRequest(CorbaMessage message, OperationType opType); NVList getArguments(CorbaMessage message); NamedValue getReturn(CorbaMessage message); ExceptionList getExceptionList(Map<TypeCode, RaisesType> exceptions,
                                             CorbaMessage message,
                                             OperationType opType); Request getRequest(CorbaMessage message,
                                 String opName,
                                 org.omg.CORBA.NVList nvlist,
                                 org.omg.CORBA.NamedValue ret,
                                 org.omg.CORBA.ExceptionList exList); Map<TypeCode, RaisesType> getOperationExceptions(
                                         OperationType operation,
                                         CorbaTypeMap map); MessageObserver getMessageObserver();  }### Answer:
@Test public void testClose() throws Exception { Method m = CorbaConduit.class.getDeclaredMethod("buildRequest", new Class[] {CorbaMessage.class, OperationType.class}); CorbaConduit conduit = EasyMock.createMockBuilder(CorbaConduit.class) .addMockedMethod(m).createMock(); org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class); CorbaMessage msg = control.createMock(CorbaMessage.class); EasyMock.expect(msg.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj); Exchange exg = control.createMock(Exchange.class); EasyMock.expect(msg.getExchange()).andReturn(exg); BindingOperationInfo bopInfo = control.createMock(BindingOperationInfo.class); EasyMock.expect(exg.getBindingOperationInfo()).andReturn(bopInfo); OperationType opType = control.createMock(OperationType.class); bopInfo.getExtensor(OperationType.class); EasyMock.expectLastCall().andReturn(opType); conduit.buildRequest(msg, opType); EasyMock.expectLastCall(); OutputStream os = control.createMock(OutputStream.class); EasyMock.expect(msg.getContent(OutputStream.class)).andReturn(os); os.close(); EasyMock.expectLastCall(); control.replay(); conduit.close(msg); control.verify(); }