Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAccountForDeletedNodes()
        public virtual void ShouldAccountForDeletedNodes()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            Node node;

            using (Transaction tx = graphDb.BeginTx())
            {
                node = graphDb.CreateNode(label("Foo"));
                graphDb.CreateNode(label("Foo"));

                tx.Success();
            }
            using (Transaction tx = graphDb.BeginTx())
            {
                node.Delete();

                tx.Success();
            }

            // when
            long fooCount = NumberOfNodesWith(label("Foo"));

            // then
            assertEquals(1, fooCount);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void compositeNodeKeyConstraintUpdate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CompositeNodeKeyConstraintUpdate()
        {
            GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDirectory.storeDir()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();

            Label label = Label.label("label");

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(label);
                node.SetProperty("b", ( short )3);
                node.SetProperty("a", new double[] { 0.6, 0.4, 0.2 });
                transaction.Success();
            }

            using (Transaction transaction = database.BeginTx())
            {
                string query = format("CREATE CONSTRAINT ON (n:%s) ASSERT (n.%s,n.%s) IS NODE KEY", label.Name(), "a", "b");
                database.Execute(query);
                transaction.Success();
            }

            AwaitIndex(database);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(label);
                node.SetProperty("a", ( short )7);
                node.SetProperty("b", new double[] { 0.7, 0.5, 0.3 });
                transaction.Success();
            }
            database.Shutdown();

            ConsistencyCheckService.Result consistencyCheckResult = CheckDbConsistency(TestDirectory.storeDir());
            assertTrue("Database is consistent", consistencyCheckResult.Successful);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAccountForDeletedRelationships()
        public virtual void ShouldAccountForDeletedRelationships()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            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();
            }
            long before = NumberOfRelationships();
            long during;

            using (Transaction tx = graphDb.BeginTx())
            {
                rel.Delete();
                during = CountsForRelationship(null, null, null);
                tx.Success();
            }

            // when
            long after = NumberOfRelationships();

            // then
            assertEquals(3, before);
            assertEquals(2, during);
            assertEquals(2, after);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeNumberOfNodesDeletedInTransaction()
        public virtual void ShouldIncludeNumberOfNodesDeletedInTransaction()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            Node one;

            using (Transaction tx = graphDb.BeginTx())
            {
                one = graphDb.CreateNode();
                graphDb.CreateNode();
                tx.Success();
            }
            long before = NumberOfNodes();

            using (Transaction tx = graphDb.BeginTx())
            {
                // when
                one.Delete();
                long nodeCount = CountsForNode();

                // then
                assertEquals(before - 1, nodeCount);
                tx.Success();
            }
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void deletedNodesNotCheckedByExistenceConstraints()
        public virtual void DeletedNodesNotCheckedByExistenceConstraints()
        {
            GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(TestDirectory.directory());

            try
            {
                using (Transaction transaction = database.BeginTx())
                {
                    database.Execute("CREATE CONSTRAINT ON (book:Book) ASSERT exists(book.isbn)");
                    transaction.Success();
                }

                using (Transaction transaction = database.BeginTx())
                {
                    database.Execute("CREATE (:label1 {name: \"Pelle\"})<-[:T1]-(:label2 {name: \"Elin\"})-[:T2]->(:label3)");
                    transaction.Success();
                }

                using (Transaction transaction = database.BeginTx())
                {
                    database.Execute("MATCH (n:label1 {name: \"Pelle\"})<-[r:T1]-(:label2 {name: \"Elin\"})-[:T2]->(:label3) DELETE r,n");
                    transaction.Success();
                }
            }
            finally
            {
                database.Shutdown();
            }
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAccountForRemovedLabels()
        public virtual void ShouldAccountForRemovedLabels()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            Node n1;
            Node n2;
            Node n3;

            using (Transaction tx = graphDb.BeginTx())
            {
                n1 = graphDb.CreateNode(label("Foo"), label("Bar"));
                n2 = graphDb.CreateNode(label("Bar"));
                n3 = graphDb.CreateNode(label("Foo"));

                tx.Success();
            }
            using (Transaction tx = graphDb.BeginTx())
            {
                n1.RemoveLabel(label("Bar"));
                n2.RemoveLabel(label("Bar"));
                n3.RemoveLabel(label("Foo"));

                tx.Success();
            }

            // when
            long fooCount = NumberOfNodesWith(label("Foo"));
            long barCount = NumberOfNodesWith(label("Bar"));

            // then
            assertEquals(1, fooCount);
            assertEquals(0, barCount);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCountRelationshipsByType()
        public virtual void ShouldCountRelationshipsByType()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.GraphDatabaseService graphDb = db.getGraphDatabaseAPI();
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;

            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("FOO"));
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("FOO"));
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("BAR"));
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("BAR"));
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("BAR"));
                graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("BAZ"));
                tx.Success();
            }

            // when
            long total = NumberOfRelationships();
            long foo   = NumberOfRelationships(withName("FOO"));
            long bar   = NumberOfRelationships(withName("BAR"));
            long baz   = NumberOfRelationships(withName("BAZ"));
            long qux   = NumberOfRelationships(withName("QUX"));

            // then
            assertEquals(2, foo);
            assertEquals(3, bar);
            assertEquals(1, baz);
            assertEquals(0, qux);
            assertEquals(6, total);
        }
        private StoreAccess CreateStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes)
        {
            File storeDirectory           = _testDirectory.databaseDir();
            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            using (Transaction transaction = database.BeginTx())
            {
                Node denseNode = database.CreateNode();
                for (int i = 0; i < nDegreeTwoNodes; i++)
                {
                    Node degreeTwoNode = database.CreateNode();
                    Node leafNode      = database.CreateNode();
                    if (i % 2 == 0)
                    {
                        denseNode.CreateRelationshipTo(degreeTwoNode, TestRelationshipType.Connected);
                    }
                    else
                    {
                        degreeTwoNode.CreateRelationshipTo(denseNode, TestRelationshipType.Connected);
                    }
                    degreeTwoNode.CreateRelationshipTo(leafNode, TestRelationshipType.Connected);
                }
                transaction.Success();
            }
            database.Shutdown();
            PageCache   pageCache   = PageCacheRule.getPageCache(_fileSystemRule.get());
            StoreAccess storeAccess = new StoreAccess(_fileSystemRule.get(), pageCache, _testDirectory.databaseLayout(), Config.defaults());

            return(storeAccess.Initialize());
        }
