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

Commit b039dd4

Browse files
committed
Merge remote-tracking branch 'origin/1.1' into 1.2
2 parents c7ea456 + f4c4954 commit b039dd4

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.neo4j.shell.commands;
22

3-
43
import org.junit.Before;
54
import org.junit.Rule;
65
import org.junit.Test;
76
import org.junit.rules.ExpectedException;
87

98
import org.neo4j.driver.exceptions.AuthenticationException;
10-
import org.neo4j.shell.ConnectionConfig;
119
import org.neo4j.shell.CypherShell;
1210
import org.neo4j.shell.StringLinePrinter;
1311
import org.neo4j.shell.cli.Format;
@@ -16,15 +14,14 @@
1614

1715
import static org.neo4j.driver.internal.messaging.request.MultiDatabaseUtil.ABSENT_DB_NAME;
1816

19-
public class CypherShellFailureIntegrationTest {
17+
public class CypherShellFailureIntegrationTest extends CypherShellIntegrationTest {
2018
@Rule
2119
public final ExpectedException thrown = ExpectedException.none();
2220

2321
private StringLinePrinter linePrinter = new StringLinePrinter();
24-
private CypherShell shell;
2522

2623
@Before
27-
public void setUp() throws Exception {
24+
public void setUp() {
2825
linePrinter.clear();
2926
shell = new CypherShell(linePrinter, new PrettyConfig(Format.VERBOSE, true, 1000), false);
3027
}
@@ -34,6 +31,6 @@ public void cypherWithNoPasswordShouldReturnValidError() throws CommandException
3431
thrown.expect(AuthenticationException.class);
3532
thrown.expectMessage("The client is unauthorized due to authentication failure.");
3633

37-
shell.connect(new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "", false, ABSENT_DB_NAME));
34+
connect("");
3835
}
3936
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.neo4j.shell.commands;
2+
3+
import org.neo4j.driver.exceptions.ServiceUnavailableException;
4+
import org.neo4j.shell.ConnectionConfig;
5+
import org.neo4j.shell.CypherShell;
6+
import org.neo4j.shell.exception.CommandException;
7+
8+
import static org.neo4j.driver.internal.messaging.request.MultiDatabaseUtil.ABSENT_DB_NAME;
9+
10+
abstract class CypherShellIntegrationTest
11+
{
12+
CypherShell shell;
13+
14+
void connect(String password) throws CommandException {
15+
// Try with encryption off first, which is the default for 4.X
16+
try
17+
{
18+
shell.connect( new ConnectionConfig( "bolt://", "localhost", 7687, "neo4j", password, false, ABSENT_DB_NAME ) );
19+
}
20+
catch ( ServiceUnavailableException e )
21+
{
22+
// This means we are probably in 3.X, let's retry with encryption on
23+
shell.connect( new ConnectionConfig( "bolt://", "localhost", 7687, "neo4j", password, true, ABSENT_DB_NAME ) );
24+
}
25+
}
26+
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
import static org.neo4j.driver.internal.messaging.request.MultiDatabaseUtil.ABSENT_DB_NAME;
1919
import static org.neo4j.shell.prettyprint.OutputFormatter.NEWLINE;
2020

21-
public class CypherShellPlainIntegrationTest {
21+
public class CypherShellPlainIntegrationTest extends CypherShellIntegrationTest {
2222
@Rule
2323
public final ExpectedException thrown = ExpectedException.none();
2424

2525
private StringLinePrinter linePrinter = new StringLinePrinter();
26-
private CypherShell shell;
2726

2827
@Before
2928
public void setUp() throws Exception {
3029
linePrinter.clear();
3130
shell = new CypherShell(linePrinter, new PrettyConfig(Format.PLAIN, true, 1000), false);
32-
shell.connect(new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "neo", false, ABSENT_DB_NAME));
31+
connect( "neo" );
3332
}
3433

3534
@After

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
import static org.neo4j.shell.Versions.majorVersion;
2222
import static org.neo4j.shell.Versions.minorVersion;
2323

24-
public class CypherShellVerboseIntegrationTest {
24+
public class CypherShellVerboseIntegrationTest extends CypherShellIntegrationTest {
2525
@Rule
2626
public final ExpectedException thrown = ExpectedException.none();
2727

2828
private StringLinePrinter linePrinter = new StringLinePrinter();
2929
private Command rollbackCommand;
3030
private Command commitCommand;
3131
private Command beginCommand;
32-
private CypherShell shell;
3332

3433
@Before
3534
public void setUp() throws Exception {
@@ -39,7 +38,7 @@ public void setUp() throws Exception {
3938
commitCommand = new Commit(shell);
4039
beginCommand = new Begin(shell);
4140

42-
shell.connect(new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "neo", false, ABSENT_DB_NAME));
41+
connect( "neo" );
4342
}
4443

4544
@After
@@ -73,9 +72,8 @@ public void connectTwiceThrows() throws CommandException {
7372
thrown.expect(CommandException.class);
7473
thrown.expectMessage("Already connected");
7574

76-
ConnectionConfig config = new ConnectionConfig("bolt://", "localhost", 7687, "neo4j", "neo", false, ABSENT_DB_NAME);
7775
assertTrue("Shell should already be connected", shell.isConnected());
78-
shell.connect(config);
76+
connect( "neo" );
7977
}
8078

8179
@Test
@@ -194,6 +192,7 @@ public void cypherWithOrder() throws CommandException {
194192
assumeTrue(minorVersion(serverVersion) == 6 || majorVersion(serverVersion) == 4);
195193

196194
shell.execute( "CREATE INDEX ON :Person(age)" );
195+
shell.execute( "CALL db.awaitIndexes()" );
197196

198197
//when
199198
shell.execute("CYPHER RUNTIME=INTERPRETED EXPLAIN MATCH (n:Person) WHERE n.age >= 18 RETURN n.name, n.age");

tyrekicking.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ function prepare-bundle {
1111
}
1212

1313
function testscript {
14-
if cypher-shell/cypher-shell -u neo4j -p neo "RETURN 1;"; then
14+
# first try with encryption off (4.X series), if that fails with encryption on (3.X series)
15+
if cypher-shell/cypher-shell -u neo4j -p neo --encryption false "RETURN 1;"; then
16+
echo "$1 Success!"
17+
elif cypher-shell/cypher-shell -u neo4j -p neo --encryption true "RETURN 1;"; then
1518
echo "$1 Success!"
1619
else
1720
echo "$1 Failure!"

0 commit comments

Comments
 (0)