while(System.currentTimeMillis() < limit) {
Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
try {
//testing outgoing sequence reports
SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
//testing incoming sequence reports
List incomingSequenceReports = SandeshaClient.getIncomingSequenceReports(configContext);
assertEquals(incomingSequenceReports.size(),1);
SequenceReport incomingSequenceReport = (SequenceReport) incomingSequenceReports.get(0);
assertEquals(incomingSequenceReport.getCompletedMessages().size(),2);
assertNotNull(incomingSequenceReport.getSequenceID());
assertEquals(incomingSequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_IN);
assertNotNull(incomingSequenceReport.getInternalSequenceID());
assertEquals(incomingSequenceReport.getSequenceID(),incomingSequenceReport.getInternalSequenceID()); //for the incoming side, internalSequenceID==sequenceID
lastError = null;
break;
} catch(Error e) {
lastError = e;
}
}
if(lastError != null) throw lastError;
SandeshaClient.terminateSequence(serviceClient, sequenceKey);
SandeshaClient.waitUntilSequenceCompleted(serviceClient, sequenceKey);
SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
configContext.getListenerManager().stop();
serviceClient.cleanup();
}