[jira] Created: (SANSELAN-36) Sanselan tests fail on Windows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (SANSELAN-36) Sanselan tests fail on Windows

Gary D. Gregory (Jira)
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.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (SANSELAN-36) Sanselan tests fail on Windows

Gary D. Gregory (Jira)

    [ https://issues.apache.org/jira/browse/SANSELAN-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844299#action_12844299 ]

James E-J commented on SANSELAN-36:
-----------------------------------

Also had this problem- tests failed due to
Had to ignore the tests using mvn -Dmaven.test.skip=true install

Error was:
Running org.apache.sanselan.formats.jpeg.exif.GpsTest
org.apache.maven.surefire.booter.SurefireExecutionException: org.apache.sanselan
.formats.jpeg.exif.GpsTest; nested exception is java.lang.ExceptionInInitializer
Error: null; nested exception is org.apache.maven.surefire.testset.TestSetFailed
Exception: org.apache.sanselan.formats.jpeg.exif.GpsTest; nested exception is ja
va.lang.ExceptionInInitializerError: null
org.apache.maven.surefire.testset.TestSetFailedException: org.apache.sanselan.fo
rmats.jpeg.exif.GpsTest; nested exception is java.lang.ExceptionInInitializerErr
or: null
java.lang.ExceptionInInitializerError
        at org.apache.sanselan.SanselanTest.<clinit>(SanselanTest.java:99)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
......................
....................... Long stack trace
.......................
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:
 1
        at java.lang.String.charAt(String.java:686)
        at java.util.regex.Matcher.appendReplacement(Matcher.java:703)
        at java.util.regex.Matcher.replaceAll(Matcher.java:813)
        at java.lang.String.replaceAll(String.java:2189)
        at org.apache.sanselan.SanselanTestConstants.<clinit>(SanselanTestConsta
nts.java:24)
        ... 23 more

> 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.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (SANSELAN-36) Sanselan tests fail on Windows

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

    [ 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.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (SANSELAN-36) Sanselan tests fail on Windows

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/SANSELAN-36?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved SANSELAN-36.
-------------------------------------

    Resolution: Fixed

I have fixed this by adding a *test* dependency to commons-io and use FilenameUtils.separatorsToSystem() to convert the paths:

    http://svn.apache.org/viewvc?view=revision&revision=922115

> 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.