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 shouldThrowTransactionExceptionOnTransientKernelException() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowTransactionExceptionOnTransientKernelException()
        {
            // GIVEN
            KernelTransaction kernelTransaction = mock(typeof(KernelTransaction));

            when(kernelTransaction.Open).thenReturn(true);
            doThrow(new Exception("Just a random failure")).when(kernelTransaction).close();
            TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction);

            // WHEN
            transaction.Success();
            try
            {
                transaction.Close();
                fail("Should have failed");
            }
            catch (Org.Neo4j.Graphdb.TransactionFailureException)
            {               // THEN Good
            }
        }
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 shouldThrowTransientExceptionOnTransientKernelException() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowTransientExceptionOnTransientKernelException()
        {
            // GIVEN
            KernelTransaction kernelTransaction = mock(typeof(KernelTransaction));

            when(kernelTransaction.Open).thenReturn(true);
            doThrow(new TransactionFailureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.ConstraintsChanged, "Proving that TopLevelTransaction does the right thing")).when(kernelTransaction).close();
            TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction);

            // WHEN
            transaction.Success();
            try
            {
                transaction.Close();
                fail("Should have failed");
            }
            catch (TransientTransactionFailureException)
            {               // THEN Good
            }
        }
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 shouldLetThroughTransientFailureException() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetThroughTransientFailureException()
        {
            // GIVEN
            KernelTransaction kernelTransaction = mock(typeof(KernelTransaction));

            when(kernelTransaction.Open).thenReturn(true);
            doThrow(new TransientDatabaseFailureException("Just a random failure")).when(kernelTransaction).close();
            TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction);

            // WHEN
            transaction.Success();
            try
            {
                transaction.Close();
                fail("Should have failed");
            }
            catch (TransientFailureException)
            {               // THEN Good
            }
        }
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 shouldShowTransactionTerminatedExceptionAsTransient() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldShowTransactionTerminatedExceptionAsTransient()
        {
            KernelTransaction kernelTransaction = mock(typeof(KernelTransaction));

            doReturn(true).when(kernelTransaction).Open;
            Exception error = new TransactionTerminatedException(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated);

            doThrow(error).when(kernelTransaction).close();
            TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction);

            transaction.Success();
            try
            {
                transaction.Close();
                fail("Should have failed");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(TransientTransactionFailureException)));
                assertSame(error, e.InnerException);
            }
        }