[
https://issues.apache.org/jira/browse/SANSELAN-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844316#action_12844316
]
James E-J commented on SANSELAN-36:
-----------------------------------
Easy fix- created Replacer.java in Test packages under org.apache.sanselan :
package org.apache.sanselan;
public class Replacer {
public static String replaceSlashes(String input){
String seperator = System.getProperty("file.separator");
if(!seperator.equals("\\"))
return input.replaceAll("\\\\",seperator);
else return input;
}
}
And then changed following three lines of code:
PngMultipleRoundtripTest.java line 38 becomes-
String imagesFolderPath =
Replacer.replaceSlashes("src\\test\\data\\images\\png\\3");
instead of: String imagesFolderPath =
"src\\test\\data\\images\\png\\3".replaceAll("\\\\",
System.getProperty("file.separator"));
and needs a new import: "import org.apache.sanselan.Replacer;"
SanselanTestConstants.java line 25/26 becomes:
Replacer.replaceSlashes("src\\test\\data\\images\\exif\\philHarvey\\"));
instead of:
"src\\test\\data\\images\\exif\\philHarvey\\".replaceAll("\\\\", System
.getProperty("file.separator")));
SanselanGuessFormatTest.java line 66/67 becomes:
imagePath = Replacer.replaceSlashes(imagePath);
instead of:
imagePath = imagePath.replaceAll("\\\\", System
.getProperty("file.separator"));
Now passes tests with following results:
Results :
Tests run: 47, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: D:\Users\Student\Documents\NetBeansProjects\commons-sansela
n\target\commons-sanselan-0.98-SNAPSHOT.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing D:\Users\Student\Documents\NetBeansProjects\commons-sanselan\t
arget\commons-sanselan-0.98-SNAPSHOT.jar to D:\Users\Student\.m2\repository\org\
apache\commons\commons-sanselan\0.98-SNAPSHOT\commons-sanselan-0.98-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 13 seconds
[INFO] Finished at: Fri Mar 12 01:08:05 GMT 2010
[INFO] Final Memory: 26M/63M
[INFO] ------------------------------------------------------------------------
> Sanselan tests fail on Windows
> ------------------------------
>
> Key: SANSELAN-36
> URL: https://issues.apache.org/jira/browse/SANSELAN-36
> Project: Commons Sanselan
> Issue Type: Test
> Reporter: Niall Pemberton
> Priority: Minor
>
> A number of the Sanselan tests fail on windows - all related to the use of
> the following code with file paths:
> {code}
> "...".replaceAll("\\\\", System.getProperty("file.separator")
> {code}
> The problem is on windows the file separator is a "back slash" character
> which needs to be escaped in regular expressions.
> This affects:
> * SanselanTestConstants (causes ExceptionIntializedError because the
> static PHIL_HARVEY_TEST_IMAGE_FOLDER fails when its being initialized with a
> StringIndexOutOfBoundsException)
> * SanselanGuessFormatTest fails in testGuess_all() and
> testGuess_unknown() throwing StringIndexOutOfBoundsException
> * PngMultipleRoundtripTest fails in test() throwing
> StringIndexOutOfBoundsException
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.