Search in sources :

Example 41 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testSizeNullMessage.

public static void testSizeNullMessage() throws Exception {
    Message msg = new Message();
    _testSize(msg);
}
Also used : Message(org.jgroups.Message)

Example 42 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testSettingMultipleFlags.

public void testSettingMultipleFlags() {
    Message msg = new Message();
    msg.setFlag((Message.Flag[]) null);
    assert msg.getFlags() == 0;
    msg.setFlag(Message.Flag.OOB, Message.Flag.NO_FC, null, Message.Flag.DONT_BUNDLE);
    assert msg.isFlagSet(Message.Flag.OOB);
    assert msg.isFlagSet(Message.Flag.NO_FC);
    assert msg.isFlagSet(Message.Flag.DONT_BUNDLE);
}
Also used : Message(org.jgroups.Message)

Example 43 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testCopy.

public static void testCopy() {
    Message m1 = new Message(null, "Bela Ban");
    m1.setFlag(Message.Flag.OOB);
    m1.setTransientFlag(Message.TransientFlag.OOB_DELIVERED);
    Message m2 = m1.copy();
    Assert.assertEquals(m1.getOffset(), m2.getOffset());
    Assert.assertEquals(m1.getLength(), m2.getLength());
    assert m2.isFlagSet(Message.Flag.OOB);
    assert m2.isTransientFlagSet(Message.TransientFlag.OOB_DELIVERED);
}
Also used : Message(org.jgroups.Message)

Example 44 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testReadFromSkipPayload.

public void testReadFromSkipPayload() throws Exception {
    Message msg = new Message(Util.createRandomAddress("A"), "bela".getBytes()).src(Util.createRandomAddress("B"));
    addHeaders(msg);
    byte[] buf = Util.streamableToByteBuffer(msg);
    // ExposedByteArrayInputStream input=new ExposedByteArrayInputStream(buf);
    // DataInput in=new DataInputStream(input);
    ByteArrayDataInputStream in = new ByteArrayDataInputStream(buf);
    Message msg2 = new Message(false);
    int payload_position = msg2.readFromSkipPayload(in);
    msg2.setBuffer(buf, payload_position, buf.length - payload_position);
    assert msg2.getOffset() == payload_position;
    assert msg2.getLength() == msg.getLength();
    assert msg2.size() == msg.size();
    Message copy = msg2.copy();
    assert copy.getOffset() == payload_position;
    assert copy.getLength() == msg.getLength();
    assert copy.size() == msg2.size();
}
Also used : Message(org.jgroups.Message) ByteArrayDataInputStream(org.jgroups.util.ByteArrayDataInputStream)

Example 45 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testSizeMessageWithBuffer.

public static void testSizeMessageWithBuffer() throws Exception {
    Message msg = new Message(null, "bela".getBytes());
    _testSize(msg);
}
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