@@ -963,22 +963,7 @@ public void shouldAcceptRoutingTableWithoutWritersAndThenRediscover() throws Exc
963963 // start another router which knows about writes, use same address as the initial router
964964 router2 = StubServer .start ( "acquire_endpoints.script" , 9010 );
965965
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 ) );
982967
983968 StatementResult createResult = session .run ( "CREATE (n {name:'Bob'})" );
984969 assertFalse ( createResult .hasNext () );
@@ -993,6 +978,35 @@ public List<String> execute( Transaction tx )
993978 }
994979 }
995980
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+
9961010 private static Driver newDriverWithSleeplessClock ( String uriString )
9971011 {
9981012 DriverFactory driverFactory = new DriverFactoryWithClock ( new SleeplessClock () );
0 commit comments