public void testRemoveWithFilter() {
Filter<Message> filter=new Filter<Message>() {
public boolean accept(Message msg) {return msg != null && msg.isTransientFlagSet(Message.TransientFlag.OOB_DELIVERED);}
};
MessageBatch batch=new MessageBatch(10);
for(int i=1; i <= 10; i++) {
Message msg=new Message(null, i);
if(i % 2 == 0)
msg.setTransientFlag(Message.TransientFlag.OOB_DELIVERED);
batch.add(msg);
}
System.out.println("batch = " + batch);
assert batch.size() == 10;
batch.remove(filter);
System.out.println("batch = " + batch);
assert batch.size() == 5;
for(int i=0; i < 5; i++)
batch.add(new Message(null, i).setTransientFlag(Message.TransientFlag.OOB_DELIVERED));
System.out.println("batch = " + batch);
batch.replace(filter, null, false);
assert batch.size() == 9;
}