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 time for sure.
This commit is contained in:
j2blake 2013-11-20 10:17:27 -05:00
parent b3c5892679
commit b6da0052ce

View file

@ -286,18 +286,20 @@ public class FreemarkerTemplateLoaderTest {
* would. * would.
*/ */
private void assertFM(String searchTerm, int expectedNumberOfTries, private void assertFM(String searchTerm, int expectedNumberOfTries,
String expectedBestFit) { String expectedBestString) {
Path expectedBestFit = expectedBestString == null ? null : Paths
.get(expectedBestString);
PathPieces stPp = new PathPieces(searchTerm); PathPieces stPp = new PathPieces(searchTerm);
int actualNumberOfTries = 0; int actualNumberOfTries = 0;
String actualBestFit = null; Path actualBestFit = null;
if (StringUtils.isNotBlank(stPp.region)) { if (StringUtils.isNotBlank(stPp.region)) {
actualNumberOfTries++; actualNumberOfTries++;
SortedSet<PathPieces> matches = runTheVisitor(stPp.base SortedSet<PathPieces> matches = runTheVisitor(stPp.base
+ stPp.language + stPp.region + stPp.extension); + stPp.language + stPp.region + stPp.extension);
if (!matches.isEmpty()) { if (!matches.isEmpty()) {
actualBestFit = matches.last().path.toString(); actualBestFit = matches.last().path;
} }
} }
if (actualBestFit == null && StringUtils.isNotBlank(stPp.language)) { if (actualBestFit == null && StringUtils.isNotBlank(stPp.language)) {
@ -305,7 +307,7 @@ public class FreemarkerTemplateLoaderTest {
SortedSet<PathPieces> matches = runTheVisitor(stPp.base SortedSet<PathPieces> matches = runTheVisitor(stPp.base
+ stPp.language + stPp.extension); + stPp.language + stPp.extension);
if (!matches.isEmpty()) { if (!matches.isEmpty()) {
actualBestFit = matches.last().path.toString(); actualBestFit = matches.last().path;
} }
} }
if (actualBestFit == null) { if (actualBestFit == null) {
@ -313,7 +315,7 @@ public class FreemarkerTemplateLoaderTest {
SortedSet<PathPieces> matches = runTheVisitor(stPp.base SortedSet<PathPieces> matches = runTheVisitor(stPp.base
+ stPp.extension); + stPp.extension);
if (!matches.isEmpty()) { if (!matches.isEmpty()) {
actualBestFit = matches.last().path.toString(); actualBestFit = matches.last().path;
} }
} }