Skip to content

Commit

Permalink
Merge branch '3.0.x' into 3.1.x
Browse files Browse the repository at this point in the history
Closes gh-37570
  • Loading branch information
mhalbritter committed Sep 25, 2023
2 parents 742dae5 + b93ce92 commit 02f71d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -228,6 +228,9 @@ private Set<StandardConfigDataReference> getReferencesForFile(ConfigDataLocation
return Collections.singleton(reference);
}
}
if (configDataLocation.isOptional()) {
return Collections.emptySet();
}
throw new IllegalStateException("File extension is not known to any PropertySourceLoader. "
+ "If the location is meant to reference a directory, it must end in '/' or File.separator");
}
Expand Down
Expand Up @@ -43,6 +43,7 @@
*
* @author Madhura Bhave
* @author Phillip Webb
* @author Moritz Halbritter
*/
class StandardConfigDataLocationResolverTests {

Expand Down Expand Up @@ -263,6 +264,26 @@ void resolveProfileSpecificWhenLocationIsFileReturnsEmptyList() {
assertThat(locations).isEmpty();
}

@Test
void resolveWhenOptionalAndLoaderIsUnknownShouldNotFail() {
ConfigDataLocation location = ConfigDataLocation.of("optional:some-unknown-loader:dummy.properties");
assertThatNoException().isThrownBy(() -> this.resolver.resolve(this.context, location));
}

@Test
void resolveWhenOptionalAndLoaderIsUnknownAndExtensionIsUnknownShouldNotFail() {
ConfigDataLocation location = ConfigDataLocation
.of("optional:some-unknown-loader:dummy.some-unknown-extension");
List<StandardConfigDataResource> locations = this.resolver.resolve(this.context, location);
assertThatNoException().isThrownBy(() -> this.resolver.resolve(this.context, location));
}

@Test
void resolveWhenOptionalAndExtensionIsUnknownShouldNotFail() {
ConfigDataLocation location = ConfigDataLocation.of("optional:file:dummy.some-unknown-extension");
assertThatNoException().isThrownBy(() -> this.resolver.resolve(this.context, location));
}

private String filePath(String... components) {
return "file [" + String.join(File.separator, components) + "]";
}
Expand Down

0 comments on commit 02f71d8

Please sign in to comment.