@Test public void testRenew() throws IOException { insertTestEntities("orange"); Transaction transaction = store.beginReadTx(); Cursor<TestEntity> cursor = transaction.createCursor(TestEntity.class); transaction.recycle(); transaction.renew(); cursor.renew(); assertEquals("orange", cursor.get(1).getSimpleString()); cursor.close(); transaction.close(); }
@Test public void testLookupKeyUsingIndex() throws IOException { insertTestEntities("find me", "not me"); Transaction transaction = store.beginTx(); Cursor<TestEntity> cursor = transaction.createCursor(TestEntity.class); assertEquals(2, cursor.lookupKeyUsingIndex(9, "not me")); assertEquals(1, cursor.lookupKeyUsingIndex(9, "find me")); assertEquals(0, cursor.lookupKeyUsingIndex(9, "peter pan")); cursor.close(); transaction.abort(); }
@Test public void testLookupKeyUsingIndex_samePrefix() { insertTestEntities("aaa", "aa"); Transaction transaction = store.beginTx(); Cursor<TestEntity> cursor = transaction.createCursor(TestEntity.class); assertEquals(0, cursor.lookupKeyUsingIndex(9, "a")); assertEquals(2, cursor.lookupKeyUsingIndex(9, "aa")); assertEquals(1, cursor.lookupKeyUsingIndex(9, "aaa")); assertEquals(0, cursor.lookupKeyUsingIndex(9, "aaaa")); cursor.close(); transaction.abort(); }
@Test public void testGetNextEntity() { insertTestEntities("hello", "bye", "dummy"); Transaction transaction = store.beginReadTx(); Cursor<TestEntity> cursor = transaction.createCursor(TestEntity.class); TestEntity entity1 = cursor.get(1); assertEquals("hello", entity1.getSimpleString()); TestEntity entity2 = cursor.next(); assertEquals("bye", entity2.getSimpleString()); TestEntity entity3 = cursor.next(); assertEquals("dummy", entity3.getSimpleString()); assertNull(cursor.next()); cursor.close(); transaction.abort(); }