//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRecoverTransactionWhereManyLabelsAreRemovedInTheFuture() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRecoverTransactionWhereManyLabelsAreRemovedInTheFuture() { // GIVEN CreateIndex(_label, "key"); Label[] labels = new Label[16]; for (int i = 0; i < labels.Length; i++) { labels[i] = label("Label" + i.ToString("x")); } Node node; using (Transaction tx = _db.beginTx()) { node = _db.createNode(labels); node.AddLabel(_label); tx.Success(); } CheckPoint(); SetProperty(node, "key", "value"); RemoveLabels(node, labels); _flush.flush(_db); // WHEN CrashAndRestart(); // THEN // -- really the problem was that recovery threw exception, so mostly assert that. using (Transaction tx = _db.beginTx()) { assertEquals(node, _db.findNode(_label, "key", "value")); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void startDb() public virtual void StartDb() { _graphDb = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder().setConfig(new Dictionary <string, string>()).newGraphDatabase(); using (Transaction tx = _graphDb.beginTx()) { // Create the node and relationship auto-indexes _graphDb.index().NodeAutoIndexer.Enabled = true; _graphDb.index().NodeAutoIndexer.startAutoIndexingProperty("nodeProp"); _graphDb.index().RelationshipAutoIndexer.Enabled = true; _graphDb.index().RelationshipAutoIndexer.startAutoIndexingProperty("type"); tx.Success(); } using (Transaction tx = _graphDb.beginTx()) { Node node1 = _graphDb.createNode(); Node node2 = _graphDb.createNode(); Node node3 = _graphDb.createNode(); _id1 = node1.Id; _id2 = node2.Id; _id3 = node3.Id; Relationship rel = node1.CreateRelationshipTo(node2, RelationshipType.withName("FOO")); rel.SetProperty("type", "FOO"); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void transactionShouldReleaseLocksWhenGraphDbIsBeingShutdown() public virtual void TransactionShouldReleaseLocksWhenGraphDbIsBeingShutdown() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.locking.Locks locks = db.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.locking.Locks.class); Locks locks = _db.DependencyResolver.resolveDependency(typeof(Locks)); assertEquals(0, LockCount(locks)); Exception exceptionThrownByTxClose = null; // WHEN try { using (Transaction tx = _db.beginTx()) { Node node = _db.createNode(); tx.AcquireWriteLock(node); assertThat(LockCount(locks), greaterThanOrEqualTo(1)); _db.shutdown(); _db.createNode(); tx.Success(); } } catch (Exception e) { exceptionThrownByTxClose = e; } // THEN assertThat(exceptionThrownByTxClose, instanceOf(typeof(DatabaseShutdownException))); assertFalse(_db.isAvailable(1)); assertEquals(0, LockCount(locks)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() { { // GIVEN Transaction tx = _db.beginTx(); _db.createNode(); _db.createNode(); tx.Success(); tx.Close(); } // WHEN iterator is started Transaction transaction = _db.beginTx(); IEnumerator <Node> allNodes = _db.AllNodes.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: allNodes.next(); // and WHEN another node is then added Thread thread = new Thread(() => { Transaction newTx = _db.beginTx(); assertThat(newTx, not(instanceOf(typeof(PlaceboTransaction)))); _db.createNode(); newTx.success(); newTx.close(); }); thread.Start(); thread.Join(); // THEN the new node is picked up by the iterator assertThat(addToCollection(allNodes, new List <>()).size(), @is(2)); transaction.Close(); }
private Node CreateLabeledNode() { using (Transaction tx = _db.beginTx()) { Node node = _db.createNode(_label); tx.Success(); return(node); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSetSingleProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSetSingleProperty() { // Given Node node = _db.createNode(); // When _propSetter.setProperty(node, "name", "bob"); // Then assertThat(node.GetProperty("name"), @is("bob")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void fulltextIndexesMustBeUpdatedByIncrementalBackup() public virtual void FulltextIndexesMustBeUpdatedByIncrementalBackup() { InitializeTestData(); File backup = _dir.databaseDir("backup"); OnlineBackup.from("127.0.0.1", _backupPort).backup(backup); long nodeId3; long nodeId4; long relId2; using (Transaction tx = _db.beginTx()) { Node node3 = _db.createNode(_label); node3.SetProperty(PROP, "Additional data."); Node node4 = _db.createNode(_label); node4.SetProperty(PROP, "Even more additional data."); Relationship rel = node3.CreateRelationshipTo(node4, _rel); rel.SetProperty(PROP, "Knows of"); nodeId3 = node3.Id; nodeId4 = node4.Id; relId2 = rel.Id; tx.Success(); } VerifyData(_db); OnlineBackup.from("127.0.0.1", _backupPort).backup(backup); _db.shutdown(); GraphDatabaseAPI backupDb = StartBackupDatabase(backup); VerifyData(backupDb); using (Transaction tx = backupDb.BeginTx()) { using (Result nodes = backupDb.Execute(format(QUERY_NODES, NODE_INDEX, "additional"))) { IList <long> nodeIds = nodes.Select(m => (( Node )m.get(NODE)).Id).ToList(); assertThat(nodeIds, containsInAnyOrder(nodeId3, nodeId4)); } using (Result relationships = backupDb.Execute(format(QUERY_RELS, REL_INDEX, "knows"))) { IList <long> relIds = relationships.Select(m => (( Relationship )m.get(RELATIONSHIP)).Id).ToList(); assertThat(relIds, containsInAnyOrder(relId2)); } tx.Success(); } }
private void CreateLegacyIndex() { using (Transaction tx = _graphDb.beginTx()) { Index <Node> nodeIndex = _graphDb.index().forNodes(INDEX); nodeIndex.Add(_graphDb.createNode(), "some-key", "som-value"); tx.Success(); } }
private Node CreateNode() { using (Transaction tx = _graphDb.beginTx()) { Node node = _graphDb.createNode(); tx.Success(); return(node); } }
protected internal static Node CreateLabeledNode(GraphDatabaseService db, IDictionary <string, object> properties, params Label[] labels) { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(labels); foreach (KeyValuePair <string, object> property in properties.SetOfKeyValuePairs()) { node.SetProperty(property.Key, property.Value); } tx.Success(); return(node); } }
public override Node CreateNode() { return(_database.createNode()); }
public override Node CreateNode(params Label[] labels) { return(GraphDatabaseAPI.createNode(labels)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNodeAutoIndexFromAPISanity() public virtual void TestNodeAutoIndexFromAPISanity() { NewTransaction(); AutoIndexer <Node> autoIndexer = _graphDb.index().NodeAutoIndexer; autoIndexer.StartAutoIndexingProperty("test_uuid"); autoIndexer.Enabled = true; assertEquals(1, autoIndexer.AutoIndexedProperties.Count); assertTrue(autoIndexer.AutoIndexedProperties.Contains("test_uuid")); Node node1 = _graphDb.createNode(); node1.SetProperty("test_uuid", "node1"); Node node2 = _graphDb.createNode(); node2.SetProperty("test_uuid", "node2"); NewTransaction(); assertEquals(node1, autoIndexer.AutoIndex.get("test_uuid", "node1").Single); assertEquals(node2, autoIndexer.AutoIndex.get("test_uuid", "node2").Single); }