Search in sources :

Example 11 with Pointer

use of com.cetsoft.imcache.offheap.bytebuffer.Pointer in project imcache by Cetsoft.

the class OffHeapByteBufferStoreTest method update.

/**
     * Update.
     */
@Test
public void update() {
    int size = 100;
    byte[] bytes = new byte[size];
    random.nextBytes(bytes);
    Pointer pointer = bufferStore.store(bytes);
    byte[] expectedBytes = new byte[size];
    random.nextBytes(expectedBytes);
    pointer = bufferStore.update(pointer, expectedBytes);
    byte[] actualBytes = bufferStore.retrieve(pointer);
    assertArrayEquals(expectedBytes, actualBytes);
}
Also used : Pointer(com.cetsoft.imcache.offheap.bytebuffer.Pointer) Test(org.junit.Test)

Example 12 with Pointer

use of com.cetsoft.imcache.offheap.bytebuffer.Pointer in project imcache by Cetsoft.

the class OffHeapByteBufferTest method updateGreaterExPayload.

/**
     * Update greater ex payload.
     */
@Test
public void updateGreaterExPayload() {
    int size = 100;
    byte[] bytes = new byte[size];
    random.nextBytes(bytes);
    Pointer pointer = buffer.store(bytes);
    byte[] expectedBytes = new byte[size + 5];
    random.nextBytes(expectedBytes);
    pointer = buffer.update(pointer, expectedBytes);
    byte[] actualBytes = buffer.retrieve(pointer);
    assertArrayEquals(expectedBytes, actualBytes);
}
Also used : Pointer(com.cetsoft.imcache.offheap.bytebuffer.Pointer) Test(org.junit.Test)

Example 13 with Pointer

use of com.cetsoft.imcache.offheap.bytebuffer.Pointer in project imcache by Cetsoft.

the class OffHeapByteBufferTest method update.

/**
     * Update.
     */
@Test
public void update() {
    int size = 100;
    byte[] bytes = new byte[size];
    random.nextBytes(bytes);
    Pointer pointer = buffer.store(bytes);
    byte[] expectedBytes = new byte[size];
    random.nextBytes(expectedBytes);
    pointer = buffer.update(pointer, expectedBytes);
    byte[] actualBytes = buffer.retrieve(pointer);
    assertArrayEquals(expectedBytes, actualBytes);
}
Also used : Pointer(com.cetsoft.imcache.offheap.bytebuffer.Pointer) Test(org.junit.Test)

Aggregations

Pointer (com.cetsoft.imcache.offheap.bytebuffer.Pointer)13 Test (org.junit.Test)9 BufferOverflowException (java.nio.BufferOverflowException)2 OffHeapByteBuffer (com.cetsoft.imcache.offheap.bytebuffer.OffHeapByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1