Commit 439d9bee authored by Andy Wilkinson's avatar Andy Wilkinson

Test that gridFsDatabase is honored by auto-configured GridFsTemplate

Closes gh-21039
parent d27e437d
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -71,9 +71,13 @@ class MongoDataAutoConfigurationTests {
}
@Test
void gridFsTemplateExists() {
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid")
.run((context) -> assertThat(context).hasSingleBean(GridFsTemplate.class));
void whenGridFsDatabaseIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid").run((context) -> {
assertThat(context).hasSingleBean(GridFsTemplate.class);
GridFsTemplate template = context.getBean(GridFsTemplate.class);
MongoDbFactory factory = (MongoDbFactory) ReflectionTestUtils.getField(template, "dbFactory");
assertThat(factory.getDb().getName()).isEqualTo("grid");
});
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment