Commits

Michael Heemskerk committed f5e54f7

NONE: Update ProcessBuilderEncodingTest to make it pass on Mac OSX

  • Participants
  • Parent commits 2113dc7

Comments (0)

Files changed (1)

File src/test/java/com/atlassian/utils/process/ProcessBuilderEncodingTest.java

      * http://jira.atlassian.com/browse/CRUC-4793 which provides a workaround for a JVM bug on windows.
      */
     protected EchoResult spawnEcho(String encoding, String... testStrings) throws Exception {
-        List<String> cmd = new ArrayList<String>(Arrays.asList("java", "-Dfile.encoding=" + encoding, CallEcho.class.getName()));
+        List<String> cmd = new ArrayList<String>(Arrays.asList(
+                "java", "-Dfile.encoding=" + encoding, "-Dsun.jnu.encoding=" + encoding, CallEcho.class.getName()));
         cmd.addAll(Arrays.asList(testStrings));
 
         ProcessBuilder processBuilder = new ProcessBuilder(cmd);
         processBuilder.environment().put("CLASSPATH", System.getProperty("java.class.path"));
+        processBuilder.environment().put("LC_ALL", "en_US." + encoding.toUpperCase());
+        processBuilder.environment().put("LANG", "en_US." + encoding.toUpperCase());
         final Process process = processBuilder.start();
 
         Thread th = new Thread(new Runnable() {
 
     @Test
     public void testCommandLineArgumentsWin1252() throws Exception {
-        if (Charset.isSupported("windows-1252") && !isLinux()) {
+        if (Charset.isSupported("windows-1252") && isWindows()) {
             // test is disabled in linux because (ubuntu) linux always uses UTF-8 to encode parameters, causing this test to fail
             EchoResult result = spawnEcho("windows-1252", "iso-8859-1");
             assertEquals("Windows cp 1252 -  incompatibility detected:", result.input, result.output);
 
     @Test
     public void testCommandLineArgumentsIso88591() throws Exception {
-        if (!isLinux()) {
+        if (isWindows()) {
             // test is disabled in linux because (ubuntu) linux always uses UTF-8 to encode parameters, causing this test to fail
             EchoResult result = spawnEcho("iso-8859-1", "iso-8859-1");
             assertEquals("ISO-8859-1 - incompatibility detected:", result.input, result.output);