コード例 #1
0
            /*
             * This is overly careful about always closing and nulling the transaction since
             * reset can cause ctx.currentTransaction to be null we store in local variable.
             */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void closeTransaction(MutableTransactionState ctx, boolean success) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
            internal void CloseTransaction(MutableTransactionState ctx, bool success)
            {
                KernelTransaction tx = ctx.CurrentTransaction;

                ctx.CurrentTransaction = null;
                if (tx != null)
                {
                    try
                    {
                        if (success)
                        {
                            tx.Success();
                        }
                        else
                        {
                            tx.Failure();
                        }
                        if (tx.Open)
                        {
                            tx.Close();
                        }
                    }
                    finally
                    {
                        ctx.CurrentTransaction = null;
                    }
                }
            }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRollbackAndThrowOnFailedAndSuccess()
        public virtual void ShouldRollbackAndThrowOnFailedAndSuccess()
        {
            // GIVEN
            bool exceptionReceived = false;

            try
            {
                using (KernelTransaction transaction = NewTransaction(LoginContext()))
                {
                    // WHEN
                    TransactionInitializer.accept(transaction);
                    transaction.Failure();
                    transaction.Success();
                }
            }
            catch (TransactionFailureException)
            {
                // Expected.
                exceptionReceived = true;
            }

            // THEN
            assertTrue(exceptionReceived);
            verify(TransactionMonitor, times(1)).transactionFinished(false, IsWriteTx);
            VerifyExtraInteractionWithTheMonitor(TransactionMonitor, IsWriteTx);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRollbackFailedTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRollbackFailedTransaction()
        {
            // GIVEN
            using (KernelTransaction transaction = NewTransaction(LoginContext()))
            {
                // WHEN
                TransactionInitializer.accept(transaction);
                transaction.Failure();
            }

            // THEN
            verify(TransactionMonitor, times(1)).transactionFinished(false, IsWriteTx);
            VerifyExtraInteractionWithTheMonitor(TransactionMonitor, IsWriteTx);
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDowngradeFailureState() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotDowngradeFailureState()
        {
            using (KernelTransaction transaction = NewTransaction(LoginContext()))
            {
                // WHEN
                TransactionInitializer.accept(transaction);
                transaction.MarkForTermination(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError);
                transaction.Failure();
                assertEquals(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError, transaction.ReasonIfTerminated.get());
            }

            // THEN
            verify(TransactionMonitor, times(1)).transactionFinished(false, IsWriteTx);
            verify(TransactionMonitor, times(1)).transactionTerminated(IsWriteTx);
            VerifyExtraInteractionWithTheMonitor(TransactionMonitor, IsWriteTx);
        }
コード例 #5
0
 public virtual void Rollback()
 {
     try
     {
         KernelTransaction kernelTransactionBoundToThisThread = _bridge.getKernelTransactionBoundToThisThread(false);
         kernelTransactionBoundToThisThread.Failure();
         kernelTransactionBoundToThisThread.Close();
     }
     catch (TransactionFailureException e)
     {
         throw new Exception(e);
     }
     finally
     {
         _bridge.unbindTransactionFromCurrentThread();
     }
 }