Search in sources :

Example 1 with TestPageIo

use of org.apache.ignite.internal.pagememory.TestPageIoModule.TestPageIo in project ignite-3 by apache.

the class PageIoRegistryTest method testResolve.

@Test
void testResolve() throws Exception {
    // Module is not yet loaded.
    assertThrows(IgniteInternalCheckedException.class, () -> ioRegistry.resolve(TEST_PAGE_TYPE, TEST_PAGE_VER));
    // Load all PageIOModule-s from the classpath.
    ioRegistry.loadFromServiceLoader();
    // Test base resolve method.
    PageIo pageIo = ioRegistry.resolve(TEST_PAGE_TYPE, TEST_PAGE_VER);
    assertTrue(pageIo instanceof TestPageIo);
    assertEquals(TEST_PAGE_TYPE, pageIo.getType());
    assertEquals(TEST_PAGE_VER, pageIo.getVersion());
    ByteBuffer pageBuffer = ByteBuffer.allocateDirect(4);
    pageBuffer.order(GridUnsafe.NATIVE_BYTE_ORDER);
    pageBuffer.putShort(PageIo.TYPE_OFF, (short) TEST_PAGE_TYPE);
    pageBuffer.putShort(PageIo.VER_OFF, (short) TEST_PAGE_VER);
    // Test resolve from a pointer.
    assertEquals(pageIo, ioRegistry.resolve(bufferAddress(pageBuffer)));
    // Test resolve from ByteBuffer.
    assertEquals(pageIo, ioRegistry.resolve(pageBuffer));
}
Also used : TestPageIo(org.apache.ignite.internal.pagememory.TestPageIoModule.TestPageIo) ByteBuffer(java.nio.ByteBuffer) PageIo(org.apache.ignite.internal.pagememory.io.PageIo) TestPageIo(org.apache.ignite.internal.pagememory.TestPageIoModule.TestPageIo) Test(org.junit.jupiter.api.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 TestPageIo (org.apache.ignite.internal.pagememory.TestPageIoModule.TestPageIo)1 PageIo (org.apache.ignite.internal.pagememory.io.PageIo)1 Test (org.junit.jupiter.api.Test)1