### Question:
Proxy { void terminate(SourceSequence ss) throws RMException { ProtocolVariation protocol = ss.getProtocol(); RMConstants constants = protocol.getConstants(); OperationInfo oi = reliableEndpoint.getEndpoint(protocol).getEndpointInfo() .getService().getInterface().getOperation(constants.getTerminateSequenceOperationName()); TerminateSequenceType ts = new TerminateSequenceType(); ts.setIdentifier(ss.getIdentifier()); ts.setLastMsgNumber(ss.getCurrentMessageNr()); EncoderDecoder codec = protocol.getCodec(); invoke(oi, protocol, new Object[] {codec.convertToSend(ts)}, this.sequenceContext); } Proxy(RMEndpoint rme); CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo,
             boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context);  }### Answer:
@Test public void testTerminate() throws NoSuchMethodException, RMException { Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] {OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class}); Proxy proxy = EasyMock.createMockBuilder(Proxy.class) .addMockedMethod(m).createMock(control); proxy.setReliableEndpoint(rme); Endpoint endpoint = control.createMock(Endpoint.class); EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes(); EndpointInfo epi = control.createMock(EndpointInfo.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes(); ServiceInfo si = control.createMock(ServiceInfo.class); EasyMock.expect(epi.getService()).andReturn(si).anyTimes(); InterfaceInfo ii = control.createMock(InterfaceInfo.class); EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes(); OperationInfo oi = control.createMock(OperationInfo.class); EasyMock.expect(ii.getOperation(RM10Constants.TERMINATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes(); SourceSequence ss = control.createMock(SourceSequence.class); Identifier id = control.createMock(Identifier.class); EasyMock.expect(ss.getIdentifier()).andReturn(id).anyTimes(); EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes(); expectInvoke(proxy, oi, null); control.replay(); proxy.terminate(ss); }