### Question:
RetransmissionQueueImpl implements RetransmissionQueue { protected ResendCandidate createResendCandidate(Message message) { return new ResendCandidate(message); } RetransmissionQueueImpl(RMManager m); RMManager getManager(); void setManager(RMManager m); void addUnacknowledged(Message message); synchronized int countUnacknowledged(SourceSequence seq); int countUnacknowledged(); boolean isEmpty(); void purgeAcknowledged(SourceSequence seq); void purgeAll(SourceSequence seq); List<Long> getUnacknowledgedMessageNumbers(SourceSequence seq); RetryStatus getRetransmissionStatus(SourceSequence seq, long num); Map<Long, RetryStatus> getRetransmissionStatuses(SourceSequence seq); void start(); void stop(SourceSequence seq); void suspend(SourceSequence seq); void resume(SourceSequence seq);  }### Answer:
@Test public void testResendCandidateCtor() { SoapMessage message = createMock(SoapMessage.class); setupMessagePolicies(message); control.replay(); long now = System.currentTimeMillis(); RetransmissionQueueImpl.ResendCandidate candidate = queue.createResendCandidate(message); assertSame(message, candidate.getMessage()); assertEquals(0, candidate.getRetries()); Date refDate = new Date(now + 5000); assertFalse(candidate.getNext().before(refDate)); refDate = new Date(now + 7000); assertFalse(candidate.getNext().after(refDate)); assertFalse(candidate.isPending()); }
@Test public void testResendCandidateAttempted() { SoapMessage message = createMock(SoapMessage.class); setupMessagePolicies(message); ready(true); long now = System.currentTimeMillis(); RetransmissionQueueImpl.ResendCandidate candidate = queue.createResendCandidate(message); candidate.attempted(); assertEquals(1, candidate.getRetries()); Date refDate = new Date(now + 15000); assertFalse(candidate.getNext().before(refDate)); refDate = new Date(now + 17000); assertFalse(candidate.getNext().after(refDate)); assertFalse(candidate.isPending()); }
@Test public void testResendCandidateMaxRetries() { SoapMessage message = createMock(SoapMessage.class); setupMessagePolicies(message); setupRetryPolicy(message); ready(true); RetransmissionQueueImpl.ResendCandidate candidate = queue.createResendCandidate(message); assertEquals(3, candidate.getMaxRetries()); Date next = null; for (int i = 1; i < 3; i++) { next = candidate.getNext(); candidate.attempted(); assertEquals(i, candidate.getRetries()); assertTrue(candidate.getNext().after(next)); } next = candidate.getNext(); candidate.attempted(); assertEquals(3, candidate.getRetries()); assertFalse(candidate.getNext().after(next)); }