use of com.mongodb.MongoClientSettings in project spring-boot by spring-projects.
the class MongoPropertiesClientSettingsBuilderCustomizerTests method replicaSetCanBeCustomized.
@Test
void replicaSetCanBeCustomized() {
this.properties.setReplicaSetName("test");
MongoClientSettings settings = customizeSettings();
assertThat(settings.getClusterSettings().getRequiredReplicaSetName()).isEqualTo("test");
}
use of com.mongodb.MongoClientSettings in project spring-boot by spring-projects.
the class MongoPropertiesClientSettingsBuilderCustomizerTests method onlyUriSetShouldUseThat.
@Test
void onlyUriSetShouldUseThat() {
this.properties.setUri("mongodb://mongo1.example.com:12345");
MongoClientSettings settings = customizeSettings();
List<ServerAddress> allAddresses = getAllAddresses(settings);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
}
use of com.mongodb.MongoClientSettings in project spring-boot by spring-projects.
the class MongoPropertiesClientSettingsBuilderCustomizerTests method uriCanBeCustomized.
@Test
void uriCanBeCustomized() {
this.properties.setUri("mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test");
MongoClientSettings settings = customizeSettings();
List<ServerAddress> allAddresses = getAllAddresses(settings);
assertThat(allAddresses).hasSize(2);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456);
assertMongoCredential(settings.getCredential(), "user", "secret", "test");
}
use of com.mongodb.MongoClientSettings in project spring-boot by spring-projects.
the class MongoPropertiesClientSettingsBuilderCustomizerTests method uriIsIgnoredInEmbeddedMode.
@Test
void uriIsIgnoredInEmbeddedMode() {
this.properties.setUri("mongodb://mongo.example.com:1234/mydb");
this.environment.setProperty("local.mongo.port", "4000");
MongoClientSettings settings = customizeSettings();
List<ServerAddress> allAddresses = getAllAddresses(settings);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 4000);
}
use of com.mongodb.MongoClientSettings in project spring-boot by spring-projects.
the class MongoPropertiesClientSettingsBuilderCustomizerTests method onlyHostAndPortSetShouldUseThat.
@Test
void onlyHostAndPortSetShouldUseThat() {
this.properties.setHost("localhost");
this.properties.setPort(27017);
MongoClientSettings settings = customizeSettings();
List<ServerAddress> allAddresses = getAllAddresses(settings);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 27017);
}
Aggregations