VIVO-548 Make unit tests independent of file separator characters.
By converting Strings to Paths before comparing, we should get consistent usage of “/“ and “\”
This commit is contained in:
parent
30fa123948
commit
5bb8a4c698
1 changed files with 6 additions and 7 deletions
|
@ -266,20 +266,19 @@ public class FreemarkerTemplateLoaderTest {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void assertMatches(String searchTerm, int expectedHowMany,
|
private void assertMatches(String searchTerm, int expectedHowMany,
|
||||||
String expectedBestFit) {
|
String expectedBestFitString) {
|
||||||
|
Path expectedBestFit = (expectedBestFitString == null) ? null : Paths
|
||||||
|
.get(expectedBestFitString);
|
||||||
|
|
||||||
SortedSet<PathPieces> matches = runTheVisitor(searchTerm);
|
SortedSet<PathPieces> matches = runTheVisitor(searchTerm);
|
||||||
int actualHowMany = matches.size();
|
int actualHowMany = matches.size();
|
||||||
String actualBestFit = matches.isEmpty() ? null : matches.last().path
|
Path actualBestFit = matches.isEmpty() ? null : matches.last().path;
|
||||||
.toString();
|
|
||||||
|
|
||||||
if (expectedHowMany != actualHowMany) {
|
if (expectedHowMany != actualHowMany) {
|
||||||
fail("How many results: expected " + expectedHowMany
|
fail("How many results: expected " + expectedHowMany
|
||||||
+ ", but was " + actualHowMany + ": " + matches);
|
+ ", but was " + actualHowMany + ": " + matches);
|
||||||
}
|
}
|
||||||
if (!StringUtils.equals(expectedBestFit, actualBestFit)) {
|
assertEquals("Best result", expectedBestFit, actualBestFit);
|
||||||
fail("Best result: expected '" + expectedBestFit + "', but was '"
|
|
||||||
+ actualBestFit + "': " + matches);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue