Test that gridFsDatabase is honored by auto-configured GridFsTemplate
Closes gh-21039
This commit is contained in:
parent
d27e437ddc
commit
439d9beecb
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -71,9 +71,13 @@ class MongoDataAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gridFsTemplateExists() {
|
void whenGridFsDatabaseIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
|
||||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid")
|
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid").run((context) -> {
|
||||||
.run((context) -> assertThat(context).hasSingleBean(GridFsTemplate.class));
|
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
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue