private void cleanupResources() { // closing is done by KTI storageReader.release(); executingQueryList = ExecutingQueryList.EMPTY; closeAllCloseableResources(); }
@Test public void shouldReleaseStoreStatementWhenForceClosingStatements() { // given KernelTransactionImplementation transaction = mock( KernelTransactionImplementation.class ); StorageReader storageReader = mock( StorageReader.class ); KernelStatement statement = getKernelStatement( transaction, storageReader ); statement.acquire(); // when try { statement.forceClose(); } catch ( KernelStatement.StatementNotClosedException ignored ) { //ignored } // then verify( storageReader ).release(); }
@Test public void shouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero() { // given KernelTransactionImplementation transaction = mock( KernelTransactionImplementation.class ); StorageReader storageReader = mock( StorageReader.class ); KernelStatement statement = getKernelStatement( transaction, storageReader ); statement.acquire(); verify( storageReader ).acquire(); statement.acquire(); // when statement.close(); verifyNoMoreInteractions( storageReader ); // then statement.close(); verify( storageReader ).release(); }
@Test public void shouldReleaseStorageReaderWhenForceClosed() { // given StorageReader storeStatement = mock( StorageReader.class ); KernelStatement statement = new KernelStatement( mock( KernelTransactionImplementation.class ), null, storeStatement, LockTracer.NONE, mock( StatementOperationParts.class ), new ClockContext(), EmptyVersionContextSupplier.EMPTY ); statement.acquire(); // when try { statement.forceClose(); } catch ( KernelStatement.StatementNotClosedException ignored ) { // ignore } // then verify( storeStatement ).release(); }
private void cleanupResources() { // closing is done by KTI storageReader.release(); executingQueryList = ExecutingQueryList.EMPTY; closeAllCloseableResources(); }