Fix the failed test due to hardcoded file separators#2366
Fix the failed test due to hardcoded file separators#2366bnasslahsen merged 1 commit intospringdoc:mainfrom wnineg:path-separator-fix
Conversation
|
I stumbled upon the same issue; maybe we can, at the same time, avoid using hardcoded "version" in the expected String, e.g.? |
|
Yeah...I knew I could go a little bit fancier using Now since you mentioned it, instead of using assertEquals(Paths.get("swagger-ui" ,"4.18.2" ,"swagger-initializer.js").toString(), actual);Additionally, I went back to see if I could clean it up more. So the method that constructs the
I can further clean up the logic there by utilizing |
|
So, as my last comment mentioned, the implementation of protected String findWebJarResourcePath(String pathStr) {
Path path = Paths.get(pathStr);
if (path.getNameCount() < 2) return null;
String version = swaggerUiConfigProperties.getVersion();
if (version == null) return null;
Path first = path.getName(0);
Path rest = path.subpath(1, path.getNameCount());
return first.resolve(version).resolve(rest).toString();
}Which eliminates the only references to the private methods |
|
Thank you, @wnineg, for your answer. I agree. I created a "fix" before I saw that you had already done it, so I just compared/commented solutions, also without going into details. |
Fix the failed test due to hardcoded file separators
This specific test fails under Windows: the
actualpath utilizedFile.separatorbut not the expected one.