Skip to content

Commit c7f111b

Browse files
committed
remove 'file:' prefix from fixture location pattern
This allows us to include the prefix in the config, which is more flexible. For example, we can set file:fixtures for the default fixtures, which need to be overridable in the docker container, and we can set classpath:test-fixtures for the test fixtures, which can then be included in the test/resources dir. Moreover, this approach is similar to the way flyway.locations are specified.
1 parent 9295809 commit c7f111b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/org/fairdatapoint/config/BootstrapConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() {
8383
for (String location : this.bootstrap.getLocations()) {
8484
// Path.of() removes trailing slashes, so it is safe to concatenate "/*.json".
8585
// Note that Path.of(location).resolve("*.json") could work on unix but fails on windows.
86-
final String locationPattern = "file:" + Path.of(location) + "/*.json";
87-
resources.addAll(List.of(resourceResolver.getResources(locationPattern)));
86+
resources.addAll(List.of(resourceResolver.getResources(Path.of(location) + "/*.json")));
8887
}
8988
// remove resources that have been applied already
9089
final List<String> appliedFixtures = fixtureHistoryRepository.findAll().stream()

src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
public class BootstrapProperties {
3939
// boolean defaults to false
4040
private boolean enabled;
41-
// locations to search for fixtures
41+
// locations to search for fixtures, for example, file:fixtures, relative to project root,
42+
// or classpath:fixtures (see PathMatchingResourcePatternResolver docs for valid patterns)
4243
private List<String> locations;
4344
}

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ server:
115115
bootstrap:
116116
enabled: true
117117
locations:
118-
- "fixtures"
118+
- file:fixtures

src/test/resources/application-testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ping:
2727
bootstrap:
2828
enabled: true
2929
locations:
30-
- fixtures
31-
- test-fixtures
30+
- file:fixtures
31+
- classpath:test-fixtures

0 commit comments

Comments
 (0)