Example #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void extractTransactionalInformationFromLogs(String path, java.io.File customLogLocation, org.neo4j.io.layout.DatabaseLayout databaseLayout, java.io.File storeDir) throws java.io.IOException
        private void ExtractTransactionalInformationFromLogs(string path, File customLogLocation, DatabaseLayout databaseLayout, File storeDir)
        {
            LogService logService = new SimpleLogService(NullLogProvider.Instance, NullLogProvider.Instance);
            File       neoStore   = databaseLayout.MetadataStore();

            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir).setConfig(logical_logs_location, path).newGraphDatabase();

            for (int i = 0; i < 10; i++)
            {
                using (Transaction transaction = database.BeginTx())
                {
                    Node node = database.CreateNode();
                    transaction.Success();
                }
            }
            database.Shutdown();

            MetaDataStore.setRecord(_pageCache, neoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_VERSION, MetaDataRecordFormat.FIELD_NOT_PRESENT);
            Config        config      = Config.defaults(logical_logs_location, path);
            StoreMigrator migrator    = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            LogPosition   logPosition = migrator.ExtractTransactionLogPosition(neoStore, databaseLayout, 100);

            File[] logFiles = customLogLocation.listFiles();
            assertNotNull(logFiles);
            assertEquals(0, logPosition.LogVersion);
            assertEquals(logFiles[0].length(), logPosition.ByteOffset);
        }
 private void WaitIndexesOnline(GraphDatabaseService database)
 {
     using (Transaction ignored = database.BeginTx())
     {
         database.Schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
     }
 }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToCreateLongGraphPropertyChainsAndReadTheCorrectNextPointerFromTheStore()
        public virtual void ShouldBeAbleToCreateLongGraphPropertyChainsAndReadTheCorrectNextPointerFromTheStore()
        {
            GraphDatabaseService database = _factory.newImpermanentDatabase();

            PropertyContainer graphProperties = Properties(( GraphDatabaseAPI )database);

            using (Transaction tx = database.BeginTx())
            {
                graphProperties.SetProperty("a", new string[] { "A", "B", "C", "D", "E" });
                graphProperties.SetProperty("b", true);
                graphProperties.SetProperty("c", "C");
                tx.Success();
            }

            using (Transaction tx = database.BeginTx())
            {
                graphProperties.SetProperty("d", new string[] { "A", "F" });
                graphProperties.SetProperty("e", true);
                graphProperties.SetProperty("f", "F");
                tx.Success();
            }

            using (Transaction tx = database.BeginTx())
            {
                graphProperties.SetProperty("g", new string[] { "F" });
                graphProperties.SetProperty("h", false);
                graphProperties.SetProperty("i", "I");
                tx.Success();
            }

            using (Transaction tx = database.BeginTx())
            {
                assertArrayEquals(new string[] { "A", "B", "C", "D", "E" }, ( string[] )graphProperties.GetProperty("a"));
                assertTrue(( bool )graphProperties.GetProperty("b"));
                assertEquals("C", graphProperties.GetProperty("c"));

                assertArrayEquals(new string[] { "A", "F" }, ( string[] )graphProperties.GetProperty("d"));
                assertTrue(( bool )graphProperties.GetProperty("e"));
                assertEquals("F", graphProperties.GetProperty("f"));

                assertArrayEquals(new string[] { "F" }, ( string[] )graphProperties.GetProperty("g"));
                assertFalse(( bool )graphProperties.GetProperty("h"));
                assertEquals("I", graphProperties.GetProperty("i"));
                tx.Success();
            }
            database.Shutdown();
        }
