assertEquals("number of entries incremented on last invocation", -2, this.queueSizeListener.getLastIncrementEntries());
assertEquals("number of bytes incremented on last invocation", -2*queueEntries[0].getSizeInBytes(), this.queueSizeListener.getLastIncrementBytes());
assertEquals(ME+": Wrong number removed", 2, numRemoved);
assertEquals(ME+": Wrong size", 1, queue.getNumOfEntries());
I_QueueEntry result = queue.peek();
assertEquals(ME+": Wrong timestamp", queueEntries[1].getUniqueId(), result.getUniqueId());
queue.clear();
log.info("#2 Success, fill and random remove");
}
//========== Test 3: removeRandom 5 from 3
{
DummyEntry[] queueEntries = {
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true),
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true),
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true)
};
queue.put(queueEntries, false);
I_QueueEntry[] dataIdArr = {
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true),
queueEntries[0],
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true),
new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true),
queueEntries[2],
};
long numRemoved = 0L;
boolean[] tmpArr = queue.removeRandom(dataIdArr);
for (int i=0; i < tmpArr.length; i++) if(tmpArr[i]) numRemoved++;
assertEquals("number of entries incremented on last invocation", -2, this.queueSizeListener.getLastIncrementEntries());
assertEquals("number of bytes incremented on last invocation", -2*queueEntries[0].getSizeInBytes(), this.queueSizeListener.getLastIncrementBytes());
assertEquals(ME+": Wrong number removed", 2, numRemoved);
assertEquals(ME+": Wrong size", 1, queue.getNumOfEntries());
I_QueueEntry entry = queue.peek();
assertTrue("Missing entry", (I_QueueEntry)null != entry);
assertEquals(ME+": Wrong entry removed", queueEntries[1].getUniqueId(), entry.getUniqueId());
queue.clear();
log.info("#3 Success, fill and random remove");
}