Skip to content

Commit

Permalink
Test that gridFsDatabase is honored by auto-configured GridFsTemplate
Browse files Browse the repository at this point in the history
Closes gh-21039
  • Loading branch information
wilkinsona committed Apr 20, 2020
1 parent d27e437 commit 439d9be
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -71,9 +71,13 @@ void templateExists() {
}

@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
Expand Down

0 comments on commit 439d9be

Please sign in to comment.