Exemplo n.º 1
0
        private static int ActiveTxCount(GraphDatabaseService db)
        {
            DependencyResolver resolver           = (( GraphDatabaseAPI )db).DependencyResolver;
            KernelTransactions kernelTransactions = resolver.ResolveDependency(typeof(KernelTransactions));

            return(kernelTransactions.ActiveTransactions().Count);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotTimeoutSchemaTransactions()
        internal virtual void ShouldNotTimeoutSchemaTransactions()
        {
            // given
            KernelTransactions       kernelTransactions = mock(typeof(KernelTransactions));
            FakeClock                clock   = new FakeClock(100, MINUTES);
            KernelTransactionMonitor monitor = new KernelTransactionMonitor(kernelTransactions, clock, NullLogService.Instance);
            // a 2 minutes old schema transaction which has a timeout of 1 minute
            KernelTransactionHandle oldSchemaTransaction = mock(typeof(KernelTransactionHandle));

            when(oldSchemaTransaction.SchemaTransaction).thenReturn(true);
            when(oldSchemaTransaction.StartTime()).thenReturn(clock.Millis() - MINUTES.toMillis(2));
            when(oldSchemaTransaction.TimeoutMillis()).thenReturn(MINUTES.toMillis(1));
            when(kernelTransactions.ActiveTransactions()).thenReturn(Iterators.asSet(oldSchemaTransaction));

            // when
            monitor.Run();

            // then
            verify(oldSchemaTransaction, times(1)).SchemaTransaction;
            verify(oldSchemaTransaction, never()).markForTermination(any());
        }