}
public void testGetAckRangesFromRangeStringGapFilling () {
//build a range string to represent the completed messages
RangeString rangeString = new RangeString();
rangeString.addRange(new Range(1,3));
rangeString.addRange(new Range(4));
//insert a gap - number 5 is missing
rangeString.addRange(new Range(6));
//insert a gap - 7 and 8 are missing
rangeString.addRange(new Range(9, 10));
ArrayList<Range> list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
assertNotNull(list);
//we expect 3 ranges: [1-4] [6] [9-10]
assertEquals(list.size(),3);
Iterator<Range> it = list.iterator();
Range ackRange = null;
ackRange = (Range) it.next();
assertNotNull(ackRange);
assertEquals(ackRange.lowerValue,1);
assertEquals(ackRange.upperValue,4);
ackRange = null;
ackRange = (Range) it.next();
assertNotNull(ackRange);
assertEquals(ackRange.lowerValue,6);
assertEquals(ackRange.upperValue,6);
ackRange = null;
ackRange = (Range) it.next();
assertNotNull(ackRange);
assertEquals(ackRange.lowerValue,9);
assertEquals(ackRange.upperValue,10);
assertFalse(it.hasNext());
//ok, now plug a gap at msg 5
rangeString.addRange(new Range(5));
list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
assertNotNull(list);
//we expect 2 ranges: [1-6] [9-10]
it = list.iterator();
ackRange = null;
ackRange = (Range) it.next();
assertNotNull(ackRange);
assertEquals(ackRange.lowerValue,1);
assertEquals(ackRange.upperValue,6);
ackRange = null;
ackRange = (Range) it.next();
assertNotNull(ackRange);
assertEquals(ackRange.lowerValue,9);
assertEquals(ackRange.upperValue,10);
assertFalse(it.hasNext());
//plug all of the gaps - 7 and 8
rangeString.addRange(new Range(8));
rangeString.addRange(new Range(7,8));
list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
assertNotNull(list);
//we expect 1 ranges: [1-10]
it = list.iterator();
ackRange = null;