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 readArrayAndStringPropertiesWithDifferentBlockSizes()
        public virtual void ReadArrayAndStringPropertiesWithDifferentBlockSizes()
        {
            string stringValue = RandomStringUtils.randomAlphanumeric(10000);

            sbyte[] arrayValue = RandomStringUtils.randomAlphanumeric(10000).Bytes;

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(Fs.get()).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.string_block_size, "1024").setConfig(GraphDatabaseSettings.array_block_size, "2048").newGraphDatabase();

            try
            {
                long nodeId;
                using (Transaction tx = Db.beginTx())
                {
                    Node node = Db.createNode();
                    nodeId = node.Id;
                    node.SetProperty("string", stringValue);
                    node.SetProperty("array", arrayValue);
                    tx.Success();
                }

                using (Transaction tx = Db.beginTx())
                {
                    Node node = Db.getNodeById(nodeId);
                    assertEquals(stringValue, node.GetProperty("string"));
                    assertArrayEquals(arrayValue, ( sbyte[] )node.GetProperty("array"));
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemplo n.º 2
0
        public static void CreateNodeKeyConstraint(GraphDatabaseService db, string label, params string[] properties)
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            string keyProperties = java.util.properties.Select(property => format("n.`%s`", property)).collect(joining(","));

            Db.execute(format("CREATE CONSTRAINT ON (n:`%s`) ASSERT (%s) IS NODE KEY", label, keyProperties));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotIndexNodesWithWrongLabel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotIndexNodesWithWrongLabel()
        {
            // Given
            File          file     = new File(DbRule.DatabaseDirAbsolutePath);
            BatchInserter inserter = BatchInserters.inserter(file, FileSystemRule.get());

            inserter.createNode(map("name", "Bob"), label("User"), label("Admin"));

            inserter.CreateDeferredSchemaIndex(label("Banana")).on("name").create();

            // When
            inserter.Shutdown();

            // Then
            GraphDatabaseService db = DbRule.GraphDatabaseAPI;

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    assertThat(count(Db.findNodes(label("Banana"), "name", "Bob")), equalTo(0L));
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
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 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);
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reading a node command might leave a node record which referred to
        /// labels in one or more dynamic records as marked as heavy even if that
        /// node already had references to dynamic records, changed in a transaction,
        /// but had no labels on that node changed within that same transaction.
        /// Now defensively only marks as heavy if there were one or more dynamic
        /// records provided when providing the record object with the label field
        /// value. This would give the opportunity to load the dynamic records the
        /// next time that record would be ensured heavy.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverNodeWithDynamicLabelRecords()
        public virtual void ShouldRecoverNodeWithDynamicLabelRecords()
        {
            // GIVEN
            _database = (new TestGraphDatabaseFactory()).setFileSystem(Fs).newImpermanentDatabase();
            Node node;

            Label[] labels = new Label[] { label("a"), label("b"), label("c"), label("d"), label("e"), label("f"), label("g"), label("h"), label("i"), label("j"), label("k") };
            using (Transaction tx = _database.beginTx())
            {
                node = _database.createNode(labels);
                tx.Success();
            }

            // WHEN
            using (Transaction tx = _database.beginTx())
            {
                node.SetProperty("prop", "value");
                tx.Success();
            }
            EphemeralFileSystemAbstraction snapshot = Fs.snapshot();

            _database.shutdown();
            _database = (new TestGraphDatabaseFactory()).setFileSystem(snapshot).newImpermanentDatabase();

            // THEN
            using (Transaction ignored = _database.beginTx())
            {
                node = _database.getNodeById(node.Id);
                foreach (Label label in labels)
                {
                    assertTrue(node.HasLabel(label));
                }
            }
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            TestHighlyAvailableGraphDatabaseFactory factory = new TestHighlyAvailableGraphDatabaseFactory();
            Monitors monitors = new Monitors();

            monitors.AddMonitorListener(_monitor);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            factory.RemoveKernelExtensions(extension => extension.GetType().FullName.Contains("LabelScan"));
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory("root"))).withDbFactory(factory).withMonitors(monitors).withStoreDirInitializer((serverId, storeDir) =>
            {
                if (serverId == 1)
                {
                    GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();
                    try
                    {
                        CreateSomeLabeledNodes(db, new Label[] { Labels.First }, new Label[] { Labels.First, Labels.Second }, new Label[] { Labels.Second });
                    }
                    finally
                    {
                        Db.shutdown();
                    }
                }
            }).build();

            _life.add(clusterManager);
            _life.start();
            _cluster = clusterManager.Cluster;
            _cluster.await(allSeesAllAsAvailable());
            _cluster.await(allAvailabilityGuardsReleased());
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropIndexOnRecovery() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDropIndexOnRecovery()
        {
            // given a transaction stream ending in an INDEX DROP command.
            CommittedTransactionRepresentation dropTransaction = PrepareDropTransaction();
            File storeDir           = Directory.databaseDir();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(storeDir);

            CreateIndex(db);
            Db.shutdown();
            AppendDropTransactionToTransactionLog(Directory.databaseDir(), dropTransaction);

            // when recovering this (the drop transaction with the index file intact)
            Monitors monitors = new Monitors();
            AssertRecoveryIsPerformed recoveryMonitor = new AssertRecoveryIsPerformed();

            monitors.AddMonitorListener(recoveryMonitor);
            db = (new TestGraphDatabaseFactory()).setMonitors(monitors).newEmbeddedDatabase(storeDir);
            try
            {
                assertTrue(recoveryMonitor.RecoveryWasPerformed);

                // then
                using (Transaction tx = Db.beginTx())
                {
                    assertEquals(0, count(Db.schema().Indexes));
                    tx.Success();
                }
            }
            finally
            {
                // and the ability to shut down w/o failing on still open files
                Db.shutdown();
            }
        }
Exemplo n.º 12
0
//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);
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock()
        {
            File          file     = DbRule.databaseLayout().databaseDirectory();
            BatchInserter inserter = BatchInserters.inserter(file, FileSystemRule.get());
            long          nodeId   = inserter.createNode(Collections.emptyMap());

            const object finalValue1 = 87;
            const object finalValue2 = 3.14;

            inserter.SetNodeProperty(nodeId, "a", "some property value");
            inserter.SetNodeProperty(nodeId, "a", 42);
            inserter.SetNodeProperty(nodeId, "b", finalValue2);
            inserter.SetNodeProperty(nodeId, "a", finalValue2);
            inserter.SetNodeProperty(nodeId, "a", true);
            inserter.SetNodeProperty(nodeId, "a", finalValue1);
            inserter.Shutdown();

            GraphDatabaseService db = DbRule.GraphDatabaseAPI;

            try
            {
                using (Transaction ignored = Db.beginTx())
                {
                    assertThat(Db.getNodeById(nodeId).getProperty("a"), equalTo(finalValue1));
                    assertThat(Db.getNodeById(nodeId).getProperty("b"), equalTo(finalValue2));
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemplo n.º 14
0
 private void AssertFindSingleHit <T>(GraphDatabaseService db, Index <T> nodeIndex, string key, string value, T entity) where T : Org.Neo4j.Graphdb.PropertyContainer
 {
     // when get using hasNext + next, then
     assertEquals(entity, FindSingle(db, nodeIndex, key, value, hits =>
     {
         assertTrue(hits.hasNext());
         T result = hits.next();
         assertFalse(hits.hasNext());
         return(result);
     }));
     // when get using getSingle, then
     assertEquals(entity, FindSingle(db, nodeIndex, key, value, hits =>
     {
         T result = hits.Single;
         assertFalse(hits.hasNext());
         return(result);
     }));
     // when get using hasNext + getSingle, then
     assertEquals(entity, FindSingle(db, nodeIndex, key, value, hits =>
     {
         assertTrue(hits.hasNext());
         T result = hits.Single;
         assertFalse(hits.hasNext());
         return(result);
     }));
 }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGiveNiceErrorWhenShutdownLegacy()
        public virtual void ShouldGiveNiceErrorWhenShutdownLegacy()
        {
            GraphDatabaseService graphDb = _graph;
            Node node = graphDb.CreateNode();

            Commit();
            graphDb.Shutdown();

            try
            {
                node.Relationships;
                fail("Did not get a nice exception");
            }
            catch (DatabaseShutdownException)
            {               // good
            }
            try
            {
                graphDb.CreateNode();
                fail("Create node did not produce expected error");
            }
            catch (DatabaseShutdownException)
            {               // good
            }
        }
        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());
        }
Exemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportTotalNumberOfRelationships()
        public virtual void ShouldReportTotalNumberOfRelationships()
        {
            // given
            GraphDatabaseService graphDb = Db.GraphDatabaseAPI;
            long before = NumberOfRelationships();
            long during;

            using (Transaction tx = graphDb.BeginTx())
            {
                Node node = graphDb.CreateNode();
                node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS"));
                during = CountsForRelationship(null, null, null);
                tx.Success();
            }

            // when
            long after = NumberOfRelationships();

            // then
            assertEquals(0, before);
            assertEquals(3, during);
            assertEquals(3, after);
        }
Exemplo n.º 18
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.º 19
0
 private void WaitIndexesOnline(GraphDatabaseService database)
 {
     using (Transaction ignored = database.BeginTx())
     {
         database.Schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
     }
 }
Exemplo n.º 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIndexNodesWithMultipleLabels() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIndexNodesWithMultipleLabels()
        {
            // Given
            File          path     = DbRule.databaseLayout().databaseDirectory();
            BatchInserter inserter = BatchInserters.inserter(path, FileSystemRule.get());

            inserter.createNode(map("name", "Bob"), label("User"), label("Admin"));

            inserter.CreateDeferredSchemaIndex(label("User")).on("name").create();
            inserter.CreateDeferredSchemaIndex(label("Admin")).on("name").create();

            // When
            inserter.Shutdown();

            // Then
            GraphDatabaseService db = DbRule.GraphDatabaseAPI;

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    assertThat(count(Db.findNodes(label("User"), "name", "Bob")), equalTo(1L));
                    assertThat(count(Db.findNodes(label("Admin"), "name", "Bob")), equalTo(1L));
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemplo n.º 21
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();
            }
        }
Exemplo n.º 22
0
 internal SimpleRandomMutation(long nodeCount, GraphDatabaseService db, Mutation rareMutation, Mutation commonMutation)
 {
     this._nodeCount      = nodeCount;
     this._db             = db;
     this._rareMutation   = rareMutation;
     this._commonMutation = commonMutation;
 }
Exemplo n.º 23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void stopDb()
        public static void StopDb()
        {
            if (_graphdb != null)
            {
                _graphdb.shutdown();
            }
            _graphdb = null;
        }
Exemplo n.º 24
0
 private static void AwaitIndex(GraphDatabaseService database)
 {
     using (Transaction tx = database.BeginTx())
     {
         database.Schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
         tx.Success();
     }
 }
Exemplo n.º 25
0
 public static void AwaitIndexes(GraphDatabaseService db)
 {
     using (Transaction tx = Db.beginTx())
     {
         Db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
         tx.Success();
     }
 }
Exemplo n.º 26
0
 private static void WaitIndexes(GraphDatabaseService db)
 {
     using (Transaction transaction = Db.beginTx())
     {
         Db.schema().awaitIndexesOnline(5, TimeUnit.SECONDS);
         transaction.Success();
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// Used by non-cc </summary>
 /// <param name="db">
 /// @return </param>
 public static DbRepresentation CreateSomeData(GraphDatabaseService db)
 {
     using (Transaction tx = Db.beginTx())
     {
         CreateSomeData(db, tx);
     }
     return(DbRepresentation.of(db));
 }
Exemplo n.º 28
0
        /// <summary>
        /// Used by cc </summary>
        /// <param name="db"> </param>
        /// <param name="tx"> </param>
        public static void CreateSomeData(GraphDatabaseService db, Transaction tx)
        {
            Node node = Db.createNode();

            node.SetProperty(PROP_NAME, "Neo");
            node.SetProperty(PROP_RANDOM, GlobalRandom.NextDouble * 10000);
            Db.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS"));
            tx.Success();
        }
Exemplo n.º 29
0
 private void CleanDatabaseContent(GraphDatabaseService db)
 {
     using (Transaction tx = Db.beginTx())
     {
         Db.AllRelationships.forEach(Relationship.delete);
         Db.AllNodes.forEach(Node.delete);
         tx.Success();
     }
 }
Exemplo n.º 30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void crashAndRestart() throws Exception
        private void CrashAndRestart()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.GraphDatabaseService db1 = db;
            GraphDatabaseService  db1       = _db;
            FileSystemAbstraction uncleanFs = FsRule.snapshot(db1.shutdown);

            _db = DatabaseFactory(uncleanFs).newImpermanentDatabase();
        }