Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldUseStartTimeAndTxIdFromWhenStartingTxAsHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUseStartTimeAndTxIdFromWhenStartingTxAsHeader()
        {
            // GIVEN a transaction starting at one point in time
            long startingTime = Clock.millis();
            ExplicitIndexTransactionState explicitIndexState = mock(typeof(ExplicitIndexTransactionState));

            AuxTxStateManager.registerProvider(new ExplicitIndexTransactionStateProviderAnonymousInnerClass(this, explicitIndexState));
            when(explicitIndexState.hasChanges()).thenReturn(true);
            doAnswer(invocation =>
            {
                ICollection <StorageCommand> commands = invocation.getArgument(0);
                commands.add(mock(typeof(Command)));
                return(null);
            }).when(StorageEngine).createCommands(any(typeof(System.Collections.ICollection)), any(typeof(TransactionState)), any(typeof(StorageReader)), any(typeof(ResourceLocker)), anyLong(), any(typeof(TxStateVisitor.Decorator)));

            using (KernelTransactionImplementation transaction = NewTransaction(LoginContext()))
            {
                SimpleStatementLocks statementLocks = new SimpleStatementLocks(mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)));
                transaction.Initialize(5L, BASE_TX_COMMIT_TIMESTAMP, statementLocks, KernelTransaction.Type.@implicit, SecurityContext.AUTH_DISABLED, 0L, 1L);
                transaction.TxState();
                using (KernelStatement statement = transaction.AcquireStatement())
                {
                    statement.ExplicitIndexTxState();                              // which will pull it from the supplier and the mocking above
                    // will have it say that it has changes.
                }
                // WHEN committing it at a later point
                Clock.forward(5, MILLISECONDS);
                // ...and simulating some other transaction being committed
                when(MetaDataStore.LastCommittedTransactionId).thenReturn(7L);
                transaction.Success();
            }

            // THEN start time and last tx when started should have been taken from when the transaction started
            assertEquals(5L, CommitProcess.transaction.LatestCommittedTxWhenStarted);
            assertEquals(startingTime, CommitProcess.transaction.TimeStarted);
            assertEquals(startingTime + 5, CommitProcess.transaction.TimeCommitted);
        }
Esempio n. 2
0
 public override bool HasChanges()
 {
     return(_txState.hasChanges());
 }