Skip to content

Commit 60972ec

Browse files
author
Zhen
committed
Merge branch '1.2' into 1.3
2 parents 5b684aa + b0efb4b commit 60972ec

File tree

9 files changed

+55
-49
lines changed

9 files changed

+55
-49
lines changed

README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
This is the first official Neo4j java driver for connecting to Neo4j-the-database via the newly designed remoting
44
protocol BOLT.
55

6+
For detailed information such as manual, driver API documentations, changelogs, please refer to
7+
[wiki](https://github.com/neo4j/neo4j-java-driver/wiki).
8+
69
## Minimum viable snippet
710

811
Add the driver to your project:
@@ -30,8 +33,6 @@ Connect to a Neo4j 3.0.0+ database:
3033

3134
driver.close();
3235

33-
For more examples and details of usage, please refer to the [Driver Manual] (http://neo4j.com/docs/developer-manual/3.0/index.html#driver-manual-index).
34-
3536
## Binding
3637

3738
The source code here reflects the current development status of a new driver version.
@@ -40,10 +41,8 @@ code with git tags instead.
4041

4142
### Java version
4243

43-
To compile the code and run all tests, you first need to prepare the `neokit` submodule which is used for integration tests:
44-
45-
git submodule init
46-
git submodule update
44+
The driver unit tests relies on latest [`boltkit`](https://github.com/neo4j-contrib/boltkit) installed on your local machine.
45+
If `boltkit` is not installed, then all tests that requires `boltkit` will be ignored and not be executed.
4746

4847
Then if you are running Java 8:
4948

@@ -60,13 +59,5 @@ Java 8, because Neo4j-the-database needs it to run.
6059

6160
### Windows
6261

63-
If you are building on windows, you need to have Python (v2.7) installed and have Python.exe to be added in your system `PATH` variables.
64-
Then run install as admin, so that Neo4j-the-database could be installed and started with Python scripts for integration tests.
65-
66-
Or you could choose to ignore integration tests by running:
67-
68-
mvn clean install -DskipITs
69-
70-
Without integration tests, there is no need to install Python or run as admin.
71-
72-
For more information such as manual, driver API documentations, changelogs, please refer to [wiki](https://github.com/neo4j/neo4j-java-driver/wiki).
62+
If you are building on windows, you need to run install as admin, so that Neo4j-the-database could be installed and
63+
started for integration tests.

driver/src/test/java/org/neo4j/driver/v1/integration/BookmarkIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public void assumeBookmarkSupport()
6262
session = sessionRule;
6363

6464
ServerVersion serverVersion = ServerVersion.version( driver );
65-
assumeTrue( serverVersion.greaterThanOrEqual( v3_1_0 ) );
65+
assumeTrue( "Server version `" + serverVersion + "` does not support bookmark",
66+
serverVersion.greaterThanOrEqual( v3_1_0 ) );
6667
}
6768

6869
@Test

driver/src/test/java/org/neo4j/driver/v1/util/Neo4jRunner.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
import org.neo4j.driver.v1.GraphDatabase;
3333

3434
import static java.util.Arrays.asList;
35+
import static org.junit.Assume.assumeTrue;
3536
import static org.neo4j.driver.v1.ConfigTest.deleteDefaultKnownCertFileIfExists;
3637
import static org.neo4j.driver.v1.util.FileTools.updateProperties;
38+
import static org.neo4j.driver.v1.util.cc.CommandLineUtil.boltKitAvailable;
3739
import static org.neo4j.driver.v1.util.cc.CommandLineUtil.executeCommand;
3840

3941
/**
@@ -44,21 +46,23 @@ public class Neo4jRunner
4446
{
4547
private static Neo4jRunner globalInstance;
4648

47-
private static final boolean debug = Boolean.getBoolean( "neo4j.runner.debug" );
49+
private static final boolean debug = true;
4850

4951
private static final String DEFAULT_NEOCTRL_ARGS = "-e 3.1.2";
5052
public static final String NEOCTRL_ARGS = System.getProperty( "neoctrl.args", DEFAULT_NEOCTRL_ARGS );
5153
public static final URI DEFAULT_URI = URI.create( "bolt://localhost:7687" );
5254
public static final BoltServerAddress DEFAULT_ADDRESS = BoltServerAddress.from( DEFAULT_URI );
5355
private Driver driver;
54-
private Neo4jSettings currentSettings = Neo4jSettings.DEFAULT_SETTINGS;
56+
private Neo4jSettings currentSettings = Neo4jSettings.TEST_SETTINGS;
5557

56-
private static final String NEO4J_DIR = new File( "../target/neo4j" ).getAbsolutePath();
58+
public static final String TARGET_DIR = new File( "../target" ).getAbsolutePath();
59+
private static final String NEO4J_DIR = new File( TARGET_DIR, "neo4j" ).getAbsolutePath();
5760
public static String NEO4J_HOME;
5861

5962
/** Global runner controlling a single server, used to avoid having to restart the server between tests */
6063
public static synchronized Neo4jRunner getOrCreateGlobalRunner() throws IOException
6164
{
65+
assumeTrue( "BoltKit support unavailable", boltKitAvailable() );
6266
if ( globalInstance == null )
6367
{
6468
globalInstance = new Neo4jRunner();
@@ -70,6 +74,7 @@ private Neo4jRunner() throws IOException
7074
{
7175
try
7276
{
77+
installNeo4j();
7378
startNeo4j();
7479
}
7580
finally
@@ -115,30 +120,34 @@ private void installNeo4j() throws IOException
115120
commands.add( NEO4J_DIR );
116121

117122
NEO4J_HOME = executeCommand( commands ).trim();
123+
updateServerSettingsFile();
118124

125+
debug( "Installed server at `%s`.", NEO4J_HOME );
119126
}
120127

121128
private void startNeo4j() throws IOException
122129
{
123-
installNeo4j();
124-
updateServerSettingsFile();
130+
debug( "Starting server..." );
125131
executeCommand( "neoctrl-create-user", NEO4J_HOME, "neo4j", "neo4j" );
126132
executeCommand( "neoctrl-start", NEO4J_HOME );
133+
debug( "Server started." );
127134
}
128135

129136
public synchronized void stopNeo4j() throws IOException
130137
{
131-
if(serverStatus() == ServerStatus.OFFLINE)
138+
if( serverStatus() == ServerStatus.OFFLINE )
132139
{
133140
return;
134141
}
135-
if(driver != null)
142+
if( driver != null )
136143
{
137144
driver.close();
138145
driver = null;
139146
}
140147

148+
debug( "Stopping server..." );
141149
executeCommand( "neoctrl-stop", NEO4J_HOME );
150+
debug( "Server stopped." );
142151
}
143152

144153
public void forceToRestart() throws IOException
@@ -220,7 +229,7 @@ private void updateServerSettingsFile()
220229
File oldFile = new File( NEO4J_HOME, "conf/neo4j.conf" );
221230
try
222231
{
223-
debug( "Changing server properties file (for next start): " + oldFile.getCanonicalPath() );
232+
debug( "Changing server properties file (for next start): %s", oldFile.getCanonicalPath() );
224233
for ( Map.Entry<String, String> property : propertiesMap.entrySet() )
225234
{
226235
String name = property.getKey();
@@ -261,7 +270,7 @@ static void debug( String text, Object... args )
261270
{
262271
if ( debug )
263272
{
264-
System.err.println( "Neo4jRunner: " + String.format( text, args ) );
273+
System.out.println( String.format( text, args ) );
265274
}
266275
}
267276
}

driver/src/test/java/org/neo4j/driver/v1/util/Neo4jSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class Neo4jSettings
4444
private final Map<String, String> settings;
4545
private final Set<String> excludes;
4646

47-
public static Neo4jSettings DEFAULT_SETTINGS = new Neo4jSettings( new HashMap<String, String>(), Collections.<String>emptySet() );
4847
public static Neo4jSettings TEST_SETTINGS = new Neo4jSettings( map(
4948
CERT_DIR, DEFAULT_CERT_DIR,
5049
DATA_DIR, DEFAULT_DATA_DIR,

driver/src/test/java/org/neo4j/driver/v1/util/ServerVersion.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class ServerVersion
3333
private final int patch;
3434

3535
private static final Pattern PATTERN =
36-
Pattern.compile("Neo4j/(\\d+)\\.(\\d+)(?:\\.)?(\\d*)(\\.|-|\\+)?([0-9A-Za-z-.]*)?");
36+
Pattern.compile("(Neo4j/)?(\\d+)\\.(\\d+)(?:\\.)?(\\d*)(\\.|-|\\+)?([0-9A-Za-z-.]*)?");
3737

3838
private ServerVersion( int major, int minor, int patch )
3939
{
@@ -64,9 +64,9 @@ public static ServerVersion version( String server )
6464
Matcher matcher = PATTERN.matcher( server );
6565
if ( matcher.matches() )
6666
{
67-
int major = Integer.valueOf( matcher.group( 1 ) );
68-
int minor = Integer.valueOf( matcher.group( 2 ) );
69-
String patchString = matcher.group( 3 );
67+
int major = Integer.valueOf( matcher.group( 2 ) );
68+
int minor = Integer.valueOf( matcher.group( 3 ) );
69+
String patchString = matcher.group( 4 );
7070
int patch = 0;
7171
if ( patchString != null && !patchString.isEmpty() )
7272
{
@@ -141,4 +141,10 @@ private int compareTo( ServerVersion o )
141141

142142
return c;
143143
}
144+
145+
@Override
146+
public String toString()
147+
{
148+
return String.format( "%s.%s.%s", major, minor, patch );
149+
}
144150
}

driver/src/test/java/org/neo4j/driver/v1/util/TestNeo4j.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ public BoltServerAddress address()
114114

115115
static void clearDatabaseContents( Session session, String reason )
116116
{
117-
debug( "Clearing database contents for: %s", reason );
118-
119117
// Note - this hangs for extended periods some times, because there are tests that leave sessions running.
120118
// Thus, we need to wait for open sessions and transactions to time out before this will go through.
121119
// This could be helped by an extension in the future.

driver/src/test/java/org/neo4j/driver/v1/util/cc/ClusterControl.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ private ClusterControl()
2727
{
2828
}
2929

30-
static boolean boltKitClusterAvailable()
31-
{
32-
try
33-
{
34-
executeCommand( "neoctrl-cluster", "--help" );
35-
return true;
36-
}
37-
catch ( CommandLineException e )
38-
{
39-
return false;
40-
}
41-
}
42-
4330
static void installCluster( String neo4jVersion, int cores, int readReplicas, String password, int port,
4431
Path path )
4532
{

driver/src/test/java/org/neo4j/driver/v1/util/cc/ClusterRule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
import org.neo4j.driver.v1.util.ServerVersion;
3535

3636
import static org.junit.Assume.assumeTrue;
37+
import static org.neo4j.driver.v1.util.Neo4jRunner.TARGET_DIR;
38+
import static org.neo4j.driver.v1.util.cc.CommandLineUtil.boltKitAvailable;
3739

3840
public class ClusterRule extends ExternalResource
3941
{
40-
private static final Path CLUSTER_DIR = Paths.get( "target", "test-cluster" ).toAbsolutePath();
42+
private static final Path CLUSTER_DIR = Paths.get( TARGET_DIR, "test-cluster" ).toAbsolutePath();
4143
private static final String PASSWORD = "test";
4244
private static final int INITIAL_PORT = 20_000;
4345

@@ -58,7 +60,7 @@ public AuthToken getDefaultAuthToken()
5860
@Override
5961
protected void before() throws Throwable
6062
{
61-
assumeTrue( "BoltKit cluster support unavailable", ClusterControl.boltKitClusterAvailable() );
63+
assumeTrue( "BoltKit cluster support unavailable", boltKitAvailable() );
6264

6365
if ( !SharedCluster.exists() )
6466
{
@@ -107,7 +109,8 @@ private static String parseNeo4jVersion()
107109
String[] split = Neo4jRunner.NEOCTRL_ARGS.split( "\\s+" );
108110
String version = split[split.length - 1];
109111
// if the server version is older than 3.1 series, then ignore the tests
110-
assumeTrue( ServerVersion.version( "Neo4j/" + version ).greaterThanOrEqual( ServerVersion.v3_1_0 ) );
112+
assumeTrue( "Server version `" + version + "` does not support Casual Cluster",
113+
ServerVersion.version( version ).greaterThanOrEqual( ServerVersion.v3_1_0 ) );
111114
return version;
112115
}
113116

driver/src/test/java/org/neo4j/driver/v1/util/cc/CommandLineUtil.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131

3232
public class CommandLineUtil
3333
{
34+
public static boolean boltKitAvailable()
35+
{
36+
try
37+
{
38+
executeCommand( "neoctrl-cluster", "--help" );
39+
return true;
40+
}
41+
catch ( CommandLineException e )
42+
{
43+
return false;
44+
}
45+
}
3446

3547
public static String executeCommand( List<String> commands )
3648
{

0 commit comments

Comments
 (0)