Skip to content

Commit 2e02bd3

Browse files
committed
Unignore all boltkit tests
Infrastructure has been updated to handle tests using boltkit so these tests should no longer ignored
1 parent 68ff674 commit 2e02bd3

File tree

5 files changed

+54
-63
lines changed

5 files changed

+54
-63
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.neo4j.driver.internal;
2121

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

2524
import java.io.IOException;
@@ -68,12 +67,12 @@ public void shouldRegisterSingleServer()
6867

6968
}
7069

71-
@Ignore
70+
@Test
7271
public void shouldBeAbleRunCypher() throws StubServer.ForceKilled, InterruptedException, IOException
7372
{
7473
// Given
75-
StubServer server = StubServer.start( "../driver/src/test/resources/return_x.script" );
76-
URI uri = URI.create( "bolt://localhost:7687" );
74+
StubServer server = StubServer.start( "return_x.script", 9001 );
75+
URI uri = URI.create( "bolt://127.0.0.1:9001" );
7776
int x;
7877

7978
// When

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

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import java.io.IOException;
2727
import java.net.URI;
28-
import java.net.URL;
2928
import java.util.Arrays;
3029
import java.util.List;
3130
import java.util.Set;
@@ -58,7 +57,6 @@
5857
import static org.junit.Assert.assertTrue;
5958
import static org.junit.Assert.fail;
6059

61-
@Ignore
6260
public class RoutingDriverStubTest
6361
{
6462
@Rule
@@ -70,7 +68,7 @@ public class RoutingDriverStubTest
7068
public void shouldDiscoverServers() throws IOException, InterruptedException, StubServer.ForceKilled
7169
{
7270
// Given
73-
StubServer server = StubServer.start( resource( "discover_servers.script" ), 9001 );
71+
StubServer server = StubServer.start( "discover_servers.script", 9001 );
7472
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
7573

7674
// When
@@ -89,7 +87,7 @@ public void shouldDiscoverServers() throws IOException, InterruptedException, St
8987
public void shouldDiscoverNewServers() throws IOException, InterruptedException, StubServer.ForceKilled
9088
{
9189
// Given
92-
StubServer server = StubServer.start( resource( "discover_new_servers.script" ), 9001 );
90+
StubServer server = StubServer.start( "discover_new_servers.script" , 9001 );
9391
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
9492
BoltServerAddress seed = address( 9001 );
9593

@@ -110,7 +108,7 @@ public void shouldDiscoverNewServers() throws IOException, InterruptedException,
110108
public void shouldHandleEmptyResponse() throws IOException, InterruptedException, StubServer.ForceKilled
111109
{
112110
// Given
113-
StubServer server = StubServer.start( resource( "handle_empty_response.script" ), 9001 );
111+
StubServer server = StubServer.start( "handle_empty_response.script" , 9001 );
114112
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
115113
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
116114
{
@@ -127,10 +125,10 @@ public void shouldHandleEmptyResponse() throws IOException, InterruptedException
127125
public void shouldHandleAcquireReadSession() throws IOException, InterruptedException, StubServer.ForceKilled
128126
{
129127
// Given
130-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
128+
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
131129

132130
//START a read server
133-
StubServer readServer = StubServer.start( resource( "read_server.script" ), 9005 );
131+
StubServer readServer = StubServer.start( "read_server.script" , 9005 );
134132
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
135133
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
136134
Session session = driver.session( AccessMode.READ ) )
@@ -156,11 +154,11 @@ public String apply( Record record )
156154
public void shouldRoundRobinReadServers() throws IOException, InterruptedException, StubServer.ForceKilled
157155
{
158156
// Given
159-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
157+
StubServer server = StubServer.start( "acquire_endpoints.script" , 9001 );
160158

161159
//START two read servers
162-
StubServer readServer1 = StubServer.start( resource( "read_server.script" ), 9005 );
163-
StubServer readServer2 = StubServer.start( resource( "read_server.script" ), 9006 );
160+
StubServer readServer1 = StubServer.start( "read_server.script", 9005 );
161+
StubServer readServer2 = StubServer.start( "read_server.script" , 9006 );
164162
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
165163
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
166164
{
@@ -195,10 +193,10 @@ public void shouldThrowSessionExpiredIfReadServerDisappears()
195193
exception.expectMessage( "Server at 127.0.0.1:9005 is no longer available" );
196194

197195
// Given
198-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
196+
StubServer server = StubServer.start( "acquire_endpoints.script" , 9001 );
199197

200198
//START a read server
201-
StubServer.start( resource( "dead_server.script" ), 9005 );
199+
StubServer.start( "dead_server.script" , 9005 );
202200
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
203201
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
204202
Session session = driver.session( AccessMode.READ ) )
@@ -218,10 +216,10 @@ public void shouldThrowSessionExpiredIfWriteServerDisappears()
218216
//exception.expectMessage( "Server at 127.0.0.1:9006 is no longer available" );
219217

220218
// Given
221-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
219+
StubServer server = StubServer.start( "acquire_endpoints.script" , 9001 );
222220

223221
//START a dead write servers
224-
StubServer.start( resource( "dead_server.script" ), 9007 );
222+
StubServer.start( "dead_server.script" , 9007 );
225223
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
226224
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
227225
Session session = driver.session( AccessMode.WRITE ) )
@@ -236,10 +234,10 @@ public void shouldThrowSessionExpiredIfWriteServerDisappears()
236234
public void shouldHandleAcquireWriteSession() throws IOException, InterruptedException, StubServer.ForceKilled
237235
{
238236
// Given
239-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
237+
StubServer server = StubServer.start( "acquire_endpoints.script" , 9001 );
240238

241239
//START a write server
242-
StubServer writeServer = StubServer.start( resource( "write_server.script" ), 9007 );
240+
StubServer writeServer = StubServer.start( "write_server.script" , 9007 );
243241
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
244242
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
245243
Session session = driver.session( AccessMode.WRITE ) )
@@ -255,11 +253,11 @@ public void shouldHandleAcquireWriteSession() throws IOException, InterruptedExc
255253
public void shouldRoundRobinWriteSessions() throws IOException, InterruptedException, StubServer.ForceKilled
256254
{
257255
// Given
258-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
256+
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
259257

260258
//START a write server
261-
StubServer writeServer1 = StubServer.start( resource( "write_server.script" ), 9007 );
262-
StubServer writeServer2 = StubServer.start( resource( "write_server.script" ), 9008 );
259+
StubServer writeServer1 = StubServer.start( "write_server.script", 9007 );
260+
StubServer writeServer2 = StubServer.start( "write_server.script", 9008 );
263261
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
264262
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
265263
{
@@ -281,10 +279,10 @@ public void shouldRoundRobinWriteSessions() throws IOException, InterruptedExcep
281279
public void shouldRememberEndpoints() throws IOException, InterruptedException, StubServer.ForceKilled
282280
{
283281
// Given
284-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
282+
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
285283

286284
//START a read server
287-
StubServer readServer = StubServer.start( resource( "read_server.script" ), 9005 );
285+
StubServer readServer = StubServer.start( "read_server.script", 9005 );
288286
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
289287
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
290288
Session session = driver.session( AccessMode.READ ) )
@@ -304,10 +302,10 @@ public void shouldRememberEndpoints() throws IOException, InterruptedException,
304302
public void shouldForgetEndpointsOnFailure() throws IOException, InterruptedException, StubServer.ForceKilled
305303
{
306304
// Given
307-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
305+
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
308306

309307
//START a read server
310-
StubServer.start( resource( "dead_server.script" ), 9005 );
308+
StubServer.start( "dead_server.script", 9005 );
311309
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
312310
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
313311
try
@@ -336,11 +334,11 @@ public void shouldRediscoverIfNecessaryOnSessionAcquisition()
336334
throws IOException, InterruptedException, StubServer.ForceKilled
337335
{
338336
// Given
339-
StubServer server = StubServer.start( resource( "rediscover.script" ), 9001 );
337+
StubServer server = StubServer.start( "rediscover.script", 9001 );
340338

341339
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
342340
//START a read server
343-
StubServer read = StubServer.start( resource( "empty.script" ), 9005 );
341+
StubServer read = StubServer.start( "empty.script", 9005 );
344342

345343
//On creation we only find ourselves
346344
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
@@ -365,11 +363,11 @@ public void shouldRediscoverIfNecessaryOnSessionAcquisition()
365363
public void shouldOnlyGetServersOnce() throws IOException, InterruptedException, StubServer.ForceKilled
366364
{
367365
// Given
368-
StubServer server = StubServer.start( resource( "rediscover.script" ), 9001 );
366+
StubServer server = StubServer.start( "rediscover.script", 9001 );
369367

370368
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
371369
//START a read server
372-
StubServer read = StubServer.start( resource( "empty.script" ), 9005 );
370+
StubServer read = StubServer.start( "empty.script", 9005 );
373371

374372
//On creation we only find ourselves
375373
final RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
@@ -410,7 +408,7 @@ public void shouldFailOnNonDiscoverableServer() throws IOException, InterruptedE
410408
exception.expect( ServiceUnavailableException.class );
411409

412410
// Given
413-
StubServer.start( resource( "non_discovery_server.script" ), 9001 );
411+
StubServer.start( "non_discovery_server.script", 9001 );
414412
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
415413

416414
// When
@@ -424,7 +422,7 @@ public void shouldFailRandomFailureInGetServers() throws IOException, Interrupte
424422
exception.expect( ServiceUnavailableException.class );
425423

426424
// Given
427-
StubServer.start( resource( "failed_discovery.script" ), 9001 );
425+
StubServer.start( "failed_discovery.script", 9001 );
428426
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
429427

430428
// When
@@ -436,10 +434,10 @@ public void shouldHandleLeaderSwitchWhenWriting()
436434
throws IOException, InterruptedException, StubServer.ForceKilled
437435
{
438436
// Given
439-
StubServer server = StubServer.start( resource( "acquire_endpoints.script" ), 9001 );
437+
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
440438

441439
//START a write server that doesn't accept writes
442-
StubServer.start( resource( "not_able_to_write_server.script" ), 9007 );
440+
StubServer.start( "not_able_to_write_server.script", 9007 );
443441
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
444442
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
445443
boolean failed = false;
@@ -468,10 +466,10 @@ public void shouldHandleLeaderSwitchWhenWriting()
468466
public void shouldRediscoverOnExpiry() throws IOException, InterruptedException, StubServer.ForceKilled
469467
{
470468
// Given
471-
StubServer server = StubServer.start( resource( "expire.script" ), 9001 );
469+
StubServer server = StubServer.start( "expire.script", 9001 );
472470

473471
//START a read server
474-
StubServer readServer = StubServer.start( resource( "empty.script" ), 9005 );
472+
StubServer readServer = StubServer.start( "empty.script", 9005 );
475473
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
476474
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
477475
assertThat(driver.routingServers(), contains(address( 9001 )));
@@ -494,12 +492,12 @@ public void shouldRediscoverOnExpiry() throws IOException, InterruptedException,
494492
public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled
495493
{
496494
// Given
497-
StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 );
495+
StubServer server = StubServer.start( "not_reuse_connection.script", 9001 );
498496

499497
//START servers
500-
StubServer readServer = StubServer.start( resource( "empty.script" ), 9002 );
501-
StubServer writeServer1 = StubServer.start( resource( "dead_server.script" ), 9003 );
502-
StubServer writeServer2 = StubServer.start( resource( "empty.script" ), 9006 );
498+
StubServer readServer = StubServer.start( "empty.script", 9002 );
499+
StubServer writeServer1 = StubServer.start( "dead_server.script", 9003 );
500+
StubServer writeServer2 = StubServer.start( "empty.script", 9006 );
503501
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
504502

505503
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
@@ -548,16 +546,6 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
548546
assertThat( writeServer2.exitStatus(), equalTo( 0 ) );
549547
}
550548

551-
String resource( String fileName )
552-
{
553-
URL resource = RoutingDriverStubTest.class.getClassLoader().getResource( fileName );
554-
if ( resource == null )
555-
{
556-
fail( fileName + " does not exists" );
557-
}
558-
return resource.getFile();
559-
}
560-
561549
private BoltServerAddress address( int port )
562550
{
563551
return new BoltServerAddress( "127.0.0.1", port );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class DriverDocIT
4141
public void exampleUsage( DocSnippet snippet ) throws IOException, InterruptedException, StubServer.ForceKilled
4242
{
4343
// given
44-
StubServer server = StubServer.start( "../driver/src/test/resources/driver_snippet.script" );
44+
StubServer server = StubServer.start( "driver_snippet.script", 7687 );
4545
snippet.addImport( List.class );
4646
snippet.addImport( LinkedList.class );
4747

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public void boltSchemeShouldInstantiateDirectDriver()
5353
public void boltPlusDiscoverySchemeShouldInstantiateClusterDriver() throws IOException, InterruptedException, StubServer.ForceKilled
5454
{
5555
// Given
56-
StubServer server = StubServer.start( "../driver/src/test/resources/discover_servers.script" );
57-
URI uri = URI.create( "bolt+routing://localhost:7687" );
56+
StubServer server = StubServer.start( "discover_servers.script", 9001 );
57+
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
5858

5959
// When
6060
Driver driver = GraphDatabase.driver( uri );

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

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

2222
import java.io.IOException;
23+
import java.net.URL;
2324
import java.util.ArrayList;
2425
import java.util.List;
2526

2627
import static java.lang.Thread.sleep;
2728
import static java.util.Arrays.asList;
2829
import static java.util.Collections.singletonList;
30+
import static org.junit.Assert.fail;
2931

3032
public class StubServer
3133
{
3234
// This may be thrown if the driver has not been closed properly
3335
public static class ForceKilled extends Exception {}
3436

35-
private static final int DEFAULT_PORT = 7687;
36-
3737
private Process process = null;
3838

3939
private StubServer( String script, int port ) throws IOException, InterruptedException
@@ -46,14 +46,9 @@ private StubServer( String script, int port ) throws IOException, InterruptedExc
4646
sleep( 500 ); // might take a moment for the socket to start listening
4747
}
4848

49-
public static StubServer start( String script ) throws IOException, InterruptedException
50-
{
51-
return start( script, DEFAULT_PORT );
52-
}
53-
54-
public static StubServer start( String script, int port ) throws IOException, InterruptedException
49+
public static StubServer start( String resource, int port ) throws IOException, InterruptedException
5550
{
56-
return new StubServer( script, port );
51+
return new StubServer( resource(resource), port );
5752
}
5853

5954
public int exitStatus() throws InterruptedException, ForceKilled
@@ -72,4 +67,13 @@ public int exitStatus() throws InterruptedException, ForceKilled
7267
}
7368
}
7469

70+
private static String resource( String fileName )
71+
{
72+
URL resource = StubServer.class.getClassLoader().getResource( fileName );
73+
if ( resource == null )
74+
{
75+
fail( fileName + " does not exists" );
76+
}
77+
return resource.getFile();
78+
}
7579
}

0 commit comments

Comments
 (0)