Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void executeQueryStartDefaultTransaction()
        internal virtual void ExecuteQueryStartDefaultTransaction()
        {
            KernelTransaction   kernelTransaction = mock(typeof(KernelTransaction));
            InternalTransaction transaction       = new TopLevelTransaction(kernelTransaction);

            when(_queryService.beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED)).thenReturn(transaction);

            _graphDatabaseFacade.execute("create (n)");
            _graphDatabaseFacade.execute("create (n)", new Dictionary <string, object>());

            long timeout = Config.defaults().get(GraphDatabaseSettings.transaction_timeout).toMillis();

            verify(_spi, times(2)).beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED, timeout);
        }
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 shouldReturnTerminationReason()
        public virtual void ShouldReturnTerminationReason()
        {
            KernelTransaction kernelTransaction = mock(typeof(KernelTransaction));

            when(kernelTransaction.ReasonIfTerminated).thenReturn(null).thenReturn(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated);

            TopLevelTransaction tx = new TopLevelTransaction(kernelTransaction);

            Optional <Status> terminationReason1 = tx.TerminationReason();
            Optional <Status> terminationReason2 = tx.TerminationReason();

            assertFalse(terminationReason1.Present);
            assertTrue(terminationReason2.Present);
            assertEquals(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated, terminationReason2.get());
        }
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 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.º 4
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.º 5
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.º 6
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);
            }
        }