### Question:
RMEndpoint { void shutdown() { for (DestinationSequence ds : getDestination().getAllSequences()) { ds.cancelDeferredAcknowledgments(); ds.cancelTermination(); } SourcePolicyType sp = manager.getSourcePolicy(); SequenceTerminationPolicyType stp = null; if (null != sp) { stp = sp.getSequenceTerminationPolicy(); } if (null != stp && stp.isTerminateOnShutdown()) { Collection<SourceSequence> seqs = source.getAllUnacknowledgedSequences(); LOG.log(Level.FINE, "Trying to terminate {0} sequences", seqs.size()); for (SourceSequence seq : seqs) { try { if (seq.isLastMessage()) { } else { getProxy().lastMessage(seq); } } catch (RMException ex) { } } } for (SourceSequence ss : getSource().getAllSequences()) { manager.getRetransmissionQueue().stop(ss); } for (DestinationSequence ds : getDestination().getAllSequences()) { manager.getRedeliveryQueue().stop(ds); } } RMEndpoint(RMManager m, Endpoint ae); RMManager getManager(); Endpoint getApplicationEndpoint(); Endpoint getEndpoint(ProtocolVariation protocol); Service getService(ProtocolVariation protocol); BindingInfo getBindingInfo(ProtocolVariation protocol); Proxy getProxy(); Servant getServant(); Destination getDestination(); void setDestination(Destination destination); Source getSource(); void setSource(Source source); long getLastApplicationMessage(); int getApplicationMessageCount(); void receivedApplicationMessage(); long getLastControlMessage(); int getControlMessageCount(); void receivedControlMessage(); Conduit getConduit(); RMConfiguration getConfiguration(); void handleAccept(String ssid, long number, Message msg); void handleAcknowledgment(String ssid, long number, Message msg);  }### Answer:
@Test public void testShutdown() { DestinationSequence ds = control.createMock(DestinationSequence.class); Identifier did = control.createMock(Identifier.class); EasyMock.expect(ds.getIdentifier()).andReturn(did).anyTimes(); EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes(); String d = "d"; EasyMock.expect(did.getValue()).andReturn(d).anyTimes(); SourceSequence ss = control.createMock(SourceSequence.class); Identifier sid = control.createMock(Identifier.class); EasyMock.expect(ss.getIdentifier()).andReturn(sid).anyTimes(); EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes(); String s = "s"; EasyMock.expect(sid.getValue()).andReturn(s).anyTimes(); ds.cancelDeferredAcknowledgments(); EasyMock.expectLastCall().anyTimes(); ds.cancelTermination(); EasyMock.expectLastCall().anyTimes(); RetransmissionQueue queue = control.createMock(RetransmissionQueue.class); EasyMock.expect(manager.getRetransmissionQueue()).andReturn(queue).anyTimes(); queue.stop(ss); EasyMock.expectLastCall().anyTimes(); RedeliveryQueue dqueue = control.createMock(RedeliveryQueue.class); EasyMock.expect(manager.getRedeliveryQueue()).andReturn(dqueue).anyTimes(); dqueue.stop(ds); EasyMock.expectLastCall().anyTimes(); control.replay(); rme.getDestination().addSequence(ds, false); rme.getSource().addSequence(ss, false); rme.shutdown(); }