Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotSeeNodeCountsOfOtherTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotSeeNodeCountsOfOtherTransaction()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;

//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();
            long          before = NumberOfNodes();
            Future <long> done   = Threading.execute(new NamedFunctionAnonymousInnerClass(this, graphDb, barrier)
                                                     , graphDb);

            barrier.Await();

            // when
            long during = NumberOfNodes();

            barrier.Release();
            long whatOtherThreadSees = done.get();
            long after = NumberOfNodes();

            // then
            assertEquals(0, before);
            assertEquals(0, during);
            assertEquals(after, whatOtherThreadSees);
            assertEquals(2, after);
        }
Exemplo n.º 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 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();
            }
        }
Exemplo n.º 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 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();
            }
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCountRelationshipsDeletedInOtherTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotCountRelationshipsDeletedInOtherTransaction()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Relationship rel;
            Relationship rel;

            using (Transaction tx = graphDb.BeginTx())
            {
                Node node = graphDb.CreateNode();
                node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                rel = node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                tx.Success();
            }
//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();
            long          before = NumberOfRelationships();
            Future <long> tx     = Threading.execute(new NamedFunctionAnonymousInnerClass2(this, graphDb, rel, tx, barrier)
                                                     , graphDb);

            barrier.Await();

            // when
            long during = NumberOfRelationships();

            barrier.Release();
            long whatOtherThreadSees = tx.get();
            long after = NumberOfRelationships();

            // then
            assertEquals(3, before);
            assertEquals(3, during);
            assertEquals(2, after);
            assertEquals(after, whatOtherThreadSees);
        }
Exemplo n.º 5
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();
            }
        }