use of org.springframework.data.mongodb.ReactiveMongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class SimpleReactiveMongoDatabaseFactoryUnitTests method cascadedWithSessionUsesRootFactory.
// DATAMONGO-1880
@Test
void cascadedWithSessionUsesRootFactory() {
when(mongoClient.getDatabase("foo")).thenReturn(database);
ReactiveMongoDatabaseFactory factory = new SimpleReactiveMongoDatabaseFactory(mongoClient, "foo");
ReactiveMongoDatabaseFactory wrapped = factory.withSession(clientSession).withSession(clientSession);
InvocationHandler invocationHandler = Proxy.getInvocationHandler(wrapped.getMongoDatabase().block());
Object singletonTarget = AopProxyUtils.getSingletonTarget(ReflectionTestUtils.getField(invocationHandler, "advised"));
assertThat(singletonTarget).isSameAs(database);
}
use of org.springframework.data.mongodb.ReactiveMongoDatabaseFactory in project spring-boot by spring-projects.
the class MongoReactiveDataAutoConfigurationTests method grisFsTemplateDatabaseName.
private String grisFsTemplateDatabaseName(AssertableApplicationContext context) {
assertThat(context).hasSingleBean(ReactiveGridFsTemplate.class);
ReactiveGridFsTemplate template = context.getBean(ReactiveGridFsTemplate.class);
ReactiveMongoDatabaseFactory factory = (ReactiveMongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
return factory.getMongoDatabase().block().getName();
}
Aggregations