.lockService( lockService ) .transactionApplierTransformer( applier::wrapAroundActualApplier ) .build(); CommandsToApply commandsToApply = mock( CommandsToApply.class ); when( commandsToApply.accept( any() ) ).thenAnswer( invocationOnMock ->
.getWith( fs, pageCache, directory.databaseLayout() ) .indexProvider( indexProvider ) .build(); storageEngine.apply( tx( singletonList( createIndexRule( DESCRIPTOR, 1, descriptor ) ) ), TransactionApplicationMode.EXTERNAL ); Dependencies dependencies = new Dependencies();
@Test public void panicOnExceptionDuringCommandsApply() { IllegalStateException failure = new IllegalStateException( "Too many open files" ); RecordStorageEngine engine = storageEngineRule.getWith( fsRule.get(), pageCacheRule.getPageCache( fsRule.get() ), testDirectory.databaseLayout() ) .databaseHealth( databaseHealth ) .transactionApplierTransformer( facade -> transactionApplierFacadeTransformer( facade, failure ) ) .build(); CommandsToApply commandsToApply = mock( CommandsToApply.class ); try { engine.apply( commandsToApply, TransactionApplicationMode.INTERNAL ); fail( "Exception expected" ); } catch ( Exception exception ) { assertSame( failure, Exceptions.rootCause( exception ) ); } verify( databaseHealth ).panic( any( Throwable.class ) ); }
@Test public void mustFlushStoresWithGivenIOLimiter() { IOLimiter limiter = IOLimiter.UNLIMITED; FileSystemAbstraction fs = fsRule.get(); AtomicReference<IOLimiter> observedLimiter = new AtomicReference<>(); PageCache pageCache = new DelegatingPageCache( pageCacheRule.getPageCache( fs ) ) { @Override public void flushAndForce( IOLimiter limiter ) throws IOException { super.flushAndForce( limiter ); observedLimiter.set( limiter ); } }; RecordStorageEngine engine = storageEngineRule.getWith( fs, pageCache, testDirectory.databaseLayout() ).build(); engine.flushAndForce( limiter ); assertThat( observedLimiter.get(), sameInstance( limiter ) ); }
private RecordStorageEngine buildRecordStorageEngine() { return recordStorageEngineBuilder().build(); }