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

Commit d995fa7

Browse files
authored
Merge pull request #88 from spacecowboy/boltrouting
Support bolt+routing
2 parents 8766fdf + ed02f75 commit d995fa7

File tree

9 files changed

+14
-36
lines changed

9 files changed

+14
-36
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public void connectInteractivelyPromptsOnWrongAuthentication() throws Exception
3535
logger.setFormat(cliArgs.getFormat());
3636

3737
ConnectionConfig connectionConfig = new ConnectionConfig(
38-
logger,
3938
cliArgs.getScheme(),
4039
cliArgs.getHost(),
4140
cliArgs.getPort(),

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellFailureIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public void cypherWithNoPasswordShouldReturnValidError() throws CommandException
3535
thrown.expect( AuthenticationException.class );
3636
thrown.expectMessage("The client is unauthorized due to authentication failure.");
3737

38-
shell.connect(new ConnectionConfig(logger, "bolt://", "localhost", 7687, "neo4j", "", true));
38+
shell.connect(new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "", true));
3939
}
4040
}

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setUp() throws Exception {
4545
commitCommand = new Commit(shell);
4646
beginCommand = new Begin(shell);
4747

48-
shell.connect(new ConnectionConfig(logger, "bolt://", "localhost", 7687, "neo4j", "neo", true));
48+
shell.connect(new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "neo", true));
4949
}
5050

5151
@After
@@ -126,7 +126,7 @@ public void connectTwiceThrows() throws CommandException {
126126
thrown.expect(CommandException.class);
127127
thrown.expectMessage("Already connected");
128128

129-
ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "localhost", 7687, "neo4j", "neo", true);
129+
ConnectionConfig config = new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "neo", true);
130130
assertTrue("Shell should already be connected", shell.isConnected());
131131
shell.connect(config);
132132
}

cypher-shell/src/main/java/org/neo4j/shell/ConnectionConfig.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.neo4j.shell;
22

33
import org.neo4j.driver.v1.Config;
4-
import org.neo4j.shell.log.AnsiFormattedText;
5-
import org.neo4j.shell.log.Logger;
64

75
import javax.annotation.Nonnull;
86

@@ -14,22 +12,13 @@ public class ConnectionConfig {
1412
private String username;
1513
private String password;
1614

17-
public ConnectionConfig(@Nonnull Logger logger, @Nonnull String scheme, @Nonnull String host, int port,
15+
public ConnectionConfig(@Nonnull String scheme, @Nonnull String host, int port,
1816
@Nonnull String username, @Nonnull String password, boolean encryption) {
1917
this.host = host;
2018
this.port = port;
2119
this.username = fallbackToEnvVariable(username, "NEO4J_USERNAME");
2220
this.password = fallbackToEnvVariable(password, "NEO4J_PASSWORD");
2321
this.encryption = encryption ? Config.EncryptionLevel.REQUIRED : Config.EncryptionLevel.NONE;
24-
25-
if ("bolt+routing://".equalsIgnoreCase(scheme)) {
26-
logger.printError(
27-
AnsiFormattedText.s()
28-
.colorRed()
29-
.append("Routing is not supported by cypher-shell. Falling back to direct connection.")
30-
.formattedString());
31-
scheme = "bolt://";
32-
}
3322
this.scheme = scheme;
3423
}
3524

cypher-shell/src/main/java/org/neo4j/shell/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void startShell(@Nonnull CliArgs cliArgs) {
5757
logger.setFormat(cliArgs.getFormat());
5858

5959
ConnectionConfig connectionConfig = new ConnectionConfig(
60-
logger,
6160
cliArgs.getScheme(),
6261
cliArgs.getHost(),
6362
cliArgs.getPort(),

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
import static org.junit.Assert.assertEquals;
88
import static org.mockito.Mockito.mock;
9-
import static org.mockito.Mockito.verify;
109

1110
public class ConnectionConfigTest {
1211
private Logger logger = mock(Logger.class);
13-
private ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "localhost", 1, "bob",
12+
private ConnectionConfig config = new ConnectionConfig("bolt://", "localhost", 1, "bob",
1413
"pass", false);
1514

1615
@Test
@@ -43,19 +42,11 @@ public void driverUrlDefaultScheme() throws Exception {
4342
assertEquals("bolt://localhost:1", config.driverUrl());
4443
}
4544

46-
@Test
47-
public void driverUrlRoutingScheme() throws Exception {
48-
ConnectionConfig config = new ConnectionConfig(logger, "bolt+routing://", "localhost", 1, "bob",
49-
"pass", false);
50-
verify(logger).printError("@|RED Routing is not supported by cypher-shell. Falling back to direct connection.|@");
51-
assertEquals("bolt://localhost:1", config.driverUrl());
52-
}
53-
5445
@Test
5546
public void encryption() {
5647
assertEquals(Config.EncryptionLevel.REQUIRED,
57-
new ConnectionConfig(logger, "bolt://", "", -1, "", "", true).encryption());
48+
new ConnectionConfig("bolt://", "", -1, "", "", true).encryption());
5849
assertEquals(Config.EncryptionLevel.NONE,
59-
new ConnectionConfig(logger, "bolt://", "", -1, "", "", false).encryption());
50+
new ConnectionConfig("bolt://", "", -1, "", "", false).encryption());
6051
}
6152
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.neo4j.shell.test.OfflineTestShell;
2222

2323
import java.io.IOException;
24-
import java.util.Arrays;
2524
import java.util.Optional;
2625

2726
import static java.util.Arrays.asList;
@@ -59,7 +58,7 @@ public void setup() {
5958

6059
@Test
6160
public void verifyDelegationOfConnectionMethods() throws CommandException {
62-
ConnectionConfig cc = new ConnectionConfig(logger, "bolt://", "", 1, "", "", false);
61+
ConnectionConfig cc = new ConnectionConfig("bolt://", "", 1, "", "", false);
6362
CypherShell shell = new CypherShell(logger, mockedBoltStateHandler, mockedPrettyPrinter);
6463

6564
shell.connect(cc);

cypher-shell/src/test/java/org/neo4j/shell/prettyprint/TableOutputFormatTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ private StatementResult mockResult(List<String> cols, Object... data) {
276276
}
277277
when(result.list()).thenReturn(records);
278278
when(result.consume()).thenReturn(summary);
279+
when(result.summary()).thenReturn(summary);
279280
return result;
280281
}
281282

cypher-shell/src/test/java/org/neo4j/shell/state/BoltStateHandlerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Session session() {
7676
}
7777
};
7878
BoltStateHandler handler = new BoltStateHandler(provider);
79-
ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "", -1, "", "", false);
79+
ConnectionConfig config = new ConnectionConfig("bolt://", "", -1, "", "", false);
8080
handler.connect(config);
8181

8282
assertEquals("", handler.getServerVersion());
@@ -87,7 +87,7 @@ public void versionIsNotEmptyAfterConnect() throws CommandException {
8787
Driver driverMock = stubVersionInAnOpenSession(mock(StatementResult.class), mock(Session.class), "Neo4j/9.4.1-ALPHA");
8888

8989
BoltStateHandler handler = new BoltStateHandler((s, authToken, config) -> driverMock);
90-
ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "", -1, "", "", false);
90+
ConnectionConfig config = new ConnectionConfig("bolt://", "", -1, "", "", false);
9191
handler.connect(config);
9292

9393
assertEquals("9.4.1-ALPHA", handler.getServerVersion());
@@ -336,7 +336,7 @@ public void silentDisconnectCleansUp() throws Exception {
336336
public void turnOffEncryptionIfRequested() throws CommandException {
337337
RecordingDriverProvider provider = new RecordingDriverProvider();
338338
BoltStateHandler handler = new BoltStateHandler(provider);
339-
ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "", -1, "", "", false);
339+
ConnectionConfig config = new ConnectionConfig("bolt://", "", -1, "", "", false);
340340
handler.connect(config);
341341
assertEquals(Config.EncryptionLevel.NONE, provider.config.encryptionLevel());
342342
}
@@ -345,7 +345,7 @@ public void turnOffEncryptionIfRequested() throws CommandException {
345345
public void turnOnEncryptionIfRequested() throws CommandException {
346346
RecordingDriverProvider provider = new RecordingDriverProvider();
347347
BoltStateHandler handler = new BoltStateHandler(provider);
348-
ConnectionConfig config = new ConnectionConfig(logger, "bolt://", "", -1, "", "", true);
348+
ConnectionConfig config = new ConnectionConfig("bolt://", "", -1, "", "", true);
349349
handler.connect(config);
350350
assertEquals(Config.EncryptionLevel.REQUIRED, provider.config.encryptionLevel());
351351
}
@@ -376,7 +376,7 @@ public OfflineBoltStateHandler(Driver driver) {
376376
}
377377

378378
public void connect() throws CommandException {
379-
connect(new ConnectionConfig(mock(Logger.class), "bolt://", "", 1, "", "", false));
379+
connect(new ConnectionConfig("bolt://", "", 1, "", "", false));
380380
}
381381
}
382382

0 commit comments

Comments
 (0)