Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero()
        public virtual void ShouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero()
        {
            // given
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            StorageReader   storageReader = mock(typeof(StorageReader));
            KernelStatement statement     = GetKernelStatement(transaction, storageReader);

            statement.Acquire();
            verify(storageReader).acquire();
            statement.Acquire();

            // when
            statement.Close();
            verifyNoMoreInteractions(storageReader);

            // then
            statement.Close();
            verify(storageReader).release();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStorageReaderWhenForceClosed()
        public virtual void ShouldReleaseStorageReaderWhenForceClosed()
        {
            // given
            StorageReader   storeStatement = mock(typeof(StorageReader));
            KernelStatement statement      = new KernelStatement(mock(typeof(KernelTransactionImplementation)), null, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.Acquire();

            // when
            try
            {
                statement.ForceClose();
            }
            catch (KernelStatement.StatementNotClosedException)
            {
                // ignore
            }

            // then
            verify(storeStatement).release();
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStoreStatementWhenForceClosingStatements()
        public virtual void ShouldReleaseStoreStatementWhenForceClosingStatements()
        {
            // given
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            StorageReader   storageReader = mock(typeof(StorageReader));
            KernelStatement statement     = GetKernelStatement(transaction, storageReader);

            statement.Acquire();

            // when
            try
            {
                statement.ForceClose();
            }
            catch (KernelStatement.StatementNotClosedException)
            {
                //ignored
            }

            // then
            verify(storageReader).release();
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        public virtual void ReportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        {
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            TxStateHolder txStateHolder  = mock(typeof(TxStateHolder));
            StorageReader storeStatement = mock(typeof(StorageReader));

            KernelTransactionImplementation.Statistics statistics = new KernelTransactionImplementation.Statistics(transaction, new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE));
            when(transaction.GetStatistics()).thenReturn(statistics);
            when(transaction.ExecutingQueries()).thenReturn(ExecutingQueryList.EMPTY);

            KernelStatement statement = new KernelStatement(transaction, txStateHolder, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.Acquire();

            ExecutingQuery query  = QueryWithWaitingTime;
            ExecutingQuery query2 = QueryWithWaitingTime;
            ExecutingQuery query3 = QueryWithWaitingTime;

            statement.StopQueryExecution(query);
            statement.StopQueryExecution(query2);
            statement.StopQueryExecution(query3);

            assertEquals(3, statistics.GetWaitingTimeNanos(1));
        }