Exemple #1
0
        private void AssertNotUsingCompiled(GraphDatabaseService db, string query)
        {
            _logProvider.clear();
            Db.execute(query).resultAsString();

            _logProvider.assertNone(inLog(typeof(EnterpriseCompilerFactory)).debug(anyOf(containsString("Compiling expression:"), containsString("Compiling projection:"))));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListAllLabelsInUse()
        public virtual void ShouldListAllLabelsInUse()
        {
            // Given
            GraphDatabaseService db = DbRule.GraphDatabaseAPI;

            CreateNode(db, Labels.MyLabel);
            Node node = CreateNode(db, Labels.MyOtherLabel);

            using (Transaction tx = Db.beginTx())
            {
                node.Delete();
                tx.Success();
            }

            // When
            IList <Label> labels;

            using (Transaction ignored = Db.beginTx())
            {
                labels = new IList <Label> {
                    Db.AllLabelsInUse
                };
            }

            // Then
            assertEquals(1, labels.Count);
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(map(Label::name, labels), hasItems(Labels.MyLabel.name()));
        }
 internal Writer(GraphDatabaseService db, string propertyKey, string propertyValue, AtomicBoolean start)
 {
     this.Db            = db;
     this.PropertyKey   = propertyKey;
     this.PropertyValue = propertyValue;
     this.Start         = start;
 }
Exemple #4
0
        /// <summary>
        /// Perform a transaction, with the option to automatically retry on failure.
        /// Also returning a result from the supplied transaction function.
        /// </summary>
        /// <param name="db"> <seealso cref="GraphDatabaseService"/> to apply the transaction on. </param>
        /// <param name="commit"> whether or not to call <seealso cref="Transaction.success()"/> in the end. </param>
        /// <param name="retry"> <seealso cref="RetryHandler"/> deciding what type of failures to retry on. </param>
        /// <param name="transaction"> <seealso cref="Function"/> containing the transaction logic and returning a result. </param>
        /// <returns> result from transaction <seealso cref="Function"/>. </returns>
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: public static <T> T tx(org.neo4j.graphdb.GraphDatabaseService db, boolean commit, RetryHandler retry, System.Func<? super org.neo4j.graphdb.GraphDatabaseService, T> transaction)
        public static T Tx <T, T1>(GraphDatabaseService db, bool commit, RetryHandler retry, System.Func <T1> transaction)
        {
            while (true)
            {
                try
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        T result = transaction(db);
                        if (commit)
                        {
                            tx.Success();
                        }
                        return(result);
                    }
                }
                catch (Exception t)
                {
                    if (!retry(t))
                    {
                        throw t;
                    }
                    // else continue one more time
                }
            }
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addingALabelUsingAnInvalidIdentifierShouldFail()
        public virtual void AddingALabelUsingAnInvalidIdentifierShouldFail()
        {
            // Given
            GraphDatabaseService graphDatabase = DbRule.GraphDatabaseAPI;

            // When I set an empty label
            try
            {
                using (Transaction ignored = graphDatabase.BeginTx())
                {
                    graphDatabase.CreateNode().addLabel(label(""));
                    fail("Should have thrown exception");
                }
            }
            catch (ConstraintViolationException)
            {               // Happy
            }

            // And When I set a null label
            try
            {
                using (Transaction ignored = graphDatabase.BeginTx())
                {
                    graphDatabase.CreateNode().addLabel(() => null);
                    fail("Should have thrown exception");
                }
            }
            catch (ConstraintViolationException)
            {               // Happy
            }
        }
