Search in sources :

Example 36 with Message

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;
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 37 with Message

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());
}
Also used : Message(org.jgroups.Message)

Example 38 with Message

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);
}
Also used : Message(org.jgroups.Message)

Example 39 with Message

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());
}
Also used : Message(org.jgroups.Message)

Example 40 with Message

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);
}
Also used : Message(org.jgroups.Message)

Aggregations

Message (org.jgroups.Message)246 Address (org.jgroups.Address)50 MessageBatch (org.jgroups.util.MessageBatch)37 BytesMessage (org.jgroups.BytesMessage)31 NioMessage (org.jgroups.NioMessage)14 ObjectMessage (org.jgroups.ObjectMessage)14 EmptyMessage (org.jgroups.EmptyMessage)12 Test (org.testng.annotations.Test)12 Event (org.jgroups.Event)11 ToaHeader (org.jgroups.protocols.tom.ToaHeader)11 Test (org.junit.Test)11 IOException (java.io.IOException)8 JChannel (org.jgroups.JChannel)8 MessageID (org.jgroups.protocols.tom.MessageID)8 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)7 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)7 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)7 TimeoutException (java.util.concurrent.TimeoutException)6 Collectors (java.util.stream.Collectors)6 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)6