use of com.mongodb.reactivestreams.client.MongoClient in project spring-boot by spring-projects.
the class ReactiveMongoClientFactoryTests method uriIsIgnoredInEmbeddedMode.
@Test
public void uriIsIgnoredInEmbeddedMode() throws UnknownHostException {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://mongo.example.com:1234/mydb");
this.environment.setProperty("local.mongo.port", "4000");
MongoClient client = createMongoClient(properties, this.environment);
List<ServerAddress> allAddresses = extractServerAddresses(client);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 4000);
}
use of com.mongodb.reactivestreams.client.MongoClient in project spring-boot by spring-projects.
the class ReactiveMongoClientFactoryTests method portCanBeCustomized.
@Test
public void portCanBeCustomized() throws UnknownHostException {
MongoProperties properties = new MongoProperties();
properties.setPort(12345);
MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = extractServerAddresses(client);
assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 12345);
}
use of com.mongodb.reactivestreams.client.MongoClient in project spring-boot by spring-projects.
the class ReactiveMongoClientFactoryTests method uriCanBeCustomized.
@Test
public void uriCanBeCustomized() throws UnknownHostException {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://user:secret@mongo1.example.com:12345," + "mongo2.example.com:23456/test");
MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = extractServerAddresses(client);
assertThat(allAddresses).hasSize(2);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456);
List<MongoCredential> credentialsList = extractMongoCredentials(client);
assertThat(credentialsList).hasSize(1);
assertMongoCredential(credentialsList.get(0), "user", "secret", "test");
}
use of com.mongodb.reactivestreams.client.MongoClient in project spring-boot by spring-projects.
the class ReactiveMongoClientFactoryTests method credentialsCanBeCustomized.
@Test
public void credentialsCanBeCustomized() throws UnknownHostException {
MongoProperties properties = new MongoProperties();
properties.setUsername("user");
properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties);
assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret", "test");
}
use of com.mongodb.reactivestreams.client.MongoClient in project spring-boot by spring-projects.
the class ReactiveMongoRepositoriesAutoConfigurationTests method testDefaultRepositoryConfiguration.
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
prepareApplicationContext(TestConfiguration.class);
assertThat(this.context.getBean(ReactiveCityRepository.class)).isNotNull();
MongoClient client = this.context.getBean(MongoClient.class);
assertThat(client).isInstanceOf(MongoClient.class);
MongoMappingContext mappingContext = this.context.getBean(MongoMappingContext.class);
@SuppressWarnings("unchecked") Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils.getField(mappingContext, "initialEntitySet");
assertThat(entities).hasSize(1);
}
Aggregations