Search in sources :

Example 6 with AsciiString

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

the class AsciiStringTest method testHashcode.

public void testHashcode() {
    AsciiString str = new AsciiString("hello"), str2 = new AsciiString("hello");
    assert str.hashCode() == str2.hashCode();
    str2 = new AsciiString("hello world");
    assert str.hashCode() != str2.hashCode();
    Map<AsciiString, Integer> map = new HashMap<>(5);
    map.put(new AsciiString("a"), 1);
    assert map.get(new AsciiString("a")) == 1;
    map.put(new AsciiString("b"), 2);
    assert map.get(new AsciiString("b")) == 2;
    map.put(new AsciiString("a"), 2);
    assert map.get(new AsciiString("a")) == 2;
}
Also used : HashMap(java.util.HashMap) AsciiString(org.jgroups.util.AsciiString)

Example 7 with AsciiString

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

the class BitsTest method testAsciiString.

public void testAsciiString() throws Exception {
    AsciiString[] strings = { null, new AsciiString("hello world"), new AsciiString("1") };
    for (AsciiString str : strings) {
        byte[] buf = marshall(str);
        AsciiString s = unmarshallAsciiString(buf);
        assert str == null && s == null || str.equals(s);
    }
}
Also used : AsciiString(org.jgroups.util.AsciiString)

Aggregations

AsciiString (org.jgroups.util.AsciiString)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 Address (org.jgroups.Address)2 PhysicalAddress (org.jgroups.PhysicalAddress)2 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 ManagedOperation (org.jgroups.annotations.ManagedOperation)1