Skip to content

Commit d14308e

Browse files
author
Zhen Li
authored
Merge pull request #251 from zhenlineo/1.1-enable-boltIt
Enable test that requires boltkit
2 parents c0bf2b3 + 236d3e7 commit d14308e

File tree

10 files changed

+142
-97
lines changed

10 files changed

+142
-97
lines changed

driver/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@
154154
</archive>
155155
</configuration>
156156
</plugin>
157+
<plugin>
158+
<groupId>org.apache.maven.plugins</groupId>
159+
<artifactId>maven-surefire-plugin</artifactId>
160+
<version>2.19</version>
161+
<configuration>
162+
<excludes>
163+
<exclude>**/*BoltKitTest.java</exclude>
164+
</excludes>
165+
</configuration>
166+
</plugin>
157167
<plugin>
158168
<groupId>org.apache.maven.plugins</groupId>
159169
<artifactId>maven-failsafe-plugin</artifactId>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright (c) 2002-2016 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
package org.neo4j.driver.internal;
21+
22+
import java.io.IOException;
23+
import java.net.URI;
24+
25+
import org.junit.Test;
26+
import org.neo4j.driver.v1.Driver;
27+
import org.neo4j.driver.v1.GraphDatabase;
28+
import org.neo4j.driver.v1.Record;
29+
import org.neo4j.driver.v1.Session;
30+
import org.neo4j.driver.v1.util.StubServer;
31+
32+
import static org.hamcrest.core.IsEqual.equalTo;
33+
import static org.junit.Assert.assertThat;
34+
import static org.neo4j.driver.v1.Values.parameters;
35+
36+
public class DirectDriverBoltKitTest
37+
{
38+
@Test
39+
public void shouldBeAbleRunCypher() throws StubServer.ForceKilled, InterruptedException, IOException
40+
{
41+
// Given
42+
StubServer server = StubServer.start( "return_x.script", 9001 );
43+
URI uri = URI.create( "bolt://127.0.0.1:9001" );
44+
int x;
45+
46+
// When
47+
try ( Driver driver = GraphDatabase.driver( uri ) )
48+
{
49+
try ( Session session = driver.session() )
50+
{
51+
Record record = session.run( "RETURN {x}", parameters( "x", 1 ) ).single();
52+
x = record.get( 0 ).asInt();
53+
}
54+
}
55+
56+
// Then
57+
assertThat( x, equalTo( 1 ) );
58+
59+
// Finally
60+
assertThat( server.exitStatus(), equalTo( 0 ) );
61+
}
62+
}

driver/src/test/java/org/neo4j/driver/internal/DirectDriverTest.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,15 @@
1919

2020
package org.neo4j.driver.internal;
2121

22-
import org.junit.Ignore;
2322
import org.junit.Test;
2423

25-
import java.io.IOException;
2624
import java.net.URI;
2725

2826
import org.neo4j.driver.internal.net.BoltServerAddress;
29-
import org.neo4j.driver.v1.Driver;
3027
import org.neo4j.driver.v1.GraphDatabase;
31-
import org.neo4j.driver.v1.Record;
32-
import org.neo4j.driver.v1.Session;
33-
import org.neo4j.driver.v1.util.StubServer;
3428

3529
import static org.hamcrest.core.IsEqual.equalTo;
3630
import static org.junit.Assert.assertThat;
37-
import static org.neo4j.driver.v1.Values.parameters;
3831

3932
public class DirectDriverTest
4033
{
@@ -67,30 +60,4 @@ public void shouldRegisterSingleServer()
6760
assertThat( driverAddress, equalTo( address ));
6861

6962
}
70-
71-
@Ignore
72-
public void shouldBeAbleRunCypher() throws StubServer.ForceKilled, InterruptedException, IOException
73-
{
74-
// Given
75-
StubServer server = StubServer.start( "return_x.script", 9001 );
76-
URI uri = URI.create( "bolt://127.0.0.1:9001" );
77-
int x;
78-
79-
// When
80-
try ( Driver driver = GraphDatabase.driver( uri ) )
81-
{
82-
try ( Session session = driver.session() )
83-
{
84-
Record record = session.run( "RETURN {x}", parameters( "x", 1 ) ).single();
85-
x = record.get( 0 ).asInt();
86-
}
87-
}
88-
89-
// Then
90-
assertThat( x, equalTo( 1 ) );
91-
92-
// Finally
93-
assertThat( server.exitStatus(), equalTo( 0 ) );
94-
}
95-
96-
}
63+
}

driver/src/test/java/org/neo4j/driver/internal/RoutingDriverStubTest.java renamed to driver/src/test/java/org/neo4j/driver/internal/RoutingDriverBoltKitTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21-
import gherkin.lexer.Tr;
22-
import org.junit.Ignore;
2321
import org.junit.Rule;
2422
import org.junit.Test;
2523
import org.junit.rules.ExpectedException;
@@ -45,7 +43,6 @@
4543
import org.neo4j.driver.v1.Record;
4644
import org.neo4j.driver.v1.Session;
4745
import org.neo4j.driver.v1.Transaction;
48-
import org.neo4j.driver.v1.exceptions.ConnectionFailureException;
4946
import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
5047
import org.neo4j.driver.v1.exceptions.SessionExpiredException;
5148
import org.neo4j.driver.v1.util.Function;
@@ -63,8 +60,7 @@
6360
import static org.junit.Assert.assertTrue;
6461
import static org.junit.Assert.fail;
6562

66-
@Ignore
67-
public class RoutingDriverStubTest
63+
public class RoutingDriverBoltKitTest
6864
{
6965
@Rule
7066
public ExpectedException exception = ExpectedException.none();

driver/src/test/java/org/neo4j/driver/internal/net/pooling/SocketConnectionPoolTest.java

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright (c) 2002-2016 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
package org.neo4j.driver.v1;
21+
22+
import java.io.IOException;
23+
import java.net.URI;
24+
25+
import org.junit.Test;
26+
import org.neo4j.driver.internal.RoutingDriver;
27+
import org.neo4j.driver.v1.util.StubServer;
28+
29+
import static org.hamcrest.core.IsEqual.equalTo;
30+
import static org.hamcrest.core.IsInstanceOf.instanceOf;
31+
import static org.junit.Assert.assertThat;
32+
33+
public class GraphDatabaseBoltKitTest
34+
{
35+
@Test
36+
public void boltPlusDiscoverySchemeShouldInstantiateClusterDriver() throws IOException, InterruptedException, StubServer.ForceKilled
37+
{
38+
// Given
39+
StubServer server = StubServer.start( "discover_servers.script", 9001 );
40+
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
41+
42+
// When
43+
Driver driver = GraphDatabase.driver( uri );
44+
45+
// Then
46+
assertThat( driver, instanceOf( RoutingDriver.class ) );
47+
48+
// Finally
49+
driver.close();
50+
assertThat( server.exitStatus(), equalTo( 0 ) );
51+
}
52+
}

driver/src/test/java/org/neo4j/driver/v1/GraphDatabaseTest.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@
1919

2020
package org.neo4j.driver.v1;
2121

22-
import org.junit.Ignore;
2322
import org.junit.Test;
2423

25-
import java.io.IOException;
2624
import java.net.URI;
2725

2826
import org.neo4j.driver.internal.DirectDriver;
29-
import org.neo4j.driver.internal.RoutingDriver;
30-
import org.neo4j.driver.v1.util.StubServer;
3127

32-
import static org.hamcrest.core.IsEqual.equalTo;
3328
import static org.hamcrest.core.IsInstanceOf.instanceOf;
3429
import static org.junit.Assert.assertThat;
3530

@@ -48,23 +43,4 @@ public void boltSchemeShouldInstantiateDirectDriver()
4843
assertThat( driver, instanceOf( DirectDriver.class ) );
4944

5045
}
51-
52-
@Ignore
53-
public void boltPlusDiscoverySchemeShouldInstantiateClusterDriver() throws IOException, InterruptedException, StubServer.ForceKilled
54-
{
55-
// Given
56-
StubServer server = StubServer.start( "discover_servers.script", 9001 );
57-
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
58-
59-
// When
60-
Driver driver = GraphDatabase.driver( uri );
61-
62-
// Then
63-
assertThat( driver, instanceOf( RoutingDriver.class ) );
64-
65-
// Finally
66-
driver.close();
67-
assertThat( server.exitStatus(), equalTo( 0 ) );
68-
}
69-
70-
}
46+
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
package org.neo4j.driver.v1.util;
2121

2222
import java.io.IOException;
23+
import java.net.URISyntaxException;
2324
import java.net.URL;
25+
import java.nio.file.Paths;
2426
import java.util.ArrayList;
2527
import java.util.List;
2628

@@ -39,7 +41,7 @@ public static class ForceKilled extends Exception {}
3941
private StubServer( String script, int port ) throws IOException, InterruptedException
4042
{
4143
List<String> command = new ArrayList<>();
42-
command.addAll( singletonList( "/usr/local/bin/boltstub" ) );
44+
command.addAll( singletonList( "boltstub" ) );
4345
command.addAll( asList( Integer.toString( port ), script ) );
4446
ProcessBuilder server = new ProcessBuilder().inheritIO().command( command );
4547
process = server.start();
@@ -74,6 +76,14 @@ private static String resource( String fileName )
7476
{
7577
fail( fileName + " does not exists" );
7678
}
77-
return resource.getFile();
79+
try
80+
{
81+
return Paths.get( resource.toURI() ).toFile().getCanonicalPath();
82+
}
83+
catch ( Throwable e )
84+
{
85+
fail( e.toString() );
86+
throw new RuntimeException( e );
87+
}
7888
}
7989
}

driver/src/test/resources/acquire_endpoints.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ C: RUN "CALL dbms.cluster.routing.getServers" {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]
10-
SUCCESS {}
10+
SUCCESS {}

driver/src/test/resources/write_server.script

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
!: AUTO PULL_ALL
55
!: AUTO RUN "ROLLBACK" {}
66
!: AUTO RUN "BEGIN" {}
7+
!: AUTO RUN "COMMIT" {}
78

89
C: RUN "CREATE (n {name:'Bob'})" {}
910
PULL_ALL
1011
S: SUCCESS {}
11-
SUCCESS {}
12+
SUCCESS {}

0 commit comments

Comments
 (0)