diff --git a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java index 3d74d37..efd0404 100644 --- a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java +++ b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java @@ -53,7 +53,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest { throw new RuntimeException(e); } } - }); + }, 3); logger.debug(" START -----------------------------------------------"); logger.debug("Flushing the buffered records"); @@ -61,21 +61,32 @@ public class PersistenceBackendMonitorTest extends ScopedTest { logger.debug(" END -----------------------------------------------"); PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext()); - persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend); - FallbackMonitor temporalDataPersistenceBackendMonitor = new FallbackMonitor(persistenceBackend); - temporalDataPersistenceBackendMonitor.run(); + if(persistenceBackend instanceof FallbackPersistenceBackend) { + /* This line has no sense in real scenario is only used to avoid null pointer exception in test because + * the test has no time to get the real persistence + */ + persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend); + } + FallbackMonitor fallbackMonitor = new FallbackMonitor(persistenceBackend, false); + fallbackMonitor.run(); + + logger.debug("{} finished", FallbackMonitor.class.getSimpleName()); } @Test public void singleParsingTest() throws Exception { PersistenceBackendFactory.setFallbackLocation(null); PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext()); - //persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend); - FallbackMonitor temporalDataPersistenceBackendMonitor = new FallbackMonitor(persistenceBackend); - - temporalDataPersistenceBackendMonitor.run(); + if(persistenceBackend instanceof FallbackPersistenceBackend) { + /* This line has no sense in real scenario is only used to avoid null pointer exception in test because + * the test has no time to get the real persistence + */ + persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend); + } + FallbackMonitor fallbackMonitor = new FallbackMonitor(persistenceBackend); + fallbackMonitor.run(); } }