### Question:
Servant implements Invoker { public Object terminateSequence(Message message) { LOG.fine("Terminating sequence"); final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(message); EncoderDecoder codec = protocol.getCodec(); TerminateSequenceType terminate = codec.convertReceivedTerminateSequence(getParameter(message)); Destination destination = reliableEndpoint.getDestination(); Identifier sid = terminate.getIdentifier(); DestinationSequence terminatedSeq = destination.getSequence(sid); if (null != terminatedSeq) { destination.terminateSequence(terminatedSeq); } Source source = reliableEndpoint.getSource(); for (SourceSequence outboundSeq : source.getAllSequences()) { if (outboundSeq.offeredBy(sid) && !outboundSeq.isLastMessage()) { if (outboundSeq.getCurrentMessageNr() == 0) { source.removeSequence(outboundSeq); } break; } } TerminateSequenceResponseType terminateResponse = null; if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) { AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false); Message outMessage = message.getExchange().getOutMessage(); if (null == outMessage) { outMessage = ContextUtils.createMessage(message.getExchange()); message.getExchange().setOutMessage(outMessage); } if (null != outMessage) { RMContextUtils.storeMAPs(maps, outMessage, false, false); } terminateResponse = new TerminateSequenceResponseType(); terminateResponse.setIdentifier(sid); } return terminateResponse; } Servant(RMEndpoint rme); Object invoke(Exchange exchange, Object o); void createSequenceResponse(CreateSequenceResponseType createResponse,
                                       ProtocolVariation protocol); Object terminateSequence(Message message); Object closeSequence(Message message);  }### Answer:
@Test public void testTerminateSequence() throws SequenceFault { RMEndpoint rme = control.createMock(RMEndpoint.class); RMManager manager = new RMManager(); Destination destination = new Destination(rme); Source source = new Source(rme); DestinationSequence seq = control.createMock(DestinationSequence.class); org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier(); sid.setValue("123"); EasyMock.expect(seq.getIdentifier()).andReturn(sid).anyTimes(); EasyMock.expect(rme.getDestination()).andReturn(destination).anyTimes(); EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes(); EasyMock.expect(rme.getSource()).andReturn(source).anyTimes(); control.replay(); Servant servant = new Servant(rme); destination.addSequence(seq, false); verifyTerminateSequenceDefault(servant, manager, "123", ProtocolVariation.RM10WSA200408); destination.addSequence(seq, false); verifyTerminateSequenceDefault(servant, manager, "123", ProtocolVariation.RM11WSA200508); }