### Question:
Servant implements Invoker { Object createSequence(Message message) { LOG.fine("Creating sequence"); final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(message); AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false); Message outMessage = message.getExchange().getOutMessage(); if (null != outMessage) { RMContextUtils.storeMAPs(maps, outMessage, false, false); } EncoderDecoder codec = protocol.getCodec(); CreateSequenceType create = codec.convertReceivedCreateSequence(getParameter(message)); Destination destination = reliableEndpoint.getDestination(); CreateSequenceResponseType createResponse = new CreateSequenceResponseType(); createResponse.setIdentifier(destination.generateSequenceIdentifier()); DestinationPolicyType dp = reliableEndpoint.getManager().getDestinationPolicy(); if (dp.getMaxSequences() > 0 && destination.getProcessingSequenceCount() >= dp.getMaxSequences()) { throw new RuntimeException("Sequence creation refused"); } Duration supportedDuration = dp.getSequenceExpiration(); if (null == supportedDuration) { supportedDuration = DatatypeFactory.PT0S; } Expires ex = create.getExpires(); if (null != ex) { Duration effectiveDuration = ex.getValue(); if (DatatypeFactory.PT0S.equals(effectiveDuration) || (!DatatypeFactory.PT0S.equals(supportedDuration) && supportedDuration.isShorterThan(effectiveDuration))) { effectiveDuration = supportedDuration; } ex = new Expires(); ex.setValue(effectiveDuration); createResponse.setExpires(ex); } OfferType offer = create.getOffer(); if (null != offer) { AcceptType accept = new AcceptType(); if (dp.isAcceptOffers()) { Source source = reliableEndpoint.getSource(); LOG.fine("Accepting inbound sequence offer"); accept.setAcksTo(RMUtils.createReference(maps.getTo().getValue())); SourceSequence seq = new SourceSequence(offer.getIdentifier(), null, createResponse.getIdentifier(), protocol); seq.setExpires(offer.getExpires()); seq.setTarget(create.getAcksTo()); source.addSequence(seq); source.setCurrent(createResponse.getIdentifier(), seq); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Making offered sequence the current sequence for responses to " + createResponse.getIdentifier().getValue()); } } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Refusing inbound sequence offer"); } accept.setAcksTo(RMUtils.createNoneReference()); } createResponse.setAccept(accept); } DestinationSequence seq = new DestinationSequence(createResponse.getIdentifier(), create.getAcksTo(), destination, protocol); seq.setCorrelationID(maps.getMessageID().getValue()); destination.addSequence(seq); LOG.fine("returning " + createResponse); return codec.convertToSend(createResponse); } 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 testCreateSequence() throws SequenceFault { RMEndpoint rme = control.createMock(RMEndpoint.class); RMManager manager = new RMManager(); Destination destination = new Destination(rme); SequenceIdentifierGenerator generator = manager.new DefaultSequenceIdentifierGenerator(); manager.setIdGenerator(generator); EasyMock.expect(rme.getDestination()).andReturn(destination).anyTimes(); EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes(); control.replay(); Servant servant = new Servant(rme); verifyCreateSequenceDefault(servant, manager); verifyCreateSequenceExpiresSetAtDestination(servant, manager); verifyCreateSequenceExpiresSetAtSource(servant, manager); verifyCreateSequenceExpiresSetAtBoth(servant, manager); }