Commit 51b56782 authored by Andy Wilkinson's avatar Andy Wilkinson

Apply customizers to build when created embedded Mongo client

Closes gh-11132
parent 45e8c237
...@@ -92,6 +92,7 @@ public class ReactiveMongoClientFactory { ...@@ -92,6 +92,7 @@ public class ReactiveMongoClientFactory {
ClusterSettings clusterSettings = ClusterSettings.builder() ClusterSettings clusterSettings = ClusterSettings.builder()
.hosts(Collections.singletonList(new ServerAddress(host, port))).build(); .hosts(Collections.singletonList(new ServerAddress(host, port))).build();
builder.clusterSettings(clusterSettings); builder.clusterSettings(clusterSettings);
customize(builder);
return MongoClients.create(builder.build()); return MongoClients.create(builder.build());
} }
......
...@@ -161,6 +161,16 @@ public class ReactiveMongoClientFactoryTests { ...@@ -161,6 +161,16 @@ public class ReactiveMongoClientFactoryTests {
verify(customizer).customize(any(MongoClientSettings.Builder.class)); verify(customizer).customize(any(MongoClientSettings.Builder.class));
} }
@Test
public void customizerIsInvokedForEmbeddedMongo() {
MongoProperties properties = new MongoProperties();
this.environment.setProperty("local.mongo.port", "27017");
MongoClientSettingsBuilderCustomizer customizer = mock(
MongoClientSettingsBuilderCustomizer.class);
createMongoClient(properties, this.environment, customizer);
verify(customizer).customize(any(MongoClientSettings.Builder.class));
}
private MongoClient createMongoClient(MongoProperties properties) { private MongoClient createMongoClient(MongoProperties properties) {
return createMongoClient(properties, this.environment); return createMongoClient(properties, this.environment);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment