//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void timeoutOnAcquiringExclusiveLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TimeoutOnAcquiringExclusiveLock() { ExpectedException.expect(new RootCauseMatcher <>(typeof(LockAcquisitionTimeoutException), "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout (dbms.lock.acquisition.timeout). " + "Unable to acquire lock for resource: NODE with id: 0 within 2000 millis.")); using (Transaction ignored = _database.beginTx()) { ResourceIterator <Node> nodes = _database.findNodes(_marker); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Node node = nodes.next(); node.SetProperty(TEST_PROPERTY_NAME, "b"); Future <Void> propertySetFuture = _secondTransactionExecutor.executeDontWait(state => { using (Transaction transaction1 = _database.beginTx()) { node.SetProperty(TEST_PROPERTY_NAME, "b"); transaction1.success(); } return(null); }); _secondTransactionExecutor.waitUntilWaiting(ExclusiveLockWaitingPredicate()); _clockExecutor.execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state => { _fakeClock.forward(3, TimeUnit.SECONDS); return(null); }); propertySetFuture.get(); fail("Should throw termination exception."); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldExpandOnFirstAccess() public virtual void ShouldExpandOnFirstAccess() { // GIVEN TraversalBranch parent = mock(typeof(TraversalBranch)); Node source = mock(typeof(Node)); TraversalBranchImpl branch = new TraversalBranchImpl(parent, source); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("rawtypes") org.neo4j.graphdb.PathExpander expander = mock(org.neo4j.graphdb.PathExpander.class); PathExpander expander = mock(typeof(PathExpander)); when(expander.expand(eq(branch), any(typeof(BranchState)))).thenReturn(Iterables.emptyResourceIterable()); TraversalContext context = mock(typeof(TraversalContext)); when(context.Evaluate(eq(branch), Null)).thenReturn(INCLUDE_AND_CONTINUE); // WHEN initializing branch.Initialize(expander, context); // THEN the branch should not be expanded verifyZeroInteractions(source); // and WHEN actually traversing from it branch.Next(expander, context); // THEN we should expand it verify(expander).expand(any(typeof(Path)), any(typeof(BranchState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pageCacheMetrics() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PageCacheMetrics() { Label testLabel = Label.label("testLabel"); using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(testLabel); node.SetProperty("property", "value"); transaction.Success(); } using (Transaction ignored = _database.beginTx()) { ResourceIterator <Node> nodes = _database.findNodes(testLabel); assertEquals(1, nodes.Count()); } AssertMetrics("Metrics report should include page cache pins", PC_PINS, greaterThan(0L)); AssertMetrics("Metrics report should include page cache unpins", PC_UNPINS, greaterThan(0L)); AssertMetrics("Metrics report should include page cache evictions", PC_EVICTIONS, greaterThanOrEqualTo(0L)); AssertMetrics("Metrics report should include page cache page faults", PC_PAGE_FAULTS, greaterThan(0L)); AssertMetrics("Metrics report should include page cache hits", PC_HITS, greaterThan(0L)); AssertMetrics("Metrics report should include page cache flushes", PC_FLUSHES, greaterThanOrEqualTo(0L)); AssertMetrics("Metrics report should include page cache exceptions", PC_EVICTION_EXCEPTIONS, equalTo(0L)); assertEventually("Metrics report should include page cache hit ratio", () => readDoubleValue(metricsCsv(_metricsDirectory, PC_HIT_RATIO)), lessThanOrEqualTo(1.0), 5, SECONDS); assertEventually("Metrics report should include page cache usage ratio", () => readDoubleValue(metricsCsv(_metricsDirectory, PC_USAGE_RATIO)), lessThanOrEqualTo(1.0), 5, SECONDS); }
protected internal override Traverser InstantiateTraverser(Node start, Node end) { GraphDatabaseService db = start.GraphDatabase; TraversalDescription side = Db.traversalDescription().breadthFirst().uniqueness(_uniqueness).order((startSource, _expander) => new LiteDepthFirstSelector(startSource, _startThreshold, _expander)); return(Db.bidirectionalTraversalDescription().startSide(side.Expand(_expander).evaluator(toDepth(_onDepth / 2))).endSide(side.Expand(_expander.reverse()).evaluator(toDepth(_onDepth - _onDepth / 2))).collisionEvaluator(atDepth(_onDepth)).traverse(start, end)); }
protected internal override Traverser InstantiateTraverser(Node start, Node end) { GraphDatabaseService db = start.GraphDatabase; TraversalDescription sideBase = Db.traversalDescription().breadthFirst().uniqueness(NODE_PATH); return(Db.bidirectionalTraversalDescription().mirroredSides(sideBase.Expand(_expander)).sideSelector(LEVEL_STOP_DESCENT_ON_RESULT, _maxDepth).collisionEvaluator(toDepth(_maxDepth)).traverse(start, end)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBidirectionalPath() public virtual void TestBidirectionalPath() { TraversalDescription side = GraphDb.traversalDescription().uniqueness(Uniqueness.NODE_PATH); BidirectionalTraversalDescription bidirectional = GraphDb.bidirectionalTraversalDescription().mirroredSides(side); Path bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); AssertPathIsCorrect(bidirectionalPath); Path path = GetFirstPath(bidirectional.Traverse(_a, _e)); Node node = path.StartNode(); assertEquals(_a, node); // White box testing below: relationships(), nodes(), reverseRelationships(), reverseNodes() // does cache the start node if not already cached, so just make sure they to it properly. bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Relationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Nodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseRelationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseNodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.GetEnumerator(); assertEquals(_a, bidirectionalPath.StartNode()); }
private Node CreateNodeWithProperty(Label label, string key, object value) { Node node = _db.createNode(label); node.SetProperty(key, value); return(node); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void timeoutOnAcquiringSharedLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TimeoutOnAcquiringSharedLock() { ExpectedException.expect(new RootCauseMatcher <>(typeof(LockAcquisitionTimeoutException), "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout (dbms.lock.acquisition.timeout). " + "Unable to acquire lock for resource: LABEL with id: 1 within 2000 millis.")); using (Transaction ignored = _database.beginTx()) { Locks lockManger = LockManager; lockManger.NewClient().acquireExclusive(LockTracer.NONE, ResourceTypes.LABEL, 1); Future <Void> propertySetFuture = _secondTransactionExecutor.executeDontWait(state => { using (Transaction nestedTransaction = _database.beginTx()) { ResourceIterator <Node> nodes = _database.findNodes(_marker); Node node = nodes.next(); node.addLabel(Label.label("anotherLabel")); nestedTransaction.success(); } return(null); }); _secondTransactionExecutor.waitUntilWaiting(SharedLockWaitingPredicate()); _clockExecutor.execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state => { _fakeClock.forward(3, TimeUnit.SECONDS); return(null); }); propertySetFuture.get(); fail("Should throw termination exception."); } }
protected internal override Traverser InstantiateTraverser(Node start, Node end) { // Bidirectional traversal GraphDatabaseService db = start.GraphDatabase; TraversalDescription @base = Db.traversalDescription().depthFirst().uniqueness(Uniqueness()); return(Db.bidirectionalTraversalDescription().startSide(@base.Expand(_expander).evaluator(toDepth(_maxDepth / 2))).endSide(@base.Expand(_expander.reverse()).evaluator(toDepth(_maxDepth - _maxDepth / 2))).traverse(start, end)); }
private Relationship GetFistRelationship(Node node) { ResourceIterable <Relationship> relationships = (ResourceIterable <Relationship>)node.GetRelationships(Direction.OUTGOING); using (ResourceIterator <Relationship> iterator = relationships.GetEnumerator()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: return(iterator.next()); } }
private void CreateNonUniqueNodes() { using (Transaction tx = _db.beginTx()) { Node originNode = _db.createNode(LABEL); originNode.SetProperty(KEY, _point1); Node centerNode = _db.createNode(LABEL); centerNode.SetProperty(KEY, _point1); 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() { CreateGraph("A TO B", "B TO C", "C TO D", "D TO E"); _tx = BeginTx(); _a = GetNodeWithName("A"); _b = GetNodeWithName("B"); _c = GetNodeWithName("C"); _d = GetNodeWithName("D"); _e = GetNodeWithName("E"); }
private void AssertNodeWith(Label label, string key, object value) { using (ResourceIterator <Node> nodes = _db.findNodes(label, key, value)) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue(nodes.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Node foundNode = nodes.next(); assertTrue(foundNode.HasLabel(label)); assertEquals(value, foundNode.GetProperty(key)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void readOwnChangesWithoutIndex() public virtual void ReadOwnChangesWithoutIndex() { // WHEN using (Transaction tx = _db.beginTx()) { Node node = _db.createNode(_label); node.SetProperty(PROPERTY_KEY, VALUE_1); AssertNodeWith(_label, PROPERTY_KEY, VALUE_1); tx.Success(); } AssertInTxNodeWith(_label, PROPERTY_KEY, VALUE_1); }
private Pair <long, long> CreateUniqueNodes() { Pair <long, long> nodeIds; using (Transaction tx = _db.beginTx()) { Node originNode = _db.createNode(LABEL); originNode.SetProperty(KEY, _point1); Node centerNode = _db.createNode(LABEL); centerNode.SetProperty(KEY, _point2); nodeIds = Pair.of(originNode.Id, centerNode.Id); tx.Success(); } return(nodeIds); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reverseRelationships() public virtual void ReverseRelationships() { Traverser traverser = GraphDb.traversalDescription().evaluator(atDepth(0)).traverse(_a); Path path = GetFirstPath(traverser); assertFalse(path.ReverseRelationships().GetEnumerator().hasNext()); Traverser traverser2 = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(_a); Path path2 = GetFirstPath(traverser2); Node[] expectedNodes = new Node[] { _e, _d, _c, _b, _a }; int index = 0; foreach (Relationship rel in path2.ReverseRelationships()) { assertEquals("For index " + index, expectedNodes[index++], rel.EndNode); } assertEquals(4, index); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void ensureCorrectPathEntitiesInShortPath() public virtual void EnsureCorrectPathEntitiesInShortPath() { /* * (a)-->(b) */ CreateGraph("a TO b"); Node a = GetNodeWithName("a"); Node b = GetNodeWithName("b"); Relationship r = a.GetSingleRelationship(To, OUTGOING); Path path = Iterables.single(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().relationships(To, OUTGOING).uniqueness(NODE_PATH)).collisionEvaluator(Evaluators.atDepth(1)).sideSelector(SideSelectorPolicies.LEVEL, 1).traverse(a, b)); AssertContainsInOrder(path.Nodes(), a, b); AssertContainsInOrder(path.ReverseNodes(), b, a); AssertContainsInOrder(path.Relationships(), r); AssertContainsInOrder(path.ReverseRelationships(), r); AssertContainsInOrder(path, a, r, b); assertEquals(a, path.StartNode()); assertEquals(b, path.EndNode()); assertEquals(r, path.LastRelationship()); }
private void AssertPathIsCorrect(Path path) { Node a = Node("A"); Relationship to1 = GetFistRelationship(a); Node b = to1.EndNode; Relationship to2 = GetFistRelationship(b); Node c = to2.EndNode; Relationship to3 = GetFistRelationship(c); Node d = to3.EndNode; Relationship to4 = GetFistRelationship(d); Node e = to4.EndNode; assertEquals(( int? )4, ( int? )path.Length()); assertEquals(a, path.StartNode()); assertEquals(e, path.EndNode()); assertEquals(to4, path.LastRelationship()); AssertContainsInOrder(path, a, to1, b, to2, c, to3, d, to4, e); AssertContainsInOrder(path.Nodes(), a, b, c, d, e); AssertContainsInOrder(path.Relationships(), to1, to2, to3, to4); AssertContainsInOrder(path.ReverseNodes(), e, d, c, b, a); AssertContainsInOrder(path.ReverseRelationships(), to4, to3, to2, to1); }
public TraversalBranchWithState(TraversalBranch parent, int depth, Node source, Relationship toHere, object inheritedState) : base(parent, depth, source, toHere) { this.StateForMe = this.StateForChildren = inheritedState; }
protected internal override TraversalBranch NewNextBranch(Node node, Relationship relationship) { return(new TraversalBranchWithState(this, Length() + 1, node, relationship, StateForChildren)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void removeNodeChangeNodeProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RemoveNodeChangeNodeProperty() { // GIVEN //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(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long nodeId; long nodeId; using (Transaction tx = _db.beginTx()) { Node node = _db.createNode(); nodeId = node.Id; node.SetProperty(PROPERTY_KEY, VALUE_1); tx.Success(); } // WHEN Future <Void> future = T2.execute(state => { using (Transaction tx = _db.beginTx()) { _db.getNodeById(nodeId).delete(); tx.Success(); barrier.Reached(); } return(null); }); try { using (Transaction tx = _db.beginTx()) { barrier.Await(); _db.getNodeById(nodeId).setProperty(PROPERTY_KEY, VALUE_2); tx.Success(); barrier.Release(); } } catch (TransactionFailureException e) { // Node was already deleted, fine. assertThat(e.InnerException, instanceOf(typeof(InvalidRecordException))); } future.get(); using (Transaction tx = _db.beginTx()) { try { _db.getNodeById(nodeId); assertEquals(VALUE_2, _db.getNodeById(nodeId).getProperty(PROPERTY_KEY, VALUE_2)); } catch (NotFoundException) { // Fine, its gone } tx.Success(); } }
public TraversalBranchWithState(TraversalBranch parent, Node source, InitialBranchState initialState) : base(parent, source) { this.StateForMe = this.StateForChildren = initialState.initialState(this); }
protected internal override TraversalBranch NewNextBranch(Node node, Relationship relationship) { return(_initialState != InitialBranchState.NO_STATE ? new TraversalBranchWithState(this, 1, node, relationship, StateForChildren) : new TraversalBranchImpl(this, 1, node, relationship)); }
internal StartNodeTraversalBranch(TraversalContext context, TraversalBranch parent, Node source, InitialBranchState initialState) : base(parent, source, initialState) { this._initialState = initialState; Evaluate(context); context.IsUniqueFirst(this); }
internal bool Accept(Org.Neo4j.Graphdb.Node start, Org.Neo4j.Graphdb.Relationship rel) { return(MatchDirection(_direction, start, rel)); }