Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When I run the tests for exec using 'mvn test' I get the following error.
junit.framework.AssertionFailedError: Arrays not equal
at org.apache.commons.exec.CommandLineTest.assertEquals(CommandLineTest.java:31)
at org.apache.commons.exec.CommandLineTest.testCommandLineParsingWithExpansion2(CommandLineTest.java:320)
As far as I can tell there are two problems with the code:
1. The test cases need to take into account that there are different file separators on Windows and Unix.
That's easy enough to fix. I just added this
private String replaceFileSeparator(String input) { return input.replace('/', File.separatorChar).replace('\\', File.separatorChar); }
and wrapped the first element of the "expected" String arrays with it.
2. Variable substitution isn't performed correctly.
After adding the above I got test failures on Unix. I debugged the test case and found out that the value of the command line executable was this: " C:\Programme\jdk1.5.0_12/bin/java". This suggests to me that variable substitution is performed after CommandLine.setExecutable(String) is performed, resulting in an executable with possibly wrong file separators.