Search in sources :

Example 11 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testPut.

public void testPut() throws Exception {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A").put("name", Util.objectToByteBuffer("Bela")).put("age", Util.objectToByteBuffer(49)).put("bool", Util.objectToByteBuffer(true));
    assert uuid.keyExists("name");
    assert uuid.keyExists("bool");
    byte[] val = uuid.get("age");
    assert Util.objectFromByteBuffer(val).equals(49);
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 12 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testmarshallingWithNullValues.

public void testmarshallingWithNullValues() throws Exception {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A");
    byte[] value = Util.objectToByteBuffer("Bela");
    for (int i = 1; i <= 5; i++) uuid.put(String.valueOf(i), i % 2 == 0 ? value : null);
    int size = uuid.serializedSize();
    byte[] buffer = Util.streamableToByteBuffer(uuid);
    assert size == buffer.length : "expected size of " + size + ", but got " + buffer.length;
    ExtendedUUID uuid2 = Util.streamableFromByteBuffer(ExtendedUUID::new, buffer);
    for (int i = 1; i <= 5; i++) {
        byte[] val = uuid.get(String.valueOf(i));
        boolean null_val = i % 2 != 0;
        if (null_val)
            assert val == null;
        else
            assert val != null && val.length == value.length;
    }
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 13 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testCreation.

public void testCreation() {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A").setFlag(RELAY2.site_master_flag);
    System.out.println("uuid = " + uuid);
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 14 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testMarshallingNullHashMap.

public void testMarshallingNullHashMap() throws Exception {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A");
    int size = uuid.serializedSize();
    byte[] buffer = Util.streamableToByteBuffer(uuid);
    assert size == buffer.length : "expected size of " + size + ", but got " + buffer.length;
    Util.streamableFromByteBuffer(ExtendedUUID::new, buffer);
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Aggregations

ExtendedUUID (org.jgroups.util.ExtendedUUID)14