-
Notifications
You must be signed in to change notification settings - Fork 38.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use relative path following placeholder in @TestPropertySource locations #23544
Comments
Thanks for raising the issue. It's certainly a unique problem that only appears to manifest itself if you have a placeholder immediately followed by
That is indeed the best way to reference the parent directory for the currently executing project. So I'd recommend sticking with that. As for the general case where a placeholder is followed by |
This commit ensures that locations to resources configured via @ContextConfiguration & @TestPropertySource are consistently cleaned using StringUtils.clean(). See gh-23544
This has been fixed in Feel free to try it out in the next 5.2 snapshot build. |
Thanks, great to hear that :) |
Affects: Spring Boot version: 2.1.1.RELEASE with Spring-test version: 5.1.3.RELEASE
I'm trying to add custom path to
application.properties
file for one of my class test with use of@TestPropertySource
like this:And I have an error caused by
FileNotFoundException
which says that it can not find this path:config/application.properties
. When I remove this ".." characters (so i've gotfile:${user.dir}/config/application.properties
), then it gives me this path:/home/pawel/projekty/simulatorserver/server/config/application.properties
, but I want to get to this path:/home/pawel/projekty/simulatorserver/config/application.properties
(without server directory).I did some investigation and I found out that org.springframework.util.StringUtils#cleanPath(String path) removes ${user.dir} from path.
I guess it should first resolve ${user.dir} to path, and then remove one directory from it.
For now I'm satisfied with this solution:
which gives me proper output:
/home/pawel/projekty/simulatorserver/config/application.properties
.Stacktrace:
The text was updated successfully, but these errors were encountered: