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));
}
Aggregations