Search in sources :

Example 41 with MongoClientSettings

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

the class MongoPropertiesClientSettingsBuilderCustomizerTests method credentialsCanBeCustomized.

@Test
void credentialsCanBeCustomized() {
    this.properties.setUsername("user");
    this.properties.setPassword("secret".toCharArray());
    MongoClientSettings settings = customizeSettings();
    assertMongoCredential(settings.getCredential(), "user", "secret", "test");
}
Also used : MongoClientSettings(com.mongodb.MongoClientSettings) Test(org.junit.jupiter.api.Test)

Example 42 with MongoClientSettings

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

the class MongoPropertiesClientSettingsBuilderCustomizerTests method uuidRepresentationCanBeCustomized.

@Test
void uuidRepresentationCanBeCustomized() {
    this.properties.setUuidRepresentation(UuidRepresentation.STANDARD);
    MongoClientSettings settings = customizeSettings();
    assertThat(settings.getUuidRepresentation()).isEqualTo(UuidRepresentation.STANDARD);
}
Also used : MongoClientSettings(com.mongodb.MongoClientSettings) Test(org.junit.jupiter.api.Test)

Example 43 with MongoClientSettings

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

the class MongoPropertiesClientSettingsBuilderCustomizerTests method uuidRepresentationDefaultToJavaLegacy.

@Test
void uuidRepresentationDefaultToJavaLegacy() {
    MongoClientSettings settings = customizeSettings();
    assertThat(settings.getUuidRepresentation()).isEqualTo(UuidRepresentation.JAVA_LEGACY);
}
Also used : MongoClientSettings(com.mongodb.MongoClientSettings) Test(org.junit.jupiter.api.Test)

Example 44 with MongoClientSettings

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

the class MongoReactiveAutoConfigurationTests method settingsSslConfig.

@Test
void settingsSslConfig() {
    this.contextRunner.withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test").withUserConfiguration(SslSettingsConfig.class).run((context) -> {
        assertThat(context).hasSingleBean(MongoClient.class);
        MongoClientSettings settings = getSettings(context);
        assertThat(settings.getApplicationName()).isEqualTo("test-config");
        assertThat(settings.getStreamFactoryFactory()).isSameAs(context.getBean("myStreamFactoryFactory"));
    });
}
Also used : MongoClientSettings(com.mongodb.MongoClientSettings) Test(org.junit.jupiter.api.Test)

Example 45 with MongoClientSettings

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

the class MongoReactiveAutoConfigurationTests method customizerOverridesAutoConfig.

@Test
void customizerOverridesAutoConfig() {
    this.contextRunner.withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test?appname=auto-config").withUserConfiguration(SimpleCustomizerConfig.class).run((context) -> {
        assertThat(context).hasSingleBean(MongoClient.class);
        MongoClientSettings settings = getSettings(context);
        assertThat(settings.getApplicationName()).isEqualTo("overridden-name");
        assertThat(settings.getStreamFactoryFactory()).isEqualTo(SimpleCustomizerConfig.streamFactoryFactory);
    });
}
Also used : MongoClientSettings(com.mongodb.MongoClientSettings) Test(org.junit.jupiter.api.Test)

Aggregations

MongoClientSettings (com.mongodb.MongoClientSettings)75 Test (org.junit.jupiter.api.Test)24 BsonString (org.bson.BsonString)21 Map (java.util.Map)20 Test (org.junit.Test)20 HashMap (java.util.HashMap)19 Document (org.bson.Document)19 BsonDocument (org.bson.BsonDocument)18 ServerAddress (com.mongodb.ServerAddress)17 AutoEncryptionSettings (com.mongodb.AutoEncryptionSettings)14 Before (org.junit.Before)14 MongoNamespace (com.mongodb.MongoNamespace)13 ClientEncryptionSettings (com.mongodb.ClientEncryptionSettings)12 ConnectionString (com.mongodb.ConnectionString)12 MongoClientFactoryBean (org.springframework.data.mongodb.core.MongoClientFactoryBean)10 Block (com.mongodb.Block)8 Fixture.getMongoClientSettingsBuilder (com.mongodb.client.Fixture.getMongoClientSettingsBuilder)8 SecureRandom (java.security.SecureRandom)8 TimeUnit (java.util.concurrent.TimeUnit)8 ClusterFixture.isServerlessTest (com.mongodb.ClusterFixture.isServerlessTest)7