コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void firstRemoveSecondChangeProperty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FirstRemoveSecondChangeProperty()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node;
            Node node;

            using (Transaction tx = _db.beginTx())
            {
                node = _db.createNode();
                node.SetProperty(PROPERTY_KEY, VALUE_1);
                tx.Success();
            }

            // WHEN
            Future <Void> future = T2.execute(state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    node.RemoveProperty(PROPERTY_KEY);
                    tx.Success();
                    barrier.Reached();
                }
                return(null);
            });

            using (Transaction tx = _db.beginTx())
            {
                barrier.Await();
                node.SetProperty(PROPERTY_KEY, VALUE_2);
                tx.Success();
                barrier.Release();
            }

            future.get();
            using (Transaction tx = _db.beginTx())
            {
                assertEquals(VALUE_2, node.GetProperty(PROPERTY_KEY, VALUE_2));
                tx.Success();
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void shouldNotFreakOutIfTwoTransactionsDecideToEachAddTheSameProperty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotFreakOutIfTwoTransactionsDecideToEachAddTheSameProperty()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node;
            Node node;

            using (Transaction tx = _db.beginTx())
            {
                node = _db.createNode();
                tx.Success();
            }

            // WHEN
            T2.execute((WorkerCommand <Void, Void>)state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    node.SetProperty(PROPERTY_KEY, VALUE_1);
                    tx.Success();
                    barrier.Reached();
                }
                return(null);
            });
            using (Transaction tx = _db.beginTx())
            {
                barrier.Await();
                node.SetProperty(PROPERTY_KEY, VALUE_2);
                tx.Success();
                barrier.Release();
            }

            using (Transaction tx = _db.beginTx())
            {
                assertEquals(1, count(node.PropertyKeys));
                tx.Success();
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void removeNodeChangeNodeProperty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RemoveNodeChangeNodeProperty()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long nodeId;
            long nodeId;

            using (Transaction tx = _db.beginTx())
            {
                Node node = _db.createNode();
                nodeId = node.Id;
                node.SetProperty(PROPERTY_KEY, VALUE_1);
                tx.Success();
            }

            // WHEN
            Future <Void> future = T2.execute(state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    _db.getNodeById(nodeId).delete();
                    tx.Success();
                    barrier.Reached();
                }
                return(null);
            });

            try
            {
                using (Transaction tx = _db.beginTx())
                {
                    barrier.Await();
                    _db.getNodeById(nodeId).setProperty(PROPERTY_KEY, VALUE_2);
                    tx.Success();
                    barrier.Release();
                }
            }
            catch (TransactionFailureException e)
            {
                // Node was already deleted, fine.
                assertThat(e.InnerException, instanceOf(typeof(InvalidRecordException)));
            }

            future.get();
            using (Transaction tx = _db.beginTx())
            {
                try
                {
                    _db.getNodeById(nodeId);
                    assertEquals(VALUE_2, _db.getNodeById(nodeId).getProperty(PROPERTY_KEY, VALUE_2));
                }
                catch (NotFoundException)
                {
                    // Fine, its gone
                }
                tx.Success();
            }
        }