Example #12
0
 private static void AwaitIndex(GraphDatabaseService database)
 {
     using (Transaction tx = database.BeginTx())
     {
         database.Schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
         tx.Success();
     }
 }
 private void CreateConstraint(GraphDatabaseService database)
 {
     using (Transaction transaction = database.BeginTx())
     {
         Schema schema = database.Schema();
         Schema.constraintFor(_constraintIndexLabel).assertPropertyIsUnique(UNIQUE_PROPERTY_NAME).create();
         transaction.Success();
     }
 }
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.Index().forNodes("foo").add(graphDb.CreateNode(), "bar", "this is it");
                Relationship edge = graphDb.CreateNode().createRelationshipTo(graphDb.CreateNode(), withName("LALA"));
                graphDb.Index().forRelationships("rels").add(edge, "alpha", "betting on the wrong string");

                tx.Success();
            }
        }
Example #15
0
        private void SetAndRemoveSomeProperties(GraphDatabaseService graphDatabaseService, object value)
        {
            Node commonNode;

            using (Transaction transaction = graphDatabaseService.BeginTx())
            {
                commonNode = graphDatabaseService.CreateNode();
                for (int i = 0; i < 10; i++)
                {
                    commonNode.SetProperty("key" + i, value);
                }
                transaction.Success();
            }

            using (Transaction transaction = graphDatabaseService.BeginTx())
            {
                for (int i = 0; i < 10; i++)
                {
                    commonNode.RemoveProperty("key" + i);
                }
                transaction.Success();
            }
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void tracePageCacheFlushProgress()
        public virtual void TracePageCacheFlushProgress()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            GraphDatabaseService  database    = (new TestGraphDatabaseFactory()).setInternalLogProvider(logProvider).newEmbeddedDatabaseBuilder(TestDirectory.directory()).setConfig(GraphDatabaseSettings.tracer, "verbose").newGraphDatabase();

            using (Transaction transaction = database.BeginTx())
            {
                database.CreateNode();
                transaction.Success();
            }
            database.Shutdown();
            logProvider.FormattedMessageMatcher().assertContains("Flushing file");
            logProvider.FormattedMessageMatcher().assertContains("Page cache flush completed. Flushed ");
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportAccurateNumberOfNodesAfterDeletion()
        public virtual void ShouldReportAccurateNumberOfNodesAfterDeletion()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            Node one;

            using (Transaction tx = graphDb.BeginTx())
            {
                one = graphDb.CreateNode();
                graphDb.CreateNode();
                tx.Success();
            }
            using (Transaction tx = graphDb.BeginTx())
            {
                one.Delete();
                tx.Success();
            }

            // when
            long nodeCount = NumberOfNodes();

            // then
            assertEquals(1, nodeCount);
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canAvoidDeadlockThatWouldHappenIfTheRelationshipTypeCreationTransactionModifiedData()
        public virtual void CanAvoidDeadlockThatWouldHappenIfTheRelationshipTypeCreationTransactionModifiedData()
        {
            GraphDatabaseService graphdb = Database.GraphDatabaseAPI;
            Node node = null;

            using (Transaction tx = graphdb.BeginTx())
            {
                node = graphdb.CreateNode();
                node.SetProperty("counter", 0L);
                tx.Success();
            }

            graphdb.RegisterTransactionEventHandler(new RelationshipCounterTransactionEventHandler(node));

            using (Transaction tx = graphdb.BeginTx())
            {
                node.SetProperty("state", "not broken yet");
                node.CreateRelationshipTo(graphdb.CreateNode(), RelationshipType.withName("TEST"));
                node.RemoveProperty("state");
                tx.Success();
            }

            assertThat(node, inTx(graphdb, hasProperty("counter").withValue(1L)));
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void startBatchInserterOnTopOfEnterpriseDatabase() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StartBatchInserterOnTopOfEnterpriseDatabase()
        {
            File databaseDir = _testDirectory.databaseDir();
            GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir);

            using (Transaction transaction = database.BeginTx())
            {
                database.Execute("CREATE CONSTRAINT ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEY");
                transaction.Success();
            }
            database.Shutdown();

            BatchInserter inserter = BatchInserters.inserter(databaseDir);

            inserter.Shutdown();
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportNumberOfNodes()
        public virtual void ShouldReportNumberOfNodes()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;

            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.CreateNode();
                graphDb.CreateNode();
                tx.Success();
            }

            // when
            long nodeCount = NumberOfNodes();

            // then
            assertEquals(2, nodeCount);
        }
