Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit a18bcd6

Browse files
committed
Update MainTest and CypherShellTest
1 parent a18f541 commit a18bcd6

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

cypher-shell/src/test/java/org/neo4j/shell/CypherShellTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void verifyDelegationOfConnectionMethods() throws CommandException {
6666
CypherShell shell = new CypherShell(logger, mockedBoltStateHandler, mockedPrettyPrinter, new ShellParameterMap());
6767

6868
shell.connect(cc);
69-
verify(mockedBoltStateHandler).connect(cc);
69+
verify(mockedBoltStateHandler).connect(cc, null);
7070

7171
shell.isConnected();
7272
verify(mockedBoltStateHandler).isConnected();

cypher-shell/src/test/java/org/neo4j/shell/MainTest.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,30 @@ public void nonEndedStringFails() throws Exception {
5757
String inputString = "no newline";
5858
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
5959

60-
doThrow(authException).when(shell).connect(connectionConfig);
60+
doThrow(authException).when(shell).connect(connectionConfig, null);
6161

6262
thrown.expectMessage("No text could be read, exiting");
6363

6464
Main main = new Main(inputStream, out);
6565
main.connectMaybeInteractively(shell, connectionConfig, true, true);
66-
verify(shell, times(1)).connect(connectionConfig);
66+
verify(shell, times(1)).connect(connectionConfig, null);
6767
}
6868

6969
@Test
7070
public void unrelatedErrorDoesNotPrompt() throws Exception {
71-
doThrow(new RuntimeException("bla")).when(shell).connect(connectionConfig);
71+
doThrow(new RuntimeException("bla")).when(shell).connect(connectionConfig, null);
7272

7373
thrown.expect(RuntimeException.class);
7474
thrown.expectMessage("bla");
7575

7676
Main main = new Main(mock(InputStream.class), out);
7777
main.connectMaybeInteractively(shell, connectionConfig, true, true);
78-
verify(shell, times(1)).connect(connectionConfig);
78+
verify(shell, times(1)).connect(connectionConfig, null);
7979
}
8080

8181
@Test
8282
public void promptsForUsernameAndPasswordIfNoneGivenIfInteractive() throws Exception {
83-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
83+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
8484

8585
String inputString = "bob\nsecret\n";
8686
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -96,7 +96,7 @@ public void promptsForUsernameAndPasswordIfNoneGivenIfInteractive() throws Excep
9696
assertEquals(String.format( "username: bob%npassword: ******%n" ), out);
9797
verify(connectionConfig).setUsername("bob");
9898
verify(connectionConfig).setPassword("secret");
99-
verify(shell, times(2)).connect(connectionConfig);
99+
verify(shell, times(2)).connect(connectionConfig, null);
100100
}
101101

102102
@Test
@@ -106,7 +106,7 @@ public void promptsSilentlyForUsernameAndPasswordIfNoneGivenIfOutputRedirected()
106106
return;
107107
}
108108

109-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
109+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
110110
doReturn("").doReturn("secret").when(connectionConfig).password();
111111

