use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testReplaceIf.
public void testReplaceIf() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
System.out.println("batch = " + batch);
int size = batch.size();
int removed = batch.replaceIf(msg -> msg.getHeader(UNICAST3_ID) != null, null, true);
System.out.println("batch = " + batch);
assert batch.size() == size - removed;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testIterator5.
public void testIterator5() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
Iterator<Message> itr = batch.iterator();
itr.remove();
// didn't remove anything
assert batch.size() == msgs.size();
for (Iterator<Message> it = batch.iterator(); it.hasNext(); ) {
Message msg = it.next();
if (msg != null && msg.getHeader(UNICAST3_ID) != null)
it.remove();
}
System.out.println("batch = " + batch);
assert batch.size() == 3;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testAddBatch2.
public void testAddBatch2() {
MessageBatch other = new MessageBatch(3);
List<Message> msgs = createMessages();
msgs.forEach(other::add);
int other_size = other.size();
MessageBatch batch = new MessageBatch(5);
batch.add(other);
System.out.println("batch = " + batch);
assert batch.size() == other_size;
assert batch.capacity() >= other.capacity();
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testAddBatch.
public void testAddBatch() {
MessageBatch batch = new MessageBatch(3), other = new MessageBatch(3);
List<Message> msgs = createMessages();
msgs.forEach(other::add);
assert other.size() == msgs.size();
batch.add(other);
assert batch.size() == msgs.size() : "batch: " + batch;
assert batch.size() == other.size();
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testSet.
public void testSet() {
List<Message> msgs = createMessages();
Message msg = msgs.get(5);
MessageBatch batch = new MessageBatch(msgs);
assert get(batch, 5) == msg;
set(batch, 4, msg);
assert get(batch, 4) == msg;
}
Aggregations