Search in sources :

Example 1 with Node

use of org.voltdb.RateLimitedClientNotifier.Node in project voltdb by VoltDB.

the class TestRateLimitedClientNotifier method testNode.

/*
     * Check that equality and hash code work as expected
     * where nodes that are heads of identical lists are identical
     * and nodes that have the same supplier and next node are also
     * equal
     */
@Test
public void testNode() throws Exception {
    Supplier<DeferredSerialization> sup = getSupplier(null);
    Node n = new Node(sup, null);
    Node n2 = new Node(sup, null);
    Node diffSup = new Node(getSupplier(null), null);
    assertFalse(n.equals(null));
    assertTrue(n.equals(n2));
    assertEquals(n.hashCode(), n2.hashCode());
    assertTrue(n2.equals(n));
    assertTrue(n.equals(n));
    assertFalse(n.equals(diffSup));
    assertFalse(n.hashCode() == diffSup.hashCode());
    Supplier<DeferredSerialization> sup2 = getSupplier(null);
    Node n3 = new Node(sup2, n);
    assertFalse(n3.equals(n2));
    assertFalse(n3.hashCode() == n2.hashCode());
    Node n3_2 = new Node(sup2, n);
    Supplier<DeferredSerialization> sup3 = getSupplier(null);
    Node n4 = new Node(sup3, n3);
    Node n4_2 = new Node(sup3, n3_2);
    assertTrue(n4.equals(n4_2));
    assertTrue(n4.hashCode() == n4_2.hashCode());
}
Also used : Node(org.voltdb.RateLimitedClientNotifier.Node) DeferredSerialization(org.voltcore.utils.DeferredSerialization) Test(org.junit.Test)

Example 2 with Node

use of org.voltdb.RateLimitedClientNotifier.Node in project voltdb by VoltDB.

the class TestRateLimitedClientNotifier method testNodeCaching.

/*
     * Check caching postfixes of nodes works
     */
@Test
public void testNodeCaching() throws Exception {
    Supplier<DeferredSerialization> sup = getSupplier(null);
    Node n = getNode(sup, null);
    Node n2 = getNode(sup, null);
    Node diffSup = getNode(getSupplier(null), null);
    assertFalse(n.equals(null));
    assertTrue(n.equals(n2));
    assertEquals(n.hashCode(), n2.hashCode());
    assertTrue(n2.equals(n));
    assertTrue(n.equals(n));
    assertFalse(n.equals(diffSup));
    assertFalse(n.hashCode() == diffSup.hashCode());
    Supplier<DeferredSerialization> sup2 = getSupplier(null);
    Node n3 = getNode(sup2, n);
    assertFalse(n3.equals(n2));
    assertFalse(n3.hashCode() == n2.hashCode());
    Node n3_2 = getNode(sup2, n);
    Supplier<DeferredSerialization> sup3 = getSupplier(null);
    Node n4 = getNode(sup3, n3);
    Node n4_2 = getNode(sup3, n3_2);
    assertTrue(n4.equals(n4_2));
    assertTrue(n4.hashCode() == n4_2.hashCode());
    assertEquals(cache.size(), 4);
}
Also used : Node(org.voltdb.RateLimitedClientNotifier.Node) DeferredSerialization(org.voltcore.utils.DeferredSerialization) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DeferredSerialization (org.voltcore.utils.DeferredSerialization)2 Node (org.voltdb.RateLimitedClientNotifier.Node)2