public void dispose() { storageReader.close(); }
@After public void after() { reader.close(); }
@Test public void transactionClosesUnderlyingStoreReaderWhenDisposed() throws Throwable { StorageReader storeStatement1 = mock( StorageReader.class ); StorageReader storeStatement2 = mock( StorageReader.class ); StorageReader storeStatement3 = mock( StorageReader.class ); KernelTransactions kernelTransactions = newKernelTransactions( mock( TransactionCommitProcess.class ), storeStatement1, storeStatement2, storeStatement3 ); // start and close 3 transactions from different threads startAndCloseTransaction( kernelTransactions ); Executors.newSingleThreadExecutor().submit( () -> startAndCloseTransaction( kernelTransactions ) ).get(); Executors.newSingleThreadExecutor().submit( () -> startAndCloseTransaction( kernelTransactions ) ).get(); kernelTransactions.disposeAll(); verify( storeStatement1 ).close(); verify( storeStatement2 ).close(); verify( storeStatement3 ).close(); }
public void dispose() { storageReader.close(); }