use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithConnectionPoolSettings.
// DATAMONGO-2384
@Test
public void clientWithConnectionPoolSettings() {
assertThat(ctx.containsBean("client-with-connection-pool-settings")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-connection-pool-settings", MongoClientFactoryBean.class);
MongoClientSettings settings = (MongoClientSettings) getField(factoryBean, "mongoClientSettings");
assertThat(settings.getConnectionPoolSettings().getMaxConnectionLifeTime(TimeUnit.MILLISECONDS)).isEqualTo(10);
assertThat(settings.getConnectionPoolSettings().getMinSize()).isEqualTo(10);
assertThat(settings.getConnectionPoolSettings().getMaxSize()).isEqualTo(20);
assertThat(settings.getConnectionPoolSettings().getMaintenanceFrequency(TimeUnit.MILLISECONDS)).isEqualTo(10);
assertThat(settings.getConnectionPoolSettings().getMaintenanceInitialDelay(TimeUnit.MILLISECONDS)).isEqualTo(11);
assertThat(settings.getConnectionPoolSettings().getMaxConnectionIdleTime(TimeUnit.MILLISECONDS)).isEqualTo(30);
assertThat(settings.getConnectionPoolSettings().getMaxWaitTime(TimeUnit.MILLISECONDS)).isEqualTo(15);
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithUUidSettings.
// DATAMONGO-2427
@Test
public void clientWithUUidSettings() {
assertThat(ctx.containsBean("client-with-uuid-settings")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-uuid-settings", MongoClientFactoryBean.class);
MongoClientSettings settings = (MongoClientSettings) getField(factoryBean, "mongoClientSettings");
assertThat(settings.getUuidRepresentation()).isEqualTo(UuidRepresentation.STANDARD);
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithConnectionString.
// DATAMONGO-2384
@Test
public void clientWithConnectionString() {
assertThat(ctx.containsBean("client-with-connection-string")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-connection-string", MongoClientFactoryBean.class);
assertThat(getField(factoryBean, "host")).isNull();
assertThat(getField(factoryBean, "port")).isNull();
assertThat(getField(factoryBean, "connectionString")).isEqualTo(new ConnectionString("mongodb://127.0.0.1:27017/?replicaSet=rs0"));
assertThat(getField(factoryBean, "credential")).isNull();
assertThat(getField(factoryBean, "replicaSet")).isNull();
assertThat(getField(factoryBean, "mongoClientSettings")).isNull();
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithAttributes.
@Test
public void testMongoSingletonWithAttributes() throws Exception {
assertThat(ctx.containsBean("defaultMongo")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&defaultMongo");
String host = (String) getField(mfb, "host");
Integer port = (Integer) getField(mfb, "port");
assertThat(host).isEqualTo("localhost");
assertThat(port).isEqualTo(new Integer(27017));
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options).isNull();
}
use of org.springframework.data.mongodb.core.MongoClientFactoryBean in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithSslEnabled.
// DATAMONGO-764
@Test
public void testMongoSingletonWithSslEnabled() throws Exception {
assertThat(ctx.containsBean("mongoSsl")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoSsl");
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options.getSslSettings().getContext().getSocketFactory() instanceof SSLSocketFactory).as("socketFactory should be a SSLSocketFactory").isTrue();
}
Aggregations