use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testRemove.
public void testRemove() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
int prev_size = batch.size();
remove(batch, 1, 4);
System.out.println("batch = " + batch);
assert batch.size() == prev_size - 2;
batch.clear();
System.out.println("batch = " + batch);
assert batch.isEmpty();
msgs.forEach(batch::add);
System.out.println("batch = " + batch);
assert batch.size() == prev_size;
assert batch.capacity() == prev_size;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testGetMatchingMessages.
public void testGetMatchingMessages() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
Collection<Message> matching = batch.getMatchingMessages(UDP_ID, false);
assert matching.size() == batch.size();
assert batch.size() == msgs.size();
matching = batch.getMatchingMessages(FD_ID, true);
assert matching.size() == 1;
assert batch.size() == msgs.size() - 1;
int size = batch.size();
matching = batch.getMatchingMessages(UDP_ID, true);
assert matching.size() == size;
assert batch.isEmpty();
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testIterator8.
public void testIterator8() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
int index = 0;
for (Iterator<Message> it = batch.iterator(); it.hasNext(); ) {
it.next();
if (index == 1 || index == 2 || index == 3 || index == 10 || index == msgs.size() - 1)
it.remove();
index++;
}
System.out.println("batch = " + batch);
int count = 0;
for (Message ignored : batch) count++;
assert count == msgs.size() - 5;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testIsEmpty2.
public void testIsEmpty2() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
batch.add(new Message());
assert !batch.isEmpty();
batch.clear();
assert batch.isEmpty();
msgs.forEach(batch::add);
System.out.println("batch = " + batch);
for (Iterator<Message> it = batch.iterator(); it.hasNext(); ) {
it.next();
it.remove();
}
System.out.println("batch = " + batch);
assert batch.isEmpty();
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testIterator3.
/**
* Test removal via iterator
*/
public void testIterator3() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
for (Message msg : batch) if (msg.getHeader(UNICAST3_ID) != null)
batch.remove(msg);
System.out.println("batch = " + batch);
assert batch.size() == 3;
}
Aggregations