//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()
        {
            _db = DbRule.GraphDatabaseAPI;
            if (WithIndex)
            {
                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().indexFor(_label).on(Keys[0]).create();

                    IndexCreator indexCreator = _db.schema().indexFor(_label);
                    foreach (string key in Keys)
                    {
                        indexCreator = indexCreator.On(key);
                    }
                    indexCreator.Create();
                    tx.Success();
                }

                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
                    tx.Success();
                }
            }
        }
//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()
        {
            _label = Label.label("LABEL1-" + TestName.MethodName);
            _db    = DbRule.GraphDatabaseAPI;
            if (_withIndex)
            {
                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().indexFor(_label).on(_key).create();
                    tx.Success();
                }

                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
                    tx.Success();
                }
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testGetIndexPopulationProgress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void TestGetIndexPopulationProgress()
        {
            assertFalse(IndexExists(_userLabel));

            // Create some nodes
            using (Transaction tx = _db.beginTx())
            {
                Label label = Label.label("User");

                // Create a huge bunch of users so the index takes a while to build
                for (int id = 0; id < 100000; id++)
                {
                    Node userNode = _db.createNode(label);
                    userNode.SetProperty("username", "user" + id + "@neo4j.org");
                }
                tx.Success();
            }

            // Create an index
            IndexDefinition indexDefinition;

            using (Transaction tx = _db.beginTx())
            {
                Schema schema = _db.schema();
                indexDefinition = Schema.indexFor(_userLabel).on("username").create();
                tx.Success();
            }

            // Get state and progress
            using (Transaction ignore = _db.beginTx())
            {
                Schema schema = _db.schema();
                Org.Neo4j.Graphdb.schema.Schema_IndexState state;

                IndexPopulationProgress progress;
                do
                {
                    state    = Schema.getIndexState(indexDefinition);
                    progress = Schema.getIndexPopulationProgress(indexDefinition);

                    assertTrue(progress.CompletedPercentage >= 0);
                    assertTrue(progress.CompletedPercentage <= 100);
                    Thread.Sleep(10);
                } while (state == Org.Neo4j.Graphdb.schema.Schema_IndexState.Populating);

                assertSame(state, Org.Neo4j.Graphdb.schema.Schema_IndexState.Online);
                assertEquals(100.0, progress.CompletedPercentage, 0.0001);
            }
        }
示例#4
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 indexCreationDoNotBlockQueryExecutions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexCreationDoNotBlockQueryExecutions()
        {
            Label nodeLabel = Label.label("nodeLabel");

            using (Transaction transaction = _database.beginTx())
            {
                _database.createNode(nodeLabel);
                transaction.Success();
            }

            using (Transaction transaction = _database.beginTx())
            {
                _database.schema().indexFor(Label.label("testLabel")).on("testProperty").create();

                Future <Number> countFuture = _executorService.submit(CountNodes());
                assertEquals(1, countFuture.get().intValue());

                transaction.Success();
            }
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testManualIndexPopulation() throws InterruptedException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestManualIndexPopulation()
        {
            using (Transaction tx = _database.beginTx())
            {
                _database.schema().indexFor(Label.label(FOOD_LABEL)).on(PROPERTY_NAME).create();
                tx.Success();
            }

            int labelId       = GetLabelId(FOOD_LABEL);
            int propertyKeyId = GetPropertyKeyId(PROPERTY_NAME);

            IndexingService indexingService = GetIndexingService(_database);
            IndexProxy      indexProxy      = indexingService.getIndexProxy(forLabel(labelId, propertyKeyId));

            WaitIndexOnline(indexProxy);
            assertEquals(InternalIndexState.ONLINE, indexProxy.State);
            PopulationProgress progress = indexProxy.IndexPopulationProgress;

            assertEquals(progress.Completed, progress.Total);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExportIndex()
        public virtual void TestExportIndex()
        {
            _gdb.schema().indexFor(Label.label("Foo")).on("bar").create();
            assertEquals("create index on :`Foo`(`bar`);" + lineSeparator(), DoExportGraph(_gdb));
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addingAnIndexingRuleInNestedTxShouldSucceed()
        public virtual void AddingAnIndexingRuleInNestedTxShouldSucceed()
        {
            IndexDefinition index;

            // WHEN
            IndexDefinition indexDef;

            using (Transaction tx = _db.beginTx())
            {
                using (Transaction nestedTransaction = _db.beginTx())
                {
                    indexDef = _db.schema().indexFor(_label).on(_propertyKey).create();
                    nestedTransaction.Success();
                }

                index = indexDef;
                tx.Success();
            }
            waitForIndex(_db, indexDef);

            // THEN
            assertThat(getIndexes(_db, _label), containsOnly(index));
        }
示例#8
0
        // The following tests verify that multiple interacting schema commands can be applied in the same transaction.

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void convertIndexToConstraint()
        public virtual void ConvertIndexToConstraint()
        {
            using (Transaction tx = _graphDb.beginTx())
            {
                _graphDb.schema().indexFor(_label).on(PROPERTY_KEY).create();
                tx.Success();
            }

            using (Transaction tx = _graphDb.beginTx())
            {
                IndexDefinition index = firstOrNull(_graphDb.schema().getIndexes(_label));
                index.Drop();

                _graphDb.schema().constraintFor(_label).assertPropertyIsUnique(PROPERTY_KEY).create();
                tx.Success();
            }
            // assert no exception is thrown
        }