Search in sources :

Example 21 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_advance_afterAdvanceReturnsFalse.

@Test
public void testCursor_advance_afterAdvanceReturnsFalse() {
    hsa.ensure(randomKey(), randomKey());
    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.advance();
    cursor.advance();
    try {
        cursor.advance();
        fail("cursor.advance() returned false, but subsequent call did not throw AssertionError");
    } catch (AssertionError ignored) {
    }
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_valueAddress_whenDisposed.

@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testCursor_valueAddress_whenDisposed() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    hsa.dispose();
    cursor.valueAddress();
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_advance_whenEmpty.

@Test
public void testCursor_advance_whenEmpty() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    assertFalse(cursor.advance());
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 24 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_withManyValues.

@Test
public void testCursor_withManyValues() {
    final long factor = 123456;
    final int k = 1000;
    for (int i = 1; i <= k; i++) {
        long key1 = (long) i;
        long key2 = key1 * factor;
        hsa.ensure(key1, key2);
    }
    boolean[] verifyKeys = new boolean[k];
    Arrays.fill(verifyKeys, false);
    HashSlotCursor16byteKey cursor = hsa.cursor();
    while (cursor.advance()) {
        long key1 = cursor.key1();
        long key2 = cursor.key2();
        assertEquals(key1 * factor, key2);
        verifyKeys[((int) key1) - 1] = true;
    }
    for (int i = 0; i < k; i++) {
        assertTrue("Haven't read " + k + "th key!", verifyKeys[i]);
    }
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_key2_withoutAdvance.

@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testCursor_key2_withoutAdvance() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.key2();
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HashSlotCursor16byteKey (com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey)28 QuickTest (com.hazelcast.test.annotation.QuickTest)28 Test (org.junit.Test)28 RequireAssertEnabled (com.hazelcast.test.RequireAssertEnabled)11