GraphDatabase { public static Driver routingDriver( Iterable<URI> routingUris, AuthToken authToken, Config config ) { assertRoutingUris( routingUris ); Logger log = createLogger( config ); for ( URI uri : routingUris ) { final Driver driver = driver( uri, authToken, config ); try { driver.verifyConnectivity(); return driver; } catch ( ServiceUnavailableException e ) { log.warn( "Unable to create routing driver for URI: " + uri, e ); closeDriver( driver, uri, log ); } catch ( Throwable e ) { closeDriver( driver, uri, log ); throw e; } } throw new ServiceUnavailableException( "Failed to discover an available server" ); }  static Driver driver( String uri ); static Driver driver( URI uri ); static Driver driver( URI uri, Config config ); static Driver driver( String uri, Config config ); static Driver driver( String uri, AuthToken authToken ); static Driver driver( URI uri, AuthToken authToken ); static Driver driver( String uri, AuthToken authToken, Config config ); static Driver driver( URI uri, AuthToken authToken, Config config ); static Driver routingDriver( Iterable<URI> routingUris, AuthToken authToken, Config config );  }
@Test void shouldLogWhenUnableToCreateRoutingDriver() throws Exception { StubServer server1 = StubServer.start( "discover_not_supported_9001.script", 9001 ); StubServer server2 = StubServer.start( "discover_not_supported_9002.script", 9002 ); Logging logging = mock( Logging.class ); Logger logger = mock( Logger.class ); when( logging.getLog( anyString() ) ).thenReturn( logger ); Config config = Config.builder() .withoutEncryption() .withLogging( logging ) .build(); List<URI> routingUris = asList( URI.create( "neo4j: URI.create( "neo4j: assertThrows( ServiceUnavailableException.class, () -> GraphDatabase.routingDriver( routingUris, AuthTokens.none(), config ) ); verify( logger ).warn( eq( "Unable to create routing driver for URI: neo4j: any( Throwable.class ) ); verify( logger ).warn( eq( "Unable to create routing driver for URI: neo4j: any( Throwable.class ) ); assertEquals( 0, server1.exitStatus() ); assertEquals( 0, server2.exitStatus() ); }