Example #21
0
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            using (Transaction tx = graphDb.BeginTx())
            {
                Node root = graphDb.CreateNode();
                _threeRoot = root.Id;

                Node[] leafs = new Node[32];
                for (int i = 0; i < leafs.Length; i++)
                {
                    leafs[i] = graphDb.CreateNode();
                }
                int offset = 0, duplicate = 12;

                Node interdup = graphDb.CreateNode();
                interdup.CreateRelationshipTo(root, _parent);
                offset = Relate(duplicate, leafs, offset, interdup);
                for (int i = 0; i < 5; i++)
                {
                    Node inter = graphDb.CreateNode();
                    inter.CreateRelationshipTo(root, _parent);
                    offset = Relate(3 + i, leafs, offset, inter);
                }
                interdup.CreateRelationshipTo(root, _parent);
                for (int i = 0; i < 4; i++)
                {
                    Node inter = graphDb.CreateNode();
                    inter.CreateRelationshipTo(root, _parent);
                    offset = Relate(2 + i, leafs, offset, inter);
                }

                Node inter = graphDb.CreateNode();
                inter.CreateRelationshipTo(root, _parent);
                offset = Relate(1, leafs, offset, inter);

                _expectedTotal  = offset + duplicate;
                _expectedUnique = leafs.Length;

                tx.Success();
            }
        }
Example #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void storeMigrationToolShouldBeAbleToMigrateOldStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StoreMigrationToolShouldBeAbleToMigrateOldStore()
        {
            StoreMigration.Main(new string[] { TestDir.databaseDir().AbsolutePath });

            // after migration we can open store and do something
            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDir.databaseDir()).setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath).newGraphDatabase();

            try
            {
                using (Transaction transaction = database.BeginTx())
                {
                    Node node = database.CreateNode();
                    node.SetProperty("key", "value");
                    transaction.Success();
                }
            }
            finally
            {
                database.Shutdown();
            }
        }
Example #23
0
        private void Prepare34DatabaseWithNodes()
        {
            GraphDatabaseService embeddedDatabase = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(_storeDir);

            try
            {
                using (Transaction transaction = embeddedDatabase.BeginTx())
                {
                    for (int i = 0; i < 10; i++)
                    {
                        embeddedDatabase.CreateNode(Label.label("label" + i));
                    }
                    transaction.Success();
                }
            }
            finally
            {
                embeddedDatabase.Shutdown();
            }
            _fileSystem.deleteFile(_nativeLabelIndex);
        }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetNumberOfNodesWithLabel()
        public virtual void ShouldGetNumberOfNodesWithLabel()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;

            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.CreateNode(label("Foo"));
                graphDb.CreateNode(label("Bar"));
                graphDb.CreateNode(label("Bar"));

                tx.Success();
            }

            // when
            long fooCount = NumberOfNodesWith(label("Foo"));
            long barCount = NumberOfNodesWith(label("Bar"));

            // then
            assertEquals(1, fooCount);
            assertEquals(2, barCount);
        }
Example #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void question5346011()
        public virtual void Question5346011()
        {
            GraphDatabaseService service = (new TestGraphDatabaseFactory()).newImpermanentDatabase();

            using (Transaction tx = service.BeginTx())
            {
                RelationshipIndex index = service.Index().forRelationships("exact");
                // ...creation of the nodes and relationship
                Node         node1        = service.CreateNode();
                Node         node2        = service.CreateNode();
                string       uuid         = "xyz";
                Relationship relationship = node1.CreateRelationshipTo(node2, RelationshipType.withName("related"));
                index.add(relationship, "uuid", uuid);
                // query
                using (IndexHits <Relationship> hits = index.Get("uuid", uuid, node1, node2))
                {
                    assertEquals(1, hits.Size());
                }
                tx.Success();
            }
            service.Shutdown();
        }
Example #26
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);
        }