Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void terminateLongRunningDriverQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void TerminateLongRunningDriverQuery()
		 {
			  GraphDatabaseAPI database = StartDatabaseWithTimeout();
			  KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) );
			  OpenEnterpriseNeoServer neoServer = StartNeoServer( ( GraphDatabaseFacade ) database );

			  Org.Neo4j.driver.v1.Config driverConfig = DriverConfig;

			  using ( Driver driver = GraphDatabase.driver( "bolt://localhost:" + _boltPortDatabaseWithTimeout, driverConfig ), Session session = driver.session() )
			  {
					Org.Neo4j.driver.v1.Transaction transaction = session.beginTransaction();
					transaction.run( "create (n)" ).consume();
					transaction.success();
					_fakeClock.forward( 3, TimeUnit.SECONDS );
					timeoutMonitor.Run();
					try
					{
						 transaction.run( "create (n)" ).consume();
						 fail( "Transaction should be already terminated by execution guard." );
					}
					catch ( Exception )
					{
						 // ignored
					}
			  }
			  AssertDatabaseDoesNotHaveNodes( database );
		 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void terminateLongRunningRestTransactionalEndpointWithCustomTimeoutQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void TerminateLongRunningRestTransactionalEndpointWithCustomTimeoutQuery()
		 {
			  GraphDatabaseAPI database = StartDatabaseWithTimeout();
			  KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) );
			  OpenEnterpriseNeoServer neoServer = StartNeoServer( ( GraphDatabaseFacade ) database );
			  long customTimeout = TimeUnit.SECONDS.toMillis( 10 );
			  HTTP.Response beginResponse = HTTP.withHeaders( HttpHeaderUtils.MAX_EXECUTION_TIME_HEADER, customTimeout.ToString() ).POST(TransactionUri(neoServer), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
			  assertEquals( "Response should be successful.", 201, beginResponse.Status() );

			  string transactionEndPoint = beginResponse.Location();
			  _fakeClock.forward( 3, TimeUnit.SECONDS );

			  HTTP.Response response = HTTP.POST( transactionEndPoint, quotedJson( "{ 'statements': [ { 'statement': 'CREATE (n)' } ] }" ) );
			  assertEquals( "Response should be successful.", 200, response.Status() );

			  _fakeClock.forward( 11, TimeUnit.SECONDS );
			  timeoutMonitor.Run();

			  response = HTTP.POST( transactionEndPoint, quotedJson( "{ 'statements': [ { 'statement': 'CREATE (n)' } ] }" ) );
			  assertEquals( "Response should be successful.", 200, response.Status() );

			  HTTP.Response commitResponse = HTTP.POST( transactionEndPoint + "/commit" );
			  assertEquals( "Transaction should be already closed and not found.", 404, commitResponse.Status() );

			  assertEquals( "Transaction should be forcefully closed.", TransactionNotFound.code().serialize(), commitResponse.Get("errors").findValue("code").asText() );
			  AssertDatabaseDoesNotHaveNodes( database );
		 }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.server.enterprise.OpenEnterpriseNeoServer startNeoServer(org.neo4j.kernel.impl.factory.GraphDatabaseFacade database) throws java.io.IOException
		 private OpenEnterpriseNeoServer StartNeoServer( GraphDatabaseFacade database )
		 {
			  if ( _neoServer == null )
			  {
					GuardingServerBuilder serverBuilder = new GuardingServerBuilder( this, database );
					BoltConnector boltConnector = new BoltConnector( BOLT_CONNECTOR_KEY );
					serverBuilder.WithProperty( boltConnector.Type.name(), "BOLT" ).withProperty(boltConnector.Enabled.name(), Settings.TRUE).withProperty(boltConnector.EncryptionLevel.name(), BoltConnector.EncryptionLevel.DISABLED.name()).withProperty(GraphDatabaseSettings.auth_enabled.name(), Settings.FALSE);
					serverBuilder.WithProperty( ( new HttpConnector( "http" ) ).listen_address.name(), "localhost:0" );
					_neoServer = serverBuilder.Build();
					CleanupRule.add( _neoServer );
					_neoServer.start();
			  }
			  return _neoServer;
		 }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void terminateLongRunningDriverPeriodicCommitQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void TerminateLongRunningDriverPeriodicCommitQuery()
		 {
			  GraphDatabaseAPI database = StartDatabaseWithTimeout();
			  KernelTransactionMonitor timeoutMonitor = database.DependencyResolver.resolveDependency( typeof( KernelTransactionMonitor ) );
			  _monitorSupplier.TransactionTimeoutMonitor = timeoutMonitor;
			  OpenEnterpriseNeoServer neoServer = StartNeoServer( ( GraphDatabaseFacade ) database );

			  Org.Neo4j.driver.v1.Config driverConfig = DriverConfig;

			  try
			  {
					  using ( Driver driver = GraphDatabase.driver( "bolt://localhost:" + _boltPortDatabaseWithTimeout, driverConfig ), Session session = driver.session() )
					  {
						URL url = PrepareTestImportFile( 8 );
						session.run( "USING PERIODIC COMMIT 5 LOAD CSV FROM '" + url + "' AS line CREATE ();" ).consume();
						fail( "Transaction should be already terminated by execution guard." );
					  }
			  }
			  catch ( Exception )
			  {
					//
			  }
			  AssertDatabaseDoesNotHaveNodes( database );
		 }
Exemplo n.º 5
0
		 private string TransactionUri( OpenEnterpriseNeoServer neoServer )
		 {
			  return neoServer.BaseUri().ToString() + "db/data/transaction";
		 }