private static HTTP.Response StartTx(HTTP.Builder http) { HTTP.Response tx = http.Post("db/data/transaction"); assertThat(tx.Status(), equalTo(201)); assertThat(tx, containsNoErrors()); return(tx); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateSingleInstanceRestTransactionThatWaitsForLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TerminateSingleInstanceRestTransactionThatWaitsForLock() { ServerControls server = _cleanupRule.add(TestServerBuilders.newInProcessBuilder().withConfig(GraphDatabaseSettings.auth_enabled, Settings.FALSE).withConfig(GraphDatabaseSettings.lock_manager, LockManagerName).withConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newServer()); GraphDatabaseService db = server.Graph(); HTTP.Builder http = withBaseUri(server.HttpURI()); long value1 = 1L; long value2 = 2L; CreateNode(db); HTTP.Response tx1 = StartTx(http); HTTP.Response tx2 = StartTx(http); AssertNumberOfActiveTransactions(2, db); HTTP.Response update1 = ExecuteUpdateStatement(tx1, value1, http); assertThat(update1.Status(), equalTo(200)); assertThat(update1, containsNoErrors()); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> tx2Result = executeInSeparateThread("tx2", () -> Future <object> tx2Result = ExecuteInSeparateThread("tx2", () => { latch.Signal(); Response update2 = ExecuteUpdateStatement(tx2, value2, http); AssertTxWasTerminated(update2); }); Await(latch); SleepForAWhile(); Terminate(tx2, http); Commit(tx1, http); HTTP.Response update3 = ExecuteUpdateStatement(tx2, value2, http); assertThat(update3.Status(), equalTo(404)); tx2Result.get(1, TimeUnit.MINUTES); AssertNodeExists(db, value1); }
private static HTTP.Response ExecuteUpdateStatement(HTTP.Response tx, long value, HTTP.Builder http) { string updateQuery = "MATCH (n:" + _label + ") SET n." + PROPERTY + "=" + value; HTTP.RawPayload json = quotedJson("{'statements': [{'statement':'" + updateQuery + "'}]}"); return(http.Post(tx.Location(), json)); }
private static void Terminate(HTTP.Response tx, HTTP.Builder http) { http.Delete(tx.Location()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void commit(org.neo4j.test.server.HTTP.Response tx, org.neo4j.test.server.HTTP.Builder http) throws org.neo4j.server.rest.domain.JsonParseException private static void Commit(HTTP.Response tx, HTTP.Builder http) { http.Post(tx.StringFromContent("commit")); }