//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateLongRunningQueryWithCustomTimeoutWithoutConfiguredDefault() public virtual void TerminateLongRunningQueryWithCustomTimeoutWithoutConfiguredDefault() { GraphDatabaseAPI database = StartDatabaseWithoutTimeout(); KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) ); using ( Transaction transaction = database.BeginTx( 5, TimeUnit.SECONDS ) ) { _fakeClock.forward( 4, TimeUnit.SECONDS ); timeoutMonitor.Run(); database.Execute( "create (n)" ); transaction.Failure(); } try { using ( Transaction transaction = database.BeginTx( 6, TimeUnit.SECONDS ) ) { _fakeClock.forward( 7, TimeUnit.SECONDS ); timeoutMonitor.Run(); transaction.Success(); database.Execute( "create (n)" ); fail( "Transaction should be already terminated." ); } } catch ( TransactionTerminatedException e ) { assertThat( e.Message, startsWith( "The transaction has been terminated." ) ); } AssertDatabaseDoesNotHaveNodes( database ); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void changeTimeoutAtRuntime() public virtual void ChangeTimeoutAtRuntime() { GraphDatabaseAPI database = StartDatabaseWithTimeout(); KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) ); try { using ( Transaction transaction = database.BeginTx() ) { _fakeClock.forward( 3, TimeUnit.SECONDS ); timeoutMonitor.Run(); transaction.Success(); database.Execute( "create (n)" ); fail( "Transaction should be already terminated." ); } } catch ( TransactionTerminatedException e ) { assertThat( e.Message, startsWith( "The transaction has been terminated." ) ); } AssertDatabaseDoesNotHaveNodes( database ); // Increase timeout using ( Transaction transaction = database.BeginTx() ) { database.Execute( "CALL dbms.setConfigValue('" + transaction_timeout.name() + "', '5s')" ); transaction.Success(); } using ( Transaction transaction = database.BeginTx() ) { _fakeClock.forward( 3, TimeUnit.SECONDS ); timeoutMonitor.Run(); transaction.Success(); database.Execute( "create (n)" ); } // Assert node successfully created using ( Transaction ignored = database.BeginTx() ) { assertEquals( 1, database.AllNodes.Count() ); } // Reset timeout and cleanup using ( Transaction transaction = database.BeginTx() ) { database.Execute( "CALL dbms.setConfigValue('" + transaction_timeout.name() + "', '" + DEFAULT_TIMEOUT + "')" ); using ( Stream<Node> stream = database.AllNodes.stream() ) { stream.findFirst().map(node => { node.delete(); return node; }); } transaction.Success(); } }
//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(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateLongRunningTransactionWithPeriodicCommit() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TerminateLongRunningTransactionWithPeriodicCommit() { GraphDatabaseAPI database = StartDatabaseWithTimeout(); KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) ); _monitorSupplier.TransactionTimeoutMonitor = timeoutMonitor; try { URL url = PrepareTestImportFile( 8 ); database.Execute( "USING PERIODIC COMMIT 5 LOAD CSV FROM '" + url + "' AS line CREATE ();" ); fail( "Transaction should be already terminated." ); } catch ( TransactionTerminatedException ) { } AssertDatabaseDoesNotHaveNodes( database ); }