assertThat(messages.length, is(1));
Message message = messages[0];
assertThat(milliSecondDateDiff(message.getSentDate(), sentDate), lessThan(3000L));
if (checkReceivedDate) {
assertThat(milliSecondDateDiff(message.getReceivedDate(), new Date()), lessThan(3000L));
<BUG>}
}</BUG>
private long milliSecondDateDiff(Date date1, Date date2) {
long diff = date1.getTime() - date2.getTime();
return Math.abs(diff);

assertThat(messages.length, is(1));
Message message = messages[0];
assertThat(milliSecondDateDiff(message.getSentDate(), sentDate), lessThan(3000L));
if (checkReceivedDate) {
assertThat(milliSecondDateDiff(message.getReceivedDate(), new Date()), lessThan(3000L));
}
} finally {
retriever.close();
}
}
private long milliSecondDateDiff(Date date1, Date date2) {
long diff = date1.getTime() - date2.getTime();
return Math.abs(diff);
