use of org.jgroups.Message in project JGroups by belaban.
the class MessageBatchTest method testIterator2.
public void testIterator2() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
int count = 0;
for (Message ignored : batch) count++;
assert count == msgs.size();
remove(batch, 3, 5, 10);
count = 0;
for (Message ignored : batch) count++;
assert count == msgs.size() - 3;
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testSetBufferWithNullBuffer.
public static void testSetBufferWithNullBuffer() {
byte[] buf = { 'b', 'e', 'l', 'a' };
Message m1 = new Message();
// dummy data with non 0 oiffset and length
m1.setBuffer(buf, 1, 2);
Assert.assertEquals(1, m1.getOffset());
Assert.assertEquals(2, m1.getLength());
// dummy offset and length, is ignored
m1.setBuffer(null, 1, 2);
Assert.assertEquals(0, m1.getOffset());
Assert.assertEquals(0, m1.getLength());
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testSizeMessageWithDestAndSrcAndFlags.
public static void testSizeMessageWithDestAndSrcAndFlags() throws Exception {
Message msg = new Message(UUID.randomUUID()).src(UUID.randomUUID());
msg.setFlag(Message.Flag.OOB);
msg.setFlag(Message.Flag.DONT_BUNDLE);
_testSize(msg);
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testGetRawBuffer.
public static void testGetRawBuffer() {
byte[] buf = { 'b', 'e', 'l', 'a', 'b', 'a', 'n' };
Message m1 = new Message(null, buf, 0, 4);
Message m2 = new Message(null, buf, 4, 3);
Assert.assertEquals(buf.length, m1.getRawBuffer().length);
Assert.assertEquals(4, m1.getBuffer().length);
Assert.assertEquals(4, m1.getLength());
Assert.assertEquals(buf.length, m2.getRawBuffer().length);
Assert.assertEquals(3, m2.getBuffer().length);
Assert.assertEquals(3, m2.getLength());
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testClearFlags.
public static void testClearFlags() {
Message msg = new Message();
msg.setFlag(Message.Flag.OOB);
assert msg.isFlagSet(Message.Flag.OOB);
msg.clearFlag(Message.Flag.OOB);
assert !msg.isFlagSet(Message.Flag.OOB);
msg.clearFlag(Message.Flag.OOB);
assert !msg.isFlagSet(Message.Flag.OOB);
msg.setFlag(Message.Flag.OOB);
assert msg.isFlagSet(Message.Flag.OOB);
}
Aggregations