|
24 | 24 |
|
25 | 25 | import java.io.IOException; |
26 | 26 | import java.util.HashMap; |
| 27 | +import java.util.List; |
27 | 28 | import java.util.Map; |
28 | 29 |
|
29 | 30 | import org.neo4j.driver.Logger; |
|
49 | 50 | import static org.hamcrest.CoreMatchers.equalTo; |
50 | 51 | import static org.junit.Assert.assertThat; |
51 | 52 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 53 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
52 | 54 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
53 | 55 | import static org.junit.jupiter.api.Assertions.assertThrows; |
54 | 56 | import static org.mockito.ArgumentMatchers.any; |
@@ -400,22 +402,36 @@ void shouldNotLogWhenSingleRetryAttemptFails() |
400 | 402 | Rediscovery rediscovery = new RediscoveryImpl( A, settings, compositionProvider, eventExecutor, resolver, logger ); |
401 | 403 | RoutingTable table = routingTableMock( A ); |
402 | 404 |
|
403 | | - ServiceUnavailableException e = assertThrows( ServiceUnavailableException.class, () -> await( rediscovery.lookupClusterComposition( table, pool, empty() ) ) ); |
| 405 | + ServiceUnavailableException e = |
| 406 | + assertThrows( ServiceUnavailableException.class, () -> await( rediscovery.lookupClusterComposition( table, pool, empty() ) ) ); |
404 | 407 | assertThat( e.getMessage(), containsString( "Could not perform discovery" ) ); |
405 | 408 |
|
406 | 409 | // rediscovery should not log about retries and should not schedule any retries |
407 | 410 | verify( logger, never() ).info( startsWith( "Unable to fetch new routing table, will try again in " ) ); |
408 | 411 | assertEquals( 0, eventExecutor.scheduleDelays().size() ); |
409 | 412 | } |
410 | 413 |
|
| 414 | + @Test |
| 415 | + void shouldNotResolveToIPs() |
| 416 | + { |
| 417 | + ServerAddressResolver resolver = resolverMock( A, A ); |
| 418 | + Rediscovery rediscovery = new RediscoveryImpl( A, null, null, null, resolver, null ); |
| 419 | + |
| 420 | + List<BoltServerAddress> addresses = rediscovery.resolve(); |
| 421 | + |
| 422 | + verify( resolver, times( 1 ) ).resolve( A ); |
| 423 | + assertEquals( 1, addresses.size() ); |
| 424 | + assertFalse( addresses.get( 0 ).isResolved() ); |
| 425 | + } |
| 426 | + |
411 | 427 | private Rediscovery newRediscovery( BoltServerAddress initialRouter, ClusterCompositionProvider compositionProvider, |
412 | | - ServerAddressResolver resolver ) |
| 428 | + ServerAddressResolver resolver ) |
413 | 429 | { |
414 | 430 | return newRediscovery( initialRouter, compositionProvider, resolver, DEV_NULL_LOGGER ); |
415 | 431 | } |
416 | 432 |
|
417 | 433 | private Rediscovery newRediscovery( BoltServerAddress initialRouter, ClusterCompositionProvider compositionProvider, |
418 | | - ServerAddressResolver resolver, Logger logger ) |
| 434 | + ServerAddressResolver resolver, Logger logger ) |
419 | 435 | { |
420 | 436 | RoutingSettings settings = new RoutingSettings( 1, 0, 0 ); |
421 | 437 | return new RediscoveryImpl( initialRouter, settings, compositionProvider, GlobalEventExecutor.INSTANCE, resolver, logger ); |
|
0 commit comments