public virtual string AllowedFunction1() { Result result = Db.execute("MATCH (:Foo) WITH count(*) AS c RETURN 'foo' AS foo"); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: return(result.Next()["foo"].ToString()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canBeEnabledAndDisabledAtRuntime() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CanBeEnabledAndDisabledAtRuntime() { _database = _databaseBuilder.setConfig(log_queries, Settings.FALSE).setConfig(GraphDatabaseSettings.log_queries_filename, _logFilename.Path).newGraphDatabase(); IList <string> strings; try { _database.execute(QUERY).close(); // File will not be created until query logging is enabled. assertFalse(FileSystem.fileExists(_logFilename)); _database.execute("CALL dbms.setConfigValue('" + log_queries.name() + "', 'true')").close(); _database.execute(QUERY).close(); // Both config change and query should exist strings = ReadAllLines(_logFilename); assertEquals(2, strings.Count); _database.execute("CALL dbms.setConfigValue('" + log_queries.name() + "', 'false')").close(); _database.execute(QUERY).close(); } finally { _database.shutdown(); } // Value should not change when disabled strings = ReadAllLines(_logFilename); assertEquals(2, strings.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void disabledQueryLogRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DisabledQueryLogRotation() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File logsDirectory = new java.io.File(testDirectory.storeDir(), "logs"); File logsDirectory = new File(TestDirectory.storeDir(), "logs"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File logFilename = new java.io.File(logsDirectory, "query.log"); File logFilename = new File(logsDirectory, "query.log"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File shiftedLogFilename1 = new java.io.File(logsDirectory, "query.log.1"); File shiftedLogFilename1 = new File(logsDirectory, "query.log.1"); _database = _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(logs_directory, logsDirectory.Path).setConfig(log_queries_rotation_threshold, "0").newGraphDatabase(); // Logging is done asynchronously, so write many times to make sure we would have rotated something for (int i = 0; i < 100; i++) { _database.execute(QUERY); } _database.shutdown(); assertFalse("There should not exist a shifted log file because rotation is disabled", shiftedLogFilename1.exists()); IList <string> lines = ReadAllLines(logFilename); assertEquals(100, lines.Count); }
public virtual IList <object> NodeList() { Result result = Db.execute("MATCH (n) RETURN n LIMIT 1"); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: object node = result.Next()["n"]; return(Collections.singletonList(node)); }
public virtual Stream <NodeResult> ReadNodesReturnThemAndTerminateTheTransaction() { Result result = Db.execute("MATCH (n) RETURN n"); //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: NodeResult[] results = result.Select(record => ( Node )record.get("n")).Select(NodeResult::new).ToArray(NodeResult[] ::new); return(Iterators.stream(new TransactionTerminatingIterator <>(Tx, results))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void queryLogRotation() public virtual void QueryLogRotation() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File logsDirectory = new java.io.File(testDirectory.storeDir(), "logs"); File logsDirectory = new File(TestDirectory.storeDir(), "logs"); _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(logs_directory, logsDirectory.Path).setConfig(log_queries_max_archives, "100").setConfig(log_queries_rotation_threshold, "1"); _database = _databaseBuilder.newGraphDatabase(); // Logging is done asynchronously, and it turns out it's really hard to make it all work the same on Linux // and on Windows, so just write many times to make sure we rotate several times. for (int i = 0; i < 100; i++) { _database.execute(QUERY); } _database.shutdown(); File[] queryLogs = FileSystem.get().listFiles(logsDirectory, (dir, name) => name.StartsWith("query.log")); assertThat("Expect to have more then one query log file.", queryLogs.Length, greaterThanOrEqualTo(2)); IList <string> loggedQueries = java.util.queryLogs.Select(this.readAllLinesSilent).flatMap(System.Collections.ICollection.stream).ToList(); assertThat("Expected log file to have at least one log entry", loggedQueries, hasSize(100)); _database = _databaseBuilder.newGraphDatabase(); // Now modify max_archives and rotation_threshold at runtime, and observe that we end up with fewer larger files _database.execute("CALL dbms.setConfigValue('" + log_queries_max_archives.name() + "','1')"); _database.execute("CALL dbms.setConfigValue('" + log_queries_rotation_threshold.name() + "','20m')"); for (int i = 0; i < 100; i++) { _database.execute(QUERY); } _database.shutdown(); queryLogs = FileSystem.get().listFiles(logsDirectory, (dir, name) => name.StartsWith("query.log")); assertThat("Expect to have more then one query log file.", queryLogs.Length, lessThan(100)); loggedQueries = java.util.queryLogs.Select(this.readAllLinesSilent).flatMap(System.Collections.ICollection.stream).ToList(); assertThat("Expected log file to have at least one log entry", loggedQueries.Count, lessThanOrEqualTo(202)); }
private Callable <Number> CountNodes() { return(() => { using (Transaction transaction = _database.beginTx()) { Result result = _database.execute("MATCH (n) RETURN count(n) as count"); IDictionary <string, object> resultMap = result.next(); return ( Number )resultMap.get("count"); } }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void collections_in_collections_look_alright() public virtual void CollectionsInCollectionsLookAlright() { Result result = _db.execute("CREATE (n:TheNode) RETURN [[ [1,2],[3,4] ],[[5,6]]] as x"); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: IDictionary <string, object> next = result.Next(); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<java.util.List<Object>> x = (java.util.List<java.util.List<Object>>)next.get("x"); IList <IList <object> > x = (IList <IList <object> >)next["x"]; System.Collections.IEnumerable objects = x[0]; assertThat(objects, isA(typeof(System.Collections.IEnumerable))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @GET @Path("createConstraint") public javax.ws.rs.core.Response createProperty() public virtual Response CreateProperty() { try { using (Transaction tx = _db.beginTx()) { using (Result result = _db.execute("CREATE CONSTRAINT ON (user:User) ASSERT exists(user.name)")) { // nothing to-do } tx.Success(); return(Response.status(HttpStatus.CREATED_201).build()); } } catch (Exception) { return(Response.status(HttpStatus.NOT_IMPLEMENTED_501).build()); } }
public virtual Stream <AuthProceduresBase.StringResult> AllowedProcedure1() { Result result = Db.execute("MATCH (:Foo) WITH count(*) AS c RETURN 'foo' AS foo"); return(result.Select(r => new AuthProceduresBase.StringResult(r.get("foo").ToString()))); }
private void ExecuteSingleQueryWithTimeZoneLog() { _database = _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM.name()).setConfig(logs_directory, _logsDirectory.Path).newGraphDatabase(); _database.execute(QUERY).close(); _database.shutdown(); }