112112
String inputString = "bob\nsecret\n";
@@ -130,7 +130,7 @@ public void promptsSilentlyForUsernameAndPasswordIfNoneGivenIfOutputRedirected()
130130
assertEquals("", out);
131131
verify(connectionConfig).setUsername("bob");
132132
verify(connectionConfig).setPassword("secret");
133-
verify(shell, times(2)).connect(connectionConfig);
133+
verify(shell, times(2)).connect(connectionConfig, null);
134134
} finally {
135135
System.setIn(stdIn);
136136
System.setOut(stdOut);
@@ -139,7 +139,7 @@ public void promptsSilentlyForUsernameAndPasswordIfNoneGivenIfOutputRedirected()
139139

140140
@Test
141141
public void doesNotPromptIfInputRedirected() throws Exception {
142-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
142+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
143143

144144
String inputString = "bob\nsecret\n";
145145
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -153,13 +153,13 @@ public void doesNotPromptIfInputRedirected() throws Exception {
153153
main.connectMaybeInteractively(shell, connectionConfig, false, true);
154154
fail("Expected auth exception");
155155
} catch (AuthenticationException e) {
156-
verify(shell, times(1)).connect(connectionConfig);
156+
verify(shell, times(1)).connect(connectionConfig, null);
157157
}
158158
}
159159

160160
@Test
161161
public void promptsForUserIfPassExistsIfInteractive() throws Exception {
162-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
162+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
163163
doReturn("secret").when(connectionConfig).password();
164164

165165
String inputString = "bob\n";
@@ -175,7 +175,7 @@ public void promptsForUserIfPassExistsIfInteractive() throws Exception {
175175

176176
assertEquals(out, String.format( "username: bob%n" ));
177177
verify(connectionConfig).setUsername("bob");
178-
verify(shell, times(2)).connect(connectionConfig);
178+
verify(shell, times(2)).connect(connectionConfig, null);
179179
}
180180

181181
@Test
@@ -185,7 +185,7 @@ public void promptsSilentlyForUserIfPassExistsIfOutputRedirected() throws Except
185185
return;
186186
}
187187

188-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
188+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
189189
doReturn("secret").when(connectionConfig).password();
190190

191191
String inputString = "bob\n";
@@ -208,7 +208,7 @@ public void promptsSilentlyForUserIfPassExistsIfOutputRedirected() throws Except
208208

209209
assertEquals(out, "");
210210
verify(connectionConfig).setUsername("bob");
211-
verify(shell, times(2)).connect(connectionConfig);
211+
verify(shell, times(2)).connect(connectionConfig, null);
212212
} finally {
213213
System.setIn(stdIn);
214214
System.setOut(stdOut);
@@ -232,7 +232,7 @@ public void promptsForPassBeforeConnectIfUserExistsIfInteractive() throws Except
232232

233233
assertEquals(out, String.format("password: ******%n"));
234234
verify(connectionConfig).setPassword("secret");
235-
verify(shell, times(1)).connect(connectionConfig);
235+
verify(shell, times(1)).connect(connectionConfig, null);
236236
}
237237

238238
@Test
@@ -265,7 +265,7 @@ public void promptsSilentlyForPassIfUserExistsIfOutputRedirected() throws Except
265265

