//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldKeepIdsAndMarkDuplicates() public virtual void ShouldKeepIdsAndMarkDuplicates() { // given int length = 10_000; using (BigIdTracker tracker = new BigIdTracker(NumberArrayFactory.HEAP.newByteArray(length, BigIdTracker.DefaultValue))) { // when long[] values = new long[length]; bool[] marks = new bool[length]; for (int i = 0; i < length; i++) { tracker.Set(i, values[i] = Random.nextLong(MAX_ID)); if (Random.nextBoolean()) { tracker.MarkAsDuplicate(i); marks[i] = true; } } // then for (int i = 0; i < length; i++) { assertEquals(values[i], tracker.Get(i)); assertEquals(marks[i], tracker.IsMarkedAsDuplicate(i)); } } }
private void CreateIndexesButDontWaitForThemToFullyPopulate(int i) { using (Transaction tx = Db.beginTx()) { Db.schema().indexFor(LabelA(i)).on(KeyA(i)).create(); if (Random.nextBoolean()) { Db.schema().indexFor(LabelB(i)).on(KeyB(i)).create(); } else { Db.schema().constraintFor(LabelB(i)).assertPropertyIsUnique(KeyB(i)).create(); } tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotDeadlockOrCrashFromInconsistency() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotDeadlockOrCrashFromInconsistency() { // GIVEN (A) -[R]-> (B) //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node a; Node a; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node b; Node b; using (Transaction tx = Db.beginTx()) { (a = Db.createNode()).createRelationshipTo(b = Db.createNode(), MyRelTypes.TEST); tx.Success(); } // WHEN Race race = new Race(); // a bunch of deleters for (int i = 0; i < 30; i++) { race.AddContestant(() => { for (int j = 0; j < 10; j++) { using (Transaction tx = Db.beginTx()) { Node node = Random.nextBoolean() ? a : b; foreach (Relationship relationship in node.Relationships) { try { relationship.delete(); } catch (NotFoundException e) { // This is OK and expected since there are multiple threads deleting assertTrue(e.Message.contains("already deleted")); } } tx.Success(); } } }); } // a bunch of creators for (int i = 0; i < 30; i++) { race.AddContestant(() => { for (int j = 0; j < 10; j++) { using (Transaction tx = Db.beginTx()) { bool order = Random.nextBoolean(); Node start = order ? a : b; Node end = order ? b : a; start.createRelationshipTo(end, MyRelTypes.Test); tx.Success(); } } }); } // THEN there should be no thread throwing exception, especially DeadlockDetectedException race.Go(); }