### Question:
SourceSequence extends AbstractSequence { long nextMessageNumber() { return nextMessageNumber(null, 0, false); } SourceSequence(Identifier i, ProtocolVariation pv);  SourceSequence(Identifier i, Date e, Identifier oi, ProtocolVariation pv);  SourceSequence(Identifier i, Date e, Identifier oi, long cmn, boolean lm, ProtocolVariation pv); long getCurrentMessageNr(); boolean isLastMessage(); Identifier getOfferingSequenceIdentifier(); String getEndpointIdentifier(); Date getExpires(); boolean offeredBy(Identifier sid); boolean needAcknowledge(long num); boolean allAcknowledged(); void setAcknowledged(SequenceAcknowledgement ack); Source getSource(); void setExpires(Expires ex); long nextMessageNumber(Identifier inSeqId, long inMsgNumber, boolean last); synchronized void setTarget(EndpointReferenceType to); synchronized EndpointReferenceType getTarget();  }### Answer:
@Test public void testNextMessageNumber() throws RMException { SourceSequence seq = null; setUpSource(); rq.purgeAcknowledged(EasyMock.isA(SourceSequence.class)); EasyMock.expectLastCall().anyTimes(); control.replay(); seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408); seq.setSource(source); assertFalse(nextMessages(seq, 10)); control.verify(); seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(1); assertTrue(nextMessages(seq, 10)); assertEquals(1, seq.getCurrentMessageNr()); control.verify(); seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(5); assertFalse(nextMessages(seq, 2)); control.verify(); seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(0); stp.setMaxRanges(3); acknowledge(seq, 1, 2, 4, 5, 6, 8, 9, 10); assertTrue(nextMessages(seq, 10)); assertEquals(1, seq.getCurrentMessageNr()); control.verify(); seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(0); stp.setMaxRanges(4); acknowledge(seq, 1, 2, 4, 5, 6, 8, 9, 10); assertFalse(nextMessages(seq, 10)); control.verify(); }