266266
assertEquals(out, "");
267267
verify(connectionConfig).setPassword("secret");
268-
verify(shell, times(1)).connect(connectionConfig);
268+
verify(shell, times(1)).connect(connectionConfig, null);
269269
} finally {
270270
System.setIn(stdIn);
271271
System.setOut(stdOut);
@@ -276,7 +276,7 @@ public void promptsSilentlyForPassIfUserExistsIfOutputRedirected() throws Except
276276
public void promptsForNewPasswordIfPasswordChangeRequired() throws Exception {
277277
// Use a real ConnectionConfig instead of the mock in this test
278278
ConnectionConfig connectionConfig = new ConnectionConfig("", "", 0, "", "", false, "");
279-
doThrow(authException).doThrow(passwordChangeRequiredException).doNothing().when(shell).connect(connectionConfig);
279+
doThrow(authException).doThrow(passwordChangeRequiredException).doNothing().when(shell).connect(connectionConfig, null);
280280

281281
String inputString = "bob\nsecret\nnewsecret\n";
282282
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -293,15 +293,15 @@ public void promptsForNewPasswordIfPasswordChangeRequired() throws Exception {
293293
assertEquals("bob", connectionConfig.username());
294294
assertEquals("secret", connectionConfig.password());
295295
assertEquals("newsecret", connectionConfig.newPassword());
296-
verify(shell, times(3)).connect(connectionConfig);
296+
verify(shell, times(3)).connect(connectionConfig, null);
297297
verify(shell).changePassword(connectionConfig);
298298
}
299299

300300
@Test
301301
public void promptsForNewPasswordIfPasswordChangeRequiredCannotBeEmpty() throws Exception {
302302
// Use a real ConnectionConfig instead of the mock in this test
303303
ConnectionConfig connectionConfig = new ConnectionConfig("", "", 0, "", "", false, "");
304-
doThrow(authException).doThrow(passwordChangeRequiredException).doNothing().when(shell).connect(connectionConfig);
304+
doThrow(authException).doThrow(passwordChangeRequiredException).doNothing().when(shell).connect(connectionConfig, null);
305305

306306
String inputString = "bob\nsecret\n\nnewsecret\n";
307307
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -318,13 +318,13 @@ public void promptsForNewPasswordIfPasswordChangeRequiredCannotBeEmpty() throws
318318
assertEquals("bob", connectionConfig.username());
319319
assertEquals("secret", connectionConfig.password());
320320
assertEquals("newsecret", connectionConfig.newPassword());
321-
verify(shell, times(3)).connect(connectionConfig);
321+
verify(shell, times(3)).connect(connectionConfig, null);
322322
verify(shell).changePassword(connectionConfig);
323323
}
324324

325325
@Test
326326
public void promptsHandlesBang() throws Exception {
327-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
327+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
328328

329329
String inputString = "bo!b\nsec!ret\n";
330330
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -340,12 +340,12 @@ public void promptsHandlesBang() throws Exception {
340340
assertEquals(String.format("username: bo!b%npassword: *******%n"), out);
341341
verify(connectionConfig).setUsername("bo!b");
342342
verify(connectionConfig).setPassword("sec!ret");
343-
verify(shell, times(2)).connect(connectionConfig);
343+
verify(shell, times(2)).connect(connectionConfig, null);
344344
}
345345

346346
@Test
347347
public void triesOnlyOnceIfUserPassExists() throws Exception {
348-
doThrow(authException).doThrow(new RuntimeException("second try")).when(shell).connect(connectionConfig);
348+
doThrow(authException).doThrow(new RuntimeException("second try")).when(shell).connect(connectionConfig, null);
349349
doReturn("bob").when(connectionConfig).username();
350350
doReturn("secret").when(connectionConfig).password();
351351

@@ -361,13 +361,13 @@ public void triesOnlyOnceIfUserPassExists() throws Exception {
361361
fail("Expected an exception");
362362
} catch (Neo4jException e) {
363363
assertEquals(authException.code(), e.code());
364-
verify(shell, times(1)).connect(connectionConfig);
364+
verify(shell, times(1)).connect(connectionConfig, null);
365365
}
366366
}
367367

368368
@Test
369369
public void repromptsIfUserIsNotProvidedIfInteractive() throws Exception {
370-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
370+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
371371

372372
String inputString = "\nbob\nsecret\n";
373373
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -383,7 +383,7 @@ public void repromptsIfUserIsNotProvidedIfInteractive() throws Exception {
383383
assertEquals(String.format( "username: %nusername cannot be empty%n%nusername: bob%npassword: ******%n"), out );
384384
verify(connectionConfig).setUsername("bob");
385385
verify(connectionConfig).setPassword("secret");
386-
verify(shell, times(2)).connect(connectionConfig);
386+
verify(shell, times(2)).connect(connectionConfig, null);
387387
}
388388

389389
@Test
@@ -393,7 +393,7 @@ public void doesNotRepromptIfUserIsNotProvidedIfOutputRedirected() throws Except
393393
return;
394394
}
395395

396-
doThrow(authException).doNothing().when(shell).connect(connectionConfig);
396+
doThrow(authException).doNothing().when(shell).connect(connectionConfig, null);
397397

398398
String inputString = "\nsecret\n";
399399
InputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
@@ -416,7 +416,7 @@ public void doesNotRepromptIfUserIsNotProvidedIfOutputRedirected() throws Except
416416
assertEquals("", out );
417417
verify(connectionConfig).setUsername("");
418418
verify(connectionConfig).setPassword("secret");
419-
verify(shell, times(2)).connect(connectionConfig);
419+
verify(shell, times(2)).connect(connectionConfig, null);
420420
} finally {
421421
System.setIn(stdIn);
422422
System.setOut(stdOut);

0 commit comments

Comments
 (0)