From bb3d239d51343bb878adcb13b1df69af99489326 Mon Sep 17 00:00:00 2001 From: Henrik Nyman Date: Wed, 29 May 2019 10:17:42 +0200 Subject: [PATCH 1/2] Fix case sensitivity of system database name Use case insensitive comparison when checking if we are on the system database to decide which ping query to use. --- .../commands/CypherShellMultiDatabaseIntegrationTest.java | 8 ++++++++ .../main/java/org/neo4j/shell/state/BoltStateHandler.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java b/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java index 47e28cd0..20b85e00 100644 --- a/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java +++ b/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java @@ -60,6 +60,14 @@ public void switchingToSystemDatabaseWorks() throws CommandException { assertOnSystemDB(); } + @Test + public void switchingToSystemDatabaseIsNotCaseSensitive() throws CommandException { + useCommand.execute("SyStEm"); + + assertThat(linePrinter.output(), is("")); + assertOnSystemDB(); + } + @Test public void switchingToSystemDatabaseAndBackToNeo4jWorks() throws CommandException { useCommand.execute(SYSTEM_DB_NAME); diff --git a/cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java b/cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java index 5ed81344..b733c0c1 100644 --- a/cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java +++ b/cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java @@ -162,7 +162,7 @@ private void reconnect(boolean keepBookmark) { }; session = driver.session(sessionArgs.andThen(sessionOptionalArgs)); - String query = activeDatabaseNameAsSetByUser.equals(SYSTEM_DB_NAME) ? "SHOW DATABASES" : "RETURN 1"; + String query = activeDatabaseNameAsSetByUser.compareToIgnoreCase(SYSTEM_DB_NAME) == 0 ? "SHOW DATABASES" : "RETURN 1"; resetActualDbName(); // Set this to null first in case run throws an exception StatementResult run = session.run(query); From 130072a9d3fee21f18077b74e68e9ae67aeac856 Mon Sep 17 00:00:00 2001 From: Henrik Nyman Date: Fri, 31 May 2019 13:17:28 +0200 Subject: [PATCH 2/2] Adapt to error message change in integration test --- .../shell/commands/CypherShellMultiDatabaseIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java b/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java index 20b85e00..a4986c6b 100644 --- a/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java +++ b/cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java @@ -108,7 +108,7 @@ public void switchingDatabaseAfterRollbackTransactionWorks() throws CommandExcep @Test public void switchingToNonExistingDatabaseShouldGiveErrorResponseFromServer() throws CommandException { thrown.expect(ClientException.class); - thrown.expectMessage("The database requested does not exist."); + thrown.expectMessage("Database does not exist"); useCommand.execute("this_database_name_does_not_exist_in_test_container"); }