@Test public void testCallInReadTxWithRetry_callback() { closeStoreForTest(); final int[] countHolder = {0}; final int[] countHolderCallback = {0}; BoxStoreBuilder builder = new BoxStoreBuilder(createTestModel(false)).directory(boxStoreDir) .failedReadTxAttemptCallback(new TxCallback() { @Override public void txFinished(@Nullable Object result, @Nullable Throwable error) { assertNotNull(error); countHolderCallback[0]++; } }); store = builder.build(); String value = store.callInReadTxWithRetry(createTestCallable(countHolder), 5, 0, true); assertEquals("42", value); assertEquals(5, countHolder[0]); assertEquals(4, countHolderCallback[0]); }
@Test // TODO can we improve? More than just "still works"? public void testQueryAttempts() { store.close(); BoxStoreBuilder builder = new BoxStoreBuilder(createTestModel(false)).directory(boxStoreDir) .queryAttempts(5) .failedReadTxAttemptCallback(new TxCallback() { @Override public void txFinished(@Nullable Object result, @Nullable Throwable error) { error.printStackTrace(); } }); builder.entity(new TestEntity_()); store = builder.build(); putTestEntitiesScalars(); Query<TestEntity> query = store.boxFor(TestEntity.class).query().equal(simpleInt, 2007).build(); assertEquals(2007, query.findFirst().getSimpleInt()); }