use of com.mongodb.MongoClient in project spring-boot by spring-projects.
the class MongoClientFactoryTests method credentialsCanBeCustomized.
@Test
public void credentialsCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setUsername("user");
properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", "test");
}
use of com.mongodb.MongoClient in project spring-boot by spring-projects.
the class MongoClientFactoryTests method portCanBeCustomized.
@Test
public void portCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setPort(12345);
MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = extractServerAddresses(client);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 12345);
}
use of com.mongodb.MongoClient in project spring-boot by spring-projects.
the class MongoClientFactoryTests method databaseCanBeCustomized.
@Test
public void databaseCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setDatabase("foo");
properties.setUsername("user");
properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", "foo");
}
use of com.mongodb.MongoClient in project spring-boot by spring-projects.
the class MongoClientFactoryTests method authenticationDatabaseCanBeCustomized.
@Test
public void authenticationDatabaseCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setAuthenticationDatabase("foo");
properties.setUsername("user");
properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", "foo");
}
use of com.mongodb.MongoClient in project spring-boot by spring-projects.
the class MongoClientFactoryTests method hostCanBeCustomized.
@Test
public void hostCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setHost("mongo.example.com");
MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = extractServerAddresses(client);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "mongo.example.com", 27017);
}
Aggregations