}
public void testResizeWithPurgeAndGetOfNonExistingElement() {
RetransmitTable table=new RetransmitTable(3, 10, 0);
for(long i=0; i < 50; i++)
addAndGet(table, i, "hello-" + i);
System.out.println("table: " + table);
// now remove 15 messages
for(long i=0; i <= 15; i++) {
Message msg=table.remove(i);
assert msg.getObject().equals("hello-" + i);
}
System.out.println("table after removal of seqno 15: " + table);
table.purge(15);
System.out.println("now triggering a resize() by addition of seqno=55");
addAndGet(table, 55, "hello-55");
// now we have elements 40-49 in row 1 and 55 in row 2:
List<String> list=new ArrayList<String>(20);
for(int i=16; i < 50; i++)
list.add("hello-" + i);
list.add("hello-55");
for(long i=table.getOffset(); i < table.capacity() + table.getOffset(); i++) {
Message msg=table.get(i);
if(msg != null) {
String message=(String)msg.getObject();
System.out.println(i + ": " + message);
list.remove(message);
}
}
System.out.println("table:\n" + table.dumpMatrix());
assert list.isEmpty() : " list: " + Util.print(list);
}