@Test public void warningLoggedAfterSomeTime() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); assertFalse(handler.skippingCorruptIndex("async", "/oak:index/foo", Calendar.getInstance())); clock.waitUntil(clock.getTime() + handler.getErrorWarnIntervalMillis() + 1); assertTrue(handler.skippingCorruptIndex("async", "/oak:index/foo", Calendar.getInstance())); assertFalse(handler.skippingCorruptIndex("async", "/oak:index/foo", Calendar.getInstance())); }
@Test public void disbaled() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); handler.setCorruptInterval(0, TimeUnit.SECONDS); //With timeout set to zero no corrupt index should be reported assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }
@Test public void basics() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); //Index would not be considered corrupt until timeout assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); //Should only be visible for "async" assertFalse(handler.getCorruptIndexData("async-fulltext").containsKey("/oak:index/foo")); handler.markWorkingIndexes(Collections.singleton("/oak:index/foo")); assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }