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

Commit 91cb686

Browse files
committed
Change use of deprecated API
1 parent d63f59b commit 91cb686

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class ConnectionConfig {
88
private final String scheme;
99
private final String host;
1010
private final int port;
11-
private final Config.EncryptionLevel encryption;
11+
private final boolean encryption;
1212
private String username;
1313
private String password;
1414
private String database;
@@ -20,7 +20,7 @@ public ConnectionConfig(@Nonnull String scheme, @Nonnull String host, int port,
2020
this.port = port;
2121
this.username = fallbackToEnvVariable(username, "NEO4J_USERNAME");
2222
this.password = fallbackToEnvVariable(password, "NEO4J_PASSWORD");
23-
this.encryption = encryption ? Config.EncryptionLevel.REQUIRED : Config.EncryptionLevel.NONE;
23+
this.encryption = encryption;
2424
this.scheme = scheme;
2525
this.database = database;
2626
}
@@ -67,7 +67,7 @@ public String driverUrl() {
6767
}
6868

6969
@Nonnull
70-
public Config.EncryptionLevel encryption() {
70+
public boolean encryption() {
7171
return encryption;
7272
}
7373

cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,13 @@ private void clearTransactionStatements() {
250250
}
251251

252252
private Driver getDriver(@Nonnull ConnectionConfig connectionConfig, @Nullable AuthToken authToken) {
253-
Config config = Config.build()
254-
.withLogging(NullLogging.NULL_LOGGING)
255-
.withEncryptionLevel(connectionConfig.encryption()).toConfig();
256-
return driverProvider.apply(connectionConfig.driverUrl(), authToken, config);
253+
Config.ConfigBuilder configBuilder = Config.build().withLogging(NullLogging.NULL_LOGGING);
254+
if (connectionConfig.encryption()) {
255+
configBuilder = configBuilder.withEncryption();
256+
} else {
257+
configBuilder = configBuilder.withoutEncryption();
258+
}
259+
return driverProvider.apply(connectionConfig.driverUrl(), authToken, configBuilder.toConfig());
257260
}
258261

259262
private Optional<List<BoltResult>> captureResults(@Nonnull List<Statement> transactionStatements) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public void driverUrlDefaultScheme() throws Exception {
4545

4646
@Test
4747
public void encryption() {
48-
assertEquals(Config.EncryptionLevel.REQUIRED,
48+
assertEquals(true,
4949
new ConnectionConfig("bolt://", "", -1, "", "", true, ABSENT_DB_NAME).encryption());
50-
assertEquals(Config.EncryptionLevel.NONE,
50+
assertEquals(false,
5151
new ConnectionConfig("bolt://", "", -1, "", "", false, ABSENT_DB_NAME).encryption());
5252
}
5353
}

0 commit comments

Comments
 (0)