示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportProgressOnRecovery() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportProgressOnRecovery()
        {
            RecoveryService                    recoveryService           = mock(typeof(RecoveryService), Answers.RETURNS_MOCKS);
            CorruptedLogsTruncator             logsTruncator             = mock(typeof(CorruptedLogsTruncator));
            RecoveryMonitor                    recoveryMonitor           = mock(typeof(RecoveryMonitor));
            TransactionCursor                  reverseTransactionCursor  = mock(typeof(TransactionCursor));
            TransactionCursor                  transactionCursor         = mock(typeof(TransactionCursor));
            CommittedTransactionRepresentation transactionRepresentation = mock(typeof(CommittedTransactionRepresentation));

            int         transactionsToRecover         = 5;
            int         expectedMax                   = transactionsToRecover * 2;
            int         lastCommittedTransactionId    = 14;
            LogPosition recoveryStartPosition         = LogPosition.start(0);
            int         firstTxIdAfterLastCheckPoint  = 10;
            RecoveryStartInformation startInformation = new RecoveryStartInformation(recoveryStartPosition, firstTxIdAfterLastCheckPoint);

            when(reverseTransactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
            when(transactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
            when(reverseTransactionCursor.get()).thenReturn(transactionRepresentation);
            when(transactionCursor.get()).thenReturn(transactionRepresentation);
            when(transactionRepresentation.CommitEntry).thenReturn(new LogEntryCommit(lastCommittedTransactionId, 1L));

            when(recoveryService.RecoveryStartInformation).thenReturn(startInformation);
            when(recoveryService.GetTransactionsInReverseOrder(recoveryStartPosition)).thenReturn(reverseTransactionCursor);
            when(recoveryService.GetTransactions(recoveryStartPosition)).thenReturn(transactionCursor);

            AssertableProgressReporter progressReporter = new AssertableProgressReporter(expectedMax);
            Recovery recovery = new Recovery(recoveryService, logsTruncator, new LifecycleAdapter(), recoveryMonitor, progressReporter, true);

            Recovery.init();

            progressReporter.Verify();
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation extractLastTransaction(org.neo4j.kernel.internal.GraphDatabaseAPI db) throws java.io.IOException
        private static CommittedTransactionRepresentation ExtractLastTransaction(GraphDatabaseAPI db)
        {
            LogicalTransactionStore            txStore     = Db.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));
            CommittedTransactionRepresentation transaction = null;

            using (TransactionCursor cursor = txStore.GetTransactions(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID + 1))
            {
                while (cursor.next())
                {
                    transaction = cursor.get();
                }
            }
            return(transaction);
        }