|
21 | 21 | import com.mongodb.MongoException; |
22 | 22 | import com.mongodb.MongoSocketException; |
23 | 23 | import com.mongodb.ServerAddress; |
24 | | -import com.mongodb.connection.ServerConnectionState; |
25 | 24 | import com.mongodb.connection.ServerDescription; |
26 | 25 | import com.mongodb.event.ClusterDescriptionChangedEvent; |
27 | 26 | import com.mongodb.event.ClusterListener; |
28 | 27 | import com.mongodb.spi.dns.DnsClient; |
29 | 28 | import com.mongodb.spi.dns.DnsException; |
30 | 29 | import com.mongodb.spi.dns.InetAddressResolver; |
31 | 30 | import org.junit.jupiter.api.Test; |
32 | | -import org.junit.jupiter.params.ParameterizedTest; |
33 | | -import org.junit.jupiter.params.provider.ValueSource; |
34 | 31 |
|
35 | 32 | import java.net.UnknownHostException; |
36 | 33 | import java.util.Collections; |
37 | 34 | import java.util.concurrent.CompletableFuture; |
38 | 35 | import java.util.concurrent.ExecutionException; |
39 | 36 | import java.util.concurrent.TimeoutException; |
40 | 37 |
|
41 | | -import static com.mongodb.ClusterFixture.getConnectionString; |
42 | | -import static com.mongodb.ClusterFixture.getServerApi; |
43 | | -import static com.mongodb.ClusterFixture.isStandalone; |
44 | 38 | import static java.util.concurrent.TimeUnit.SECONDS; |
45 | 39 | import static org.junit.jupiter.api.Assertions.assertEquals; |
46 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
47 | | -import static org.junit.jupiter.api.Assumptions.assumeTrue; |
48 | 40 |
|
49 | 41 | @SuppressWarnings("try") |
50 | 42 | public abstract class AbstractDnsConfigurationTest { |
@@ -81,41 +73,6 @@ public void clusterDescriptionChanged(final ClusterDescriptionChangedEvent event |
81 | 73 | } |
82 | 74 | } |
83 | 75 |
|
84 | | - @ParameterizedTest(name = "InetAddressResolver should not be used to resolve IP literal {0}") |
85 | | - @ValueSource(strings = {"127.0.0.1", "::1", "[0:0:0:0:0:0:0:1]"}) |
86 | | - public void testInetAddressResolverDoesNotResolveIpLiteral(final String ipLiteral) throws InterruptedException, ExecutionException, |
87 | | - TimeoutException { |
88 | | - assumeTrue(isStandalone()); |
89 | | - assumeTrue(getServerApi() == null); |
90 | | - |
91 | | - // should not be invoked for IP literals |
92 | | - InetAddressResolver resolver = host -> { |
93 | | - throw new UnknownHostException(); |
94 | | - }; |
95 | | - |
96 | | - CompletableFuture<Boolean> serverConnectedFuture = new CompletableFuture<>(); |
97 | | - MongoClientSettings settings = MongoClientSettings.builder() |
98 | | - .applyConnectionString(getConnectionString()) |
99 | | - .applyToClusterSettings(builder -> |
100 | | - builder.hosts(Collections.singletonList(new ServerAddress(ipLiteral))) |
101 | | - .addClusterListener(new ClusterListener() { |
102 | | - @Override |
103 | | - public void clusterDescriptionChanged(final ClusterDescriptionChangedEvent event) { |
104 | | - ServerDescription serverDescription = event.getNewDescription().getServerDescriptions().get(0); |
105 | | - // If the resolver that throws an exception is invoked, the state will not be CONNECTED |
106 | | - if (serverDescription.getState() == ServerConnectionState.CONNECTED) { |
107 | | - serverConnectedFuture.complete(true); |
108 | | - } |
109 | | - } |
110 | | - })) |
111 | | - .inetAddressResolver(resolver) |
112 | | - .build(); |
113 | | - |
114 | | - try (MongoClient ignored = createMongoClient(settings)) { |
115 | | - assertTrue(serverConnectedFuture.get(1, SECONDS)); |
116 | | - } |
117 | | - } |
118 | | - |
119 | 76 | @Test |
120 | 77 | public void testDnsClientConfiguration() throws InterruptedException, ExecutionException, TimeoutException { |
121 | 78 | DnsException exception = new DnsException("", new Exception()); |
|
0 commit comments