use of com.mongodb.connection.ClusterDescription in project mongo-java-driver by mongodb.
the class ServerAddressSelectorTest method testAll.
@Test
public void testAll() throws UnknownHostException {
ServerAddressSelector selector = new ServerAddressSelector(new ServerAddress("localhost:27018"));
assertTrue(selector.toString().startsWith("ServerAddressSelector"));
assertEquals(selector.getServerAddress(), selector.getServerAddress());
ServerDescription primary = ServerDescription.builder().state(CONNECTED).address(new ServerAddress()).ok(true).type(ServerType.REPLICA_SET_PRIMARY).build();
ServerDescription secondary = ServerDescription.builder().state(CONNECTED).address(new ServerAddress("localhost:27018")).ok(true).type(ServerType.REPLICA_SET_SECONDARY).build();
assertEquals(Arrays.asList(secondary), selector.select(new ClusterDescription(MULTIPLE, REPLICA_SET, Arrays.asList(primary, secondary))));
}
Aggregations