Search in sources :

Example 1 with MongoClientSettings

use of com.mongodb.async.client.MongoClientSettings in project spring-boot by spring-projects.

the class ReactiveMongoAutoConfigurationTests method optionsSslConfig.

@Test
public void optionsSslConfig() {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.uri:mongodb://localhost/test");
    this.context.register(SslOptionsConfig.class, PropertyPlaceholderAutoConfiguration.class, ReactiveMongoAutoConfiguration.class);
    this.context.refresh();
    MongoClient mongo = this.context.getBean(MongoClient.class);
    MongoClientSettings settings = mongo.getSettings();
    assertThat(settings.getApplicationName()).isEqualTo("test-config");
    assertThat(settings.getStreamFactoryFactory()).isSameAs(this.context.getBean("myStreamFactoryFactory"));
}
Also used : MongoClient(com.mongodb.reactivestreams.client.MongoClient) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MongoClientSettings(com.mongodb.async.client.MongoClientSettings) Test(org.junit.Test)

Example 2 with MongoClientSettings

use of com.mongodb.async.client.MongoClientSettings in project spring-boot by spring-projects.

the class ReactiveMongoClientFactoryTests method extractServerAddresses.

private List<ServerAddress> extractServerAddresses(MongoClient client) {
    MongoClientSettings settings = client.getSettings();
    ClusterSettings clusterSettings = settings.getClusterSettings();
    List<ServerAddress> allAddresses = clusterSettings.getHosts();
    return allAddresses;
}
Also used : ClusterSettings(com.mongodb.connection.ClusterSettings) ServerAddress(com.mongodb.ServerAddress) MongoClientSettings(com.mongodb.async.client.MongoClientSettings)

Aggregations

MongoClientSettings (com.mongodb.async.client.MongoClientSettings)2 ServerAddress (com.mongodb.ServerAddress)1 ClusterSettings (com.mongodb.connection.ClusterSettings)1 MongoClient (com.mongodb.reactivestreams.client.MongoClient)1 Test (org.junit.Test)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1