Exemple #6
0
        private long CreateNodeWithProperty(GraphDatabaseService graphDb, string propertyKey, object value)
        {
            Node p = graphDb.CreateNode();

            p.SetProperty(propertyKey, value);
            return(p.Id);
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRuleWorkWithExistingDirectory() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRuleWorkWithExistingDirectory()
        {
            // given a root folder, create /databases/graph.db folders.
            File oldDir             = TestDirectory.directory("old");
            File storeDir           = Config.defaults(GraphDatabaseSettings.data_directory, oldDir.toPath().ToString()).get(GraphDatabaseSettings.database_path);
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(storeDir);

            try
            {
                Db.execute("CREATE ()");
            }
            finally
            {
                Db.shutdown();
            }

            // When a rule with an pre-populated graph db directory is used
            File newDir = TestDirectory.directory("new");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.harness.junit.Neo4jRule ruleWithDirectory = new org.neo4j.harness.junit.Neo4jRule(newDir).copyFrom(oldDir);
            Neo4jRule ruleWithDirectory = (new Neo4jRule(newDir)).copyFrom(oldDir);
            Statement statement         = ruleWithDirectory.apply(new StatementAnonymousInnerClass(this, ruleWithDirectory)
                                                                  , null);

            // Then
            statement.evaluate();
        }
        /// <summary>
        /// GitHub issue #5996
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void terminationOfClosedTransactionDoesNotInfluenceNextTransaction()
        public virtual void TerminationOfClosedTransactionDoesNotInfluenceNextTransaction()
        {
            GraphDatabaseService db = GlobalDb;

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

            Transaction transaction = Db.beginTx();

            using (Transaction tx = transaction)
            {
                Db.createNode();
                tx.Success();
            }
            transaction.Terminate();

            using (Transaction tx = Db.beginTx())
            {
                assertThat(Db.AllNodes, @is(iterableWithSize(2)));
                tx.Success();
            }
        }
        public GraphDbStructureGuide(GraphDatabaseService graph)
        {
            this._db = graph;
            DependencyResolver dependencies = (( GraphDatabaseAPI )graph).DependencyResolver;

            this._bridge = dependencies.ResolveDependency(typeof(ThreadToStatementContextBridge));
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReuseNodeIdsFromRolledBackTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReuseNodeIdsFromRolledBackTransaction()
        {
            // Given
            GraphDatabaseService db = DbRule.GraphDatabaseAPI;

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();

                tx.Failure();
            }

            db = DbRule.restartDatabase();

            // When
            Node node;

            using (Transaction tx = Db.beginTx())
            {
                node = Db.createNode();

                tx.Success();
            }

            // Then
            assertThat(node.Id, equalTo(0L));
        }
Exemple #11
0
 private static void CreateNodesOn(GraphDatabaseService db, int count)
 {
     for (int i = 0; i < count; i++)
     {
         CreateNodeOn(db);
     }
 }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToUpgradeAStoreWithoutIdFilesAsBackups() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldBeAbleToUpgradeAStoreWithoutIdFilesAsBackups()
            {
                File databaseDirectory = Store.prepareDirectory(TestDir.databaseDir());

                // remove id files
                File[] idFiles = databaseDirectory.listFiles((dir1, name) => name.EndsWith(".id"));

                foreach (File idFile in idFiles)
                {
                    assertTrue(idFile.delete());
                }

                GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
                GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir());

                builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true");
                builder.SetConfig(GraphDatabaseSettings.record_format, Store.FormatFamily);
                builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE);
                GraphDatabaseService db = builder.NewGraphDatabase();

                try
                {
                    CheckInstance(Store, ( GraphDatabaseAPI )db);
                }
                finally
                {
                    Db.shutdown();
                }

                assertConsistentStore(DatabaseLayout.of(databaseDirectory));
            }
Exemple #13
0
        private static void AddToResults(GraphDatabaseService db, Dictionary <TestValue, ISet <object> > results, TestValue value)
        {
            ResourceIterator <Node> foundNodes     = Db.findNodes(label(LABEL), PROPERTY_KEY, value.value);
            ISet <object>           propertyValues = asSet(Iterators.map(PropertyExtractor, foundNodes));

            results[value] = propertyValues;
        }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void given4instanceClusterWhenMasterGoesDownThenElectNewMaster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Given4instanceClusterWhenMasterGoesDownThenElectNewMaster()
        {
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(4)).build();

            try
            {
                clusterManager.Start();
                ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
                cluster.Await(allSeesAllAsAvailable());

                Logging.Logger.info("STOPPING MASTER");
                cluster.Shutdown(cluster.Master);
                Logging.Logger.info("STOPPED MASTER");

                cluster.Await(ClusterManager.masterAvailable());

                GraphDatabaseService master = cluster.Master;
                Logging.Logger.info("CREATE NODE");
                using (Transaction tx = master.BeginTx())
                {
                    master.CreateNode();
                    Logging.Logger.info("CREATED NODE");
                    tx.Success();
                }

                Logging.Logger.info("STOPPING CLUSTER");
            }
            finally
            {
                clusterManager.SafeShutdown();
            }
        }
