@@ -963,22 +963,7 @@ public void shouldAcceptRoutingTableWithoutWritersAndThenRediscover() throws Exc
963
963
// start another router which knows about writes, use same address as the initial router
964
964
router2 = StubServer .start ( "acquire_endpoints.script" , 9010 );
965
965
966
- List <String > names = session .readTransaction ( new TransactionWork <List <String >>()
967
- {
968
- @ Override
969
- public List <String > execute ( Transaction tx )
970
- {
971
- List <Record > records = tx .run ( "MATCH (n) RETURN n.name" ).list ();
972
- List <String > names = new ArrayList <>( records .size () );
973
- for ( Record record : records )
974
- {
975
- names .add ( record .get ( 0 ).asString () );
976
- }
977
- return names ;
978
- }
979
- } );
980
-
981
- assertEquals ( asList ( "Bob" , "Alice" , "Tina" ), names );
966
+ assertEquals ( asList ( "Bob" , "Alice" , "Tina" ), readStrings ( "MATCH (n) RETURN n.name" , session ) );
982
967
983
968
StatementResult createResult = session .run ( "CREATE (n {name:'Bob'})" );
984
969
assertFalse ( createResult .hasNext () );
@@ -993,6 +978,35 @@ public List<String> execute( Transaction tx )
993
978
}
994
979
}
995
980
981
+ @ Test
982
+ public void shouldTreatRoutingTableWithSingleRouterAsValid () throws Exception
983
+ {
984
+ StubServer router = StubServer .start ( "discover_one_router.script" , 9010 );
985
+ StubServer reader1 = StubServer .start ( "read_server.script" , 9003 );
986
+ StubServer reader2 = StubServer .start ( "read_server.script" , 9004 );
987
+
988
+ try ( Driver driver = GraphDatabase .driver ( "bolt+routing://127.0.0.1:9010" , config );
989
+ Session session = driver .session ( AccessMode .READ ) )
990
+ {
991
+ // returned routing table contains only one router, this should be fine and we should be able to
992
+ // read multiple times without additional rediscovery
993
+
994
+ StatementResult readResult1 = session .run ( "MATCH (n) RETURN n.name" );
995
+ assertEquals ( "127.0.0.1:9003" , readResult1 .summary ().server ().address () );
996
+ assertEquals ( 3 , readResult1 .list ().size () );
997
+
998
+ StatementResult readResult2 = session .run ( "MATCH (n) RETURN n.name" );
999
+ assertEquals ( "127.0.0.1:9004" , readResult2 .summary ().server ().address () );
1000
+ assertEquals ( 3 , readResult2 .list ().size () );
1001
+ }
1002
+ finally
1003
+ {
1004
+ assertEquals ( 0 , router .exitStatus () );
1005
+ assertEquals ( 0 , reader1 .exitStatus () );
1006
+ assertEquals ( 0 , reader2 .exitStatus () );
1007
+ }
1008
+ }
1009
+
996
1010
private static Driver newDriverWithSleeplessClock ( String uriString )
997
1011
{
998
1012
DriverFactory driverFactory = new DriverFactoryWithClock ( new SleeplessClock () );
0 commit comments