From 4f9ed8cf54a6391d83aece415641e96a7d86a0f8 Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Fri, 13 Jul 2018 09:10:24 +0200 Subject: [PATCH 1/2] Update version of jline --- build.gradle | 2 +- .../src/test/java/org/neo4j/shell/MainTest.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 133671ec..c9c01c3f 100644 --- a/build.gradle +++ b/build.gradle @@ -75,6 +75,6 @@ ext { neo4jJavaVersion = '1.6.1' findbugsVersion = '3.0.0' jansiVersion = '1.13' - jlineVersion = '2.14.2' + jlineVersion = '2.14.6' mockitoVersion = '1.9.5' } diff --git a/cypher-shell/src/test/java/org/neo4j/shell/MainTest.java b/cypher-shell/src/test/java/org/neo4j/shell/MainTest.java index db0d471e..89a1868d 100644 --- a/cypher-shell/src/test/java/org/neo4j/shell/MainTest.java +++ b/cypher-shell/src/test/java/org/neo4j/shell/MainTest.java @@ -88,7 +88,7 @@ public void connectMaybeInteractivelyPromptsForBothIfNone() throws Exception { String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); - assertEquals(out, "username: bob\r\npassword: ******\r\n"); + assertEquals( out, String.format( "username: bob%npassword: ******%n" )); verify(connectionConfig).setUsername("bob"); verify(connectionConfig).setPassword("secret"); verify(shell, times(2)).connect(connectionConfig); @@ -130,7 +130,7 @@ public void connectMaybeInteractivelyPromptsForUserIfPassExists() throws Excepti String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); - assertEquals(out, "username: bob\r\n"); + assertEquals(out, String.format( "username: bob%n" )); verify(connectionConfig).setUsername("bob"); verify(shell, times(2)).connect(connectionConfig); } @@ -151,7 +151,7 @@ public void connectMaybeInteractivelyPromptsForPassIfUserExists() throws Excepti String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); - assertEquals(out, "password: ******\r\n"); + assertEquals(out, String.format("password: ******%n")); verify(connectionConfig).setPassword("secret"); verify(shell, times(2)).connect(connectionConfig); } @@ -171,7 +171,7 @@ public void connectMaybeInteractivelyPromptsHandlesBang() throws Exception { String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); - assertEquals(out, "username: bo!b\r\npassword: *******\r\n"); + assertEquals(out, String.format("username: bo!b%npassword: *******%n")); verify(connectionConfig).setUsername("bo!b"); verify(connectionConfig).setPassword("sec!ret"); verify(shell, times(2)).connect(connectionConfig); @@ -214,8 +214,7 @@ public void connectMaybeInteractivelyRepromptsIfUserIsNotProvided() throws Excep String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); - assertEquals(out, "username: \r\nusername cannot be empty" + System.lineSeparator() + System.lineSeparator() + - "username: bob\r\npassword: ******\r\n"); + assertEquals(out, String.format( "username: %nusername cannot be empty%n%nusername: bob%npassword: ******%n") ); verify(connectionConfig).setUsername("bob"); verify(connectionConfig).setPassword("secret"); verify(shell, times(2)).connect(connectionConfig); From b5112fbfed8aa03afb39c6f01e94cb8a6d34946a Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Wed, 18 Jul 2018 16:35:45 +0200 Subject: [PATCH 2/2] fix failing test due to newline change in jline --- .../java/org/neo4j/shell/MainIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java b/cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java index 89ff7f7f..400b42d9 100644 --- a/cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java +++ b/cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java @@ -19,7 +19,7 @@ public class MainIntegrationTest { public void connectInteractivelyPromptsOnWrongAuthentication() throws Exception { // given // what the user inputs when prompted - String inputString = "neo4j\nneo\n"; + String inputString = String.format( "neo4j%nneo%n" ); InputStream inputStream = new ByteArrayInputStream(inputString.getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -58,7 +58,6 @@ public void connectInteractivelyPromptsOnWrongAuthentication() throws Exception assertEquals("neo", connectionConfig.password()); String out = baos.toString(); - assertEquals( "username: neo4j\r\n" + - "password: ***\r\n", out ); + assertEquals( String.format( "username: neo4j%npassword: ***%n" ), out ); } }