Skip to content

Commit

Permalink
Merge branch '2.4.x'
Browse files Browse the repository at this point in the history
Closes gh-26139
  • Loading branch information
philwebb committed Apr 15, 2021
2 parents 5142fe9 + 302d500 commit 9682386
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ String getDirectory() {
return this.directory;
}

String getProfile() {
return this.profile;
}

boolean isSkippable() {
return this.configDataLocation.isOptional() || this.directory != null || this.profile != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public Resource getResource() {
return this.resource;
}

/**
* Return the profile or {@code null} if the resource is not profile specific.
* @return the profile or {@code null}
* @since 2.4.6
*/
public String getProfile() {
return this.reference.getProfile();
}

boolean isEmptyDirectory() {
return this.emptyDirectory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ void applyToAppliesPostProcessing() {
assertThat(this.environment.getActiveProfiles()).containsExactly("dev");
assertThat(listener.getAddedPropertySources()).hasSizeGreaterThan(0);
assertThat(listener.getProfiles().getActive()).containsExactly("dev");
assertThat(listener.getAddedPropertySources().stream().anyMatch((added) -> hasDevProfile(added.getResource())))
.isTrue();
}

private boolean hasDevProfile(ConfigDataResource resource) {
return (resource instanceof StandardConfigDataResource)
&& "dev".equals(((StandardConfigDataResource) resource).getProfile());
}

}

0 comments on commit 9682386

Please sign in to comment.