59
59
import static org .junit .Assert .fail ;
60
60
61
61
@ Ignore
62
- public class ClusterDriverStubTest
62
+ public class RoutingDriverStubTest
63
63
{
64
64
@ Rule
65
65
public ExpectedException exception = ExpectedException .none ();
@@ -74,7 +74,7 @@ public void shouldDiscoverServers() throws IOException, InterruptedException, St
74
74
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
75
75
76
76
// When
77
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config ) )
77
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config ) )
78
78
{
79
79
// Then
80
80
Set <BoltServerAddress > addresses = driver .routingServers ();
@@ -94,7 +94,7 @@ public void shouldDiscoverNewServers() throws IOException, InterruptedException,
94
94
BoltServerAddress seed = address ( 9001 );
95
95
96
96
// When
97
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config ) )
97
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config ) )
98
98
{
99
99
// Then
100
100
Set <BoltServerAddress > addresses = driver .routingServers ();
@@ -112,7 +112,7 @@ public void shouldHandleEmptyResponse() throws IOException, InterruptedException
112
112
// Given
113
113
StubServer server = StubServer .start ( resource ( "handle_empty_response.script" ), 9001 );
114
114
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
115
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config ) )
115
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config ) )
116
116
{
117
117
Set <BoltServerAddress > servers = driver .routingServers ();
118
118
assertThat ( servers , hasSize ( 0 ) );
@@ -132,7 +132,7 @@ public void shouldHandleAcquireReadSession() throws IOException, InterruptedExce
132
132
//START a read server
133
133
StubServer readServer = StubServer .start ( resource ( "read_server.script" ), 9005 );
134
134
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
135
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
135
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
136
136
Session session = driver .session ( AccessMode .READ ) )
137
137
{
138
138
List <String > result = session .run ( "MATCH (n) RETURN n.name" ).list ( new Function <Record ,String >()
@@ -162,7 +162,7 @@ public void shouldRoundRobinReadServers() throws IOException, InterruptedExcepti
162
162
StubServer readServer1 = StubServer .start ( resource ( "read_server.script" ), 9005 );
163
163
StubServer readServer2 = StubServer .start ( resource ( "read_server.script" ), 9006 );
164
164
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
165
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config ) )
165
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config ) )
166
166
{
167
167
// Run twice, one on each read server
168
168
for ( int i = 0 ; i < 2 ; i ++ )
@@ -200,7 +200,7 @@ public void shouldThrowSessionExpiredIfReadServerDisappears()
200
200
//START a read server
201
201
StubServer .start ( resource ( "dead_server.script" ), 9005 );
202
202
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
203
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
203
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
204
204
Session session = driver .session ( AccessMode .READ ) )
205
205
{
206
206
session .run ( "MATCH (n) RETURN n.name" );
@@ -223,7 +223,7 @@ public void shouldThrowSessionExpiredIfWriteServerDisappears()
223
223
//START a dead write servers
224
224
StubServer .start ( resource ( "dead_server.script" ), 9007 );
225
225
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
226
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
226
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
227
227
Session session = driver .session ( AccessMode .WRITE ) )
228
228
{
229
229
session .run ( "MATCH (n) RETURN n.name" ).consume ();
@@ -241,7 +241,7 @@ public void shouldHandleAcquireWriteSession() throws IOException, InterruptedExc
241
241
//START a write server
242
242
StubServer writeServer = StubServer .start ( resource ( "write_server.script" ), 9007 );
243
243
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
244
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
244
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
245
245
Session session = driver .session ( AccessMode .WRITE ) )
246
246
{
247
247
session .run ( "CREATE (n {name:'Bob'})" );
@@ -261,7 +261,7 @@ public void shouldRoundRobinWriteSessions() throws IOException, InterruptedExcep
261
261
StubServer writeServer1 = StubServer .start ( resource ( "write_server.script" ), 9007 );
262
262
StubServer writeServer2 = StubServer .start ( resource ( "write_server.script" ), 9008 );
263
263
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
264
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config ) )
264
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config ) )
265
265
{
266
266
for ( int i = 0 ; i < 2 ; i ++ )
267
267
{
@@ -286,7 +286,7 @@ public void shouldRememberEndpoints() throws IOException, InterruptedException,
286
286
//START a read server
287
287
StubServer readServer = StubServer .start ( resource ( "read_server.script" ), 9005 );
288
288
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
289
- try ( ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
289
+ try ( RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
290
290
Session session = driver .session ( AccessMode .READ ) )
291
291
{
292
292
session .run ( "MATCH (n) RETURN n.name" ).consume ();
@@ -309,7 +309,7 @@ public void shouldForgetEndpointsOnFailure() throws IOException, InterruptedExce
309
309
//START a read server
310
310
StubServer .start ( resource ( "dead_server.script" ), 9005 );
311
311
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
312
- ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
312
+ RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
313
313
try
314
314
{
315
315
Session session = driver .session ( AccessMode .READ );
@@ -343,7 +343,7 @@ public void shouldRediscoverIfNecessaryOnSessionAcquisition()
343
343
StubServer read = StubServer .start ( resource ( "empty.script" ), 9005 );
344
344
345
345
//On creation we only find ourselves
346
- ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
346
+ RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
347
347
assertThat ( driver .routingServers (), containsInAnyOrder ( address ( 9001 ) ) );
348
348
assertTrue ( driver .connectionPool ().hasAddress ( address ( 9001 ) ) );
349
349
@@ -372,7 +372,7 @@ public void shouldOnlyGetServersOnce() throws IOException, InterruptedException,
372
372
StubServer read = StubServer .start ( resource ( "empty.script" ), 9005 );
373
373
374
374
//On creation we only find ourselves
375
- final ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
375
+ final RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
376
376
assertThat ( driver .routingServers (), containsInAnyOrder ( address ( 9001 ) ) );
377
377
378
378
ExecutorService runner = Executors .newFixedThreadPool ( 10 );
@@ -441,7 +441,7 @@ public void shouldHandleLeaderSwitchWhenWriting()
441
441
//START a write server that doesn't accept writes
442
442
StubServer .start ( resource ( "not_able_to_write_server.script" ), 9007 );
443
443
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
444
- ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
444
+ RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
445
445
boolean failed = false ;
446
446
try ( Session session = driver .session ( AccessMode .WRITE ) )
447
447
{
@@ -473,7 +473,7 @@ public void shouldRediscoverOnExpiry() throws IOException, InterruptedException,
473
473
//START a read server
474
474
StubServer readServer = StubServer .start ( resource ( "empty.script" ), 9005 );
475
475
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
476
- ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
476
+ RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
477
477
assertThat (driver .routingServers (), contains (address ( 9001 )));
478
478
assertThat (driver .readServers (), contains (address ( 9002 )));
479
479
assertThat (driver .writeServers (), contains (address ( 9003 )));
@@ -502,7 +502,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
502
502
StubServer writeServer2 = StubServer .start ( resource ( "empty.script" ), 9006 );
503
503
URI uri = URI .create ( "bolt+routing://127.0.0.1:9001" );
504
504
505
- ClusterDriver driver = (ClusterDriver ) GraphDatabase .driver ( uri , config );
505
+ RoutingDriver driver = (RoutingDriver ) GraphDatabase .driver ( uri , config );
506
506
507
507
508
508
//Open both a read and a write session
@@ -532,7 +532,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
532
532
533
533
// now we close the read session and the connection should not be put
534
534
// back to the pool
535
- Connection connection = ((ClusteredNetworkSession ) readSession ).connection ;
535
+ Connection connection = ((RoutingNetworkSession ) readSession ).connection ;
536
536
assertTrue ( connection .isOpen () );
537
537
readSession .close ();
538
538
assertFalse ( connection .isOpen () );
@@ -550,7 +550,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
550
550
551
551
String resource ( String fileName )
552
552
{
553
- URL resource = ClusterDriverStubTest .class .getClassLoader ().getResource ( fileName );
553
+ URL resource = RoutingDriverStubTest .class .getClassLoader ().getResource ( fileName );
554
554
if ( resource == null )
555
555
{
556
556
fail ( fileName + " does not exists" );
0 commit comments