Exemple #15
0
        private DbRepresentation CreateTransactionWithWeirdRelationshipGroupRecord(File path)
        {
            _db = StartGraphDatabase(path);
            int              i = 0;
            Node             node;
            RelationshipType typeToDelete = RelationshipType.withName("A");
            RelationshipType theOtherType = RelationshipType.withName("B");
            int              defaultDenseNodeThreshold = int.Parse(GraphDatabaseSettings.dense_node_threshold.DefaultValue);

            using (Transaction tx = _db.beginTx())
            {
                node = _db.createNode();
                for ( ; i < defaultDenseNodeThreshold - 1; i++)
                {
                    node.CreateRelationshipTo(_db.createNode(), theOtherType);
                }
                node.CreateRelationshipTo(_db.createNode(), typeToDelete);
                tx.Success();
            }
            using (Transaction tx = _db.beginTx())
            {
                node.CreateRelationshipTo(_db.createNode(), theOtherType);
                foreach (Relationship relationship in node.GetRelationships(Direction.BOTH, typeToDelete))
                {
                    relationship.Delete();
                }
                tx.Success();
            }
            DbRepresentation result = DbRepresentation.of(_db);

            _db.shutdown();
            return(result);
        }
Exemple #16
0
        private void AssertThatCommunityCanStartOnNormalConstraint(string constraintCreationQuery)
        {
            // given
            GraphDatabaseService graphDb = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir());

            try
            {
                graphDb.Execute(constraintCreationQuery);
            }
            finally
            {
                graphDb.Shutdown();
            }
            graphDb = null;

            // when
            try
            {
                graphDb = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir());
                // Should not get exception
            }
            finally
            {
                if (graphDb != null)
                {
                    graphDb.Shutdown();
                }
            }
        }
Exemple #17
0
        private Worker NewWorker(GraphDatabaseService db, System.Threading.CountdownEvent startSignal, AtomicBoolean stopSignal, AtomicReference <Exception> failure, Node parentNode)
        {
            Worker worker = new Worker(db, startSignal, stopSignal, failure, parentNode);

            worker.Start();
            return(worker);
        }
Exemple #18
0
 public ExplicitIndexProxy(string name, Type <T> type, GraphDatabaseService gds, System.Func <KernelTransaction> txBridge)
 {
     this.NameConflict = name;
     this.Type         = type;
     this._gds         = gds;
     this.TxBridge     = txBridge;
 }
Exemple #19
0
 private static void AssertIndexContents(IndexDefinition index, GraphDatabaseService db, IDictionary <object, Node> expectedData)
 {
     foreach (KeyValuePair <object, Node> entry in expectedData.SetOfKeyValuePairs())
     {
         assertEquals(asSet(entry.Value), asUniqueSet(Db.findNodes(single(index.Labels), single(index.PropertyKeys), entry.Key)));
     }
 }
Exemple #20
0
 internal CursorWrappingRelationshipIndexHits(RelationshipExplicitIndexCursor cursor, GraphDatabaseService graphDatabaseService, KernelTransaction ktx, string name) : base(cursor.ExpectedTotalNumberOfResults(), cursor.Score())
 {
     this.Cursor = cursor;
     this.GraphDatabaseService = graphDatabaseService;
     this.Ktx  = ktx;
     this.Name = name;
 }
