use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithReplicaSet.
// DATAMONGO-2384
@Test
public void clientWithReplicaSet() {
assertThat(ctx.containsBean("client-with-replica-set")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-replica-set", MongoClientFactoryBean.class);
assertThat(getField(factoryBean, "host")).isNull();
assertThat(getField(factoryBean, "port")).isNull();
assertThat(getField(factoryBean, "connectionString")).isNull();
assertThat(getField(factoryBean, "credential")).isNull();
assertThat(getField(factoryBean, "replicaSet")).isEqualTo("rs0");
assertThat(getField(factoryBean, "mongoClientSettings")).isNull();
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithServerVersion.
// GH-3820
@Test
public void clientWithServerVersion() {
assertThat(ctx.containsBean("client-with-server-api-settings")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-server-api-settings", MongoClientFactoryBean.class);
MongoClientSettings settings = (MongoClientSettings) getField(factoryBean, "mongoClientSettings");
assertThat(settings.getServerApi()).isNotNull().satisfies(it -> {
assertThat(it.getVersion()).isEqualTo(ServerApiVersion.V1);
});
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithSslEnabledAndCustomSslSocketFactory.
// DATAMONGO-764
@Test
public void testMongoSingletonWithSslEnabledAndCustomSslSocketFactory() throws Exception {
assertThat(ctx.containsBean("mongoSslWithCustomSslFactory")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoSslWithCustomSslFactory");
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options.getSslSettings().getContext().getSocketFactory() instanceof SSLSocketFactory).as("socketFactory should be a SSLSocketFactory").isTrue();
assertThat(options.getSslSettings().getContext().getProvider().getName()).isEqualTo("SunJSSE");
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoClientSingletonWithSslEnabled.
// DATAMONGO-1490
@Test
public void testMongoClientSingletonWithSslEnabled() {
assertThat(ctx.containsBean("mongoClientSsl")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoClientSsl");
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options.getSslSettings().getContext().getSocketFactory() instanceof SSLSocketFactory).as("socketFactory should be a SSLSocketFactory").isTrue();
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithPropertyPlaceHolders.
@Test
public void testMongoSingletonWithPropertyPlaceHolders() {
assertThat(ctx.containsBean("mongoClient")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoClient");
String host = (String) getField(mfb, "host");
Integer port = (Integer) getField(mfb, "port");
assertThat(host).isEqualTo("127.0.0.1");
assertThat(port).isEqualTo(new Integer(27017));
}
Aggregations