Exemple #21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testHighIds(long highMark, int minus, int requiredHeapMb) throws java.io.IOException
        private void TestHighIds(long highMark, int minus, int requiredHeapMb)
        {
            if (!MachineIsOkToRunThisTest(requiredHeapMb))
            {
                return;
            }

            long idBelow = highMark - minus;

            HighIds = idBelow;
            string propertyKey         = "name";
            int    intPropertyValue    = 123;
            string stringPropertyValue = "Long string, longer than would fit in shortstring";

            long[] arrayPropertyValue = new long[] { 1021L, 321L, 343212L };

            Transaction tx = _db.beginTx();
            Node        nodeBelowTheLine = _db.createNode();

            nodeBelowTheLine.SetProperty(propertyKey, intPropertyValue);
            assertEquals(idBelow, nodeBelowTheLine.Id);
            Node nodeAboveTheLine = _db.createNode();

            nodeAboveTheLine.SetProperty(propertyKey, stringPropertyValue);
            Relationship relBelowTheLine = nodeBelowTheLine.CreateRelationshipTo(nodeAboveTheLine, this);

            relBelowTheLine.SetProperty(propertyKey, arrayPropertyValue);
            assertEquals(idBelow, relBelowTheLine.Id);
            Relationship relAboveTheLine = nodeAboveTheLine.CreateRelationshipTo(nodeBelowTheLine, this);

            assertEquals(highMark, relAboveTheLine.Id);
            assertEquals(highMark, nodeAboveTheLine.Id);
            assertEquals(intPropertyValue, nodeBelowTheLine.GetProperty(propertyKey));
            assertEquals(stringPropertyValue, nodeAboveTheLine.GetProperty(propertyKey));
            assertTrue(Arrays.Equals(arrayPropertyValue, ( long[] )relBelowTheLine.GetProperty(propertyKey)));
            tx.Success();
            tx.Close();

            for (int i = 0; i < 2; i++)
            {
                using (Transaction transaction = _db.beginTx())
                {
                    assertEquals(nodeAboveTheLine, _db.getNodeById(highMark));
                    assertEquals(idBelow, nodeBelowTheLine.Id);
                    assertEquals(highMark, nodeAboveTheLine.Id);
                    assertEquals(idBelow, relBelowTheLine.Id);
                    assertEquals(highMark, relAboveTheLine.Id);
                    assertEquals(relBelowTheLine, _db.getNodeById(idBelow).getSingleRelationship(this, Direction.OUTGOING));
                    assertEquals(relAboveTheLine, _db.getNodeById(idBelow).getSingleRelationship(this, Direction.INCOMING));
                    assertEquals(idBelow, relBelowTheLine.Id);
                    assertEquals(highMark, relAboveTheLine.Id);
                    assertEquals(AsSet(asList(relBelowTheLine, relAboveTheLine)), AsSet(Iterables.asCollection(_db.getNodeById(idBelow).Relationships)));
                    transaction.Success();
                }
                if (i == 0)
                {
                    _db = DbRule.restartDatabase();
                }
            }
        }
Exemple #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nonEmptyForeignDbShouldNotBeAbleToJoin()
        public virtual void NonEmptyForeignDbShouldNotBeAbleToJoin()
        {
            // GIVEN
            // -- one instance running
            int firstInstanceClusterPort = PortAuthority.allocatePort();

            _firstInstance = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDirectory.directory("1")).setConfig(server_id, "1").setConfig(initial_hosts, "127.0.0.1:" + firstInstanceClusterPort).setConfig(cluster_server, "127.0.0.1:" + firstInstanceClusterPort).setConfig(ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();
            CreateNodes(_firstInstance, 3, "first");
            // -- another instance preparing to join with a store with a different store ID
            File foreignDbStoreDir = CreateAnotherStore(TestDirectory.databaseDir("2"), 1);

            // WHEN
            // -- the other joins
            _foreignInstance = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(foreignDbStoreDir).setConfig(server_id, "2").setConfig(initial_hosts, "127.0.0.1:" + firstInstanceClusterPort).setConfig(cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(state_switch_timeout, "5s").setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();

            try
            {
                // THEN
                // -- that node should arrive at the master
                CreateNode(_foreignInstance, "foreigner");
                fail("Shouldn't be able to create a node, since it shouldn't have joined");
            }
            catch (Exception)
            {
                // Good
            }
        }
Exemple #23
0
        private static Node CreateNamedNode(GraphDatabaseService db, string name)
        {
            Node node = Db.createNode();

            node.SetProperty("name", name);
            return(node);
        }
Exemple #24
0
 private void CreateNodes(GraphDatabaseService db, int transactions, string prefix)
 {
     for (int i = 0; i < transactions; i++)
     {
         CreateNode(db, prefix + i);
     }
 }
Exemple #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getNodesWithLabelsWithTxAddsAndRemoves()
        public virtual void getNodesWithLabelsWithTxAddsAndRemoves()
        {
            // GIVEN
            GraphDatabaseService beansAPI = DbRule.GraphDatabaseAPI;
            Node node1 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel);
            Node node2 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel);

            // WHEN
            Node        node3;
            ISet <Node> nodesWithMyLabel;
            ISet <Node> nodesWithMyOtherLabel;

            using (Transaction tx = beansAPI.BeginTx())
            {
                node3 = beansAPI.CreateNode(Labels.MyLabel);
                node2.RemoveLabel(Labels.MyLabel);
                // extracted here to be asserted below
                nodesWithMyLabel      = asSet(beansAPI.FindNodes(Labels.MyLabel));
                nodesWithMyOtherLabel = asSet(beansAPI.FindNodes(Labels.MyOtherLabel));
                tx.Success();
            }

            // THEN
            assertEquals(asSet(node1, node3), nodesWithMyLabel);
            assertEquals(asSet(node1, node2), nodesWithMyOtherLabel);
        }
Exemple #26
0
 public Transactor(GraphDatabaseService graphDb, UnitOfWork unitOfWork, int attempts)
 {
     Debug.Assert(attempts > 0, "The Transactor should make at least one attempt at running the transaction.");
     this._unitOfWork = unitOfWork;
     this._graphDb    = graphDb;
     this._attempts   = attempts;
 }
Exemple #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void deleteAllNodesAndTheirLabels()
        public virtual void DeleteAllNodesAndTheirLabels()
        {
            // GIVEN
            GraphDatabaseService db = DbRule.GraphDatabaseAPI;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Label label = label("A");
            Label label = label("A");

            using (Transaction tx = Db.beginTx())
            {
                Node node = Db.createNode();
                node.AddLabel(label);
                node.SetProperty("name", "bla");
                tx.Success();
            }

            // WHEN
            using (Transaction tx = Db.beginTx())
            {
                foreach (Node node in Db.AllNodes)
                {
                    node.removeLabel(label);                    // remove Label ...
                    node.delete();                              // ... and afterwards the node
                }
                tx.Success();
            }               // tx.close(); - here comes the exception

            // THEN
            using (Transaction ignored = Db.beginTx())
            {
                assertEquals(0, Iterables.count(Db.AllNodes));
            }
        }
Exemple #28
0
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            IList <Node> deleted = new List <Node>();

            using (Transaction tx = graphDb.BeginTx())
            {
                for (int i = 0; i < _nNodes; i++)
                {
                    Node node = graphDb.CreateNode();
                    if (_random.nextBoolean())
                    {
                        _nodeIds.Add(node.Id);
                    }
                    else
                    {
                        deleted.Add(node);
                    }
                }
                tx.Success();
            }

            using (Transaction tx = graphDb.BeginTx())
            {
                foreach (Node node in deleted)
                {
                    node.Delete();
                }
                tx.Success();
            }
        }
        internal static StartNode Dense(GraphDatabaseService graphDb)
        {
            Node node;
            IDictionary <string, IList <StartRelationship> > relationshipMap;

            using (Transaction tx = graphDb.BeginTx())
            {
                node            = graphDb.CreateNode();
                relationshipMap = BuildSparseDenseRels(node);

                IList <StartRelationship> bulk     = new List <StartRelationship>();
                RelationshipType          bulkType = withName("BULK");

                for (int i = 0; i < 200; i++)
                {
                    Relationship r = node.CreateRelationshipTo(graphDb.CreateNode(), bulkType);
                    bulk.Add(new StartRelationship(r.Id, Direction.OUTGOING, bulkType));
                }

                string bulkKey = ComputeKey("BULK", Direction.OUTGOING);
                relationshipMap[bulkKey] = bulk;

                tx.Success();
            }
            return(new StartNode(node.Id, relationshipMap));
        }
Exemple #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @GET @Path("inject-test") @Produces(javax.ws.rs.core.MediaType.TEXT_PLAIN) public javax.ws.rs.core.Response countNodes(@Context GraphDatabaseService db)
        public virtual Response CountNodes(GraphDatabaseService db)
        {
            using (Transaction transaction = Db.beginTx())
            {
                return(Response.ok().entity(CountNodesIn(db).ToString()).build());
            }
        }