jdk/test/java/lang/ProcessBuilder/Basic.java
changeset 9500 268f823d9e1c
parent 9035 1255eb81cc2f
child 10347 1c9efe1ec7d3
equal deleted inserted replaced
9497:f08c52fe9fc7 9500:268f823d9e1c
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
    26  * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
    27  *      5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
    27  *      5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
    28  *      6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
    28  *      6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
    29  *      4947220 7018606
    29  *      4947220 7018606 7034570
    30  * @summary Basic tests for Process and Environment Variable code
    30  * @summary Basic tests for Process and Environment Variable code
    31  * @run main/othervm/timeout=300 Basic
    31  * @run main/othervm/timeout=300 Basic
    32  * @author Martin Buchholz
    32  * @author Martin Buchholz
    33  */
    33  */
    34 
    34 
  1438         //----------------------------------------------------------------
  1438         //----------------------------------------------------------------
  1439         // Test Runtime.exec(...envp...)
  1439         // Test Runtime.exec(...envp...)
  1440         // Check for sort order of environment variables on Windows.
  1440         // Check for sort order of environment variables on Windows.
  1441         //----------------------------------------------------------------
  1441         //----------------------------------------------------------------
  1442         try {
  1442         try {
       
  1443             String systemRoot = "SystemRoot=" + System.getenv("SystemRoot");
  1443             // '+' < 'A' < 'Z' < '_' < 'a' < 'z' < '~'
  1444             // '+' < 'A' < 'Z' < '_' < 'a' < 'z' < '~'
  1444             String[]envp = {"FOO=BAR","BAZ=GORP","QUUX=",
  1445             String[]envp = {"FOO=BAR","BAZ=GORP","QUUX=",
  1445                             "+=+", "_=_", "~=~"};
  1446                             "+=+", "_=_", "~=~", systemRoot};
  1446             String output = nativeEnv(envp);
  1447             String output = nativeEnv(envp);
  1447             String expected = "+=+\nBAZ=GORP\nFOO=BAR\nQUUX=\n_=_\n~=~\n";
  1448             String expected = "+=+\nBAZ=GORP\nFOO=BAR\nQUUX=\n"+systemRoot+"\n_=_\n~=~\n";
  1448             // On Windows, Java must keep the environment sorted.
  1449             // On Windows, Java must keep the environment sorted.
  1449             // Order is random on Unix, so this test does the sort.
  1450             // Order is random on Unix, so this test does the sort.
  1450             if (! Windows.is())
  1451             if (! Windows.is())
  1451                 output = sortByLinesWindowsly(output);
  1452                 output = sortByLinesWindowsly(output);
  1452             equal(output, expected);
  1453             equal(output, expected);
       
  1454         } catch (Throwable t) { unexpected(t); }
       
  1455 
       
  1456         //----------------------------------------------------------------
       
  1457         // Test Runtime.exec(...envp...)
       
  1458         // and check SystemRoot gets set automatically on Windows
       
  1459         //----------------------------------------------------------------
       
  1460         try {
       
  1461             if (Windows.is()) {
       
  1462                 String systemRoot = "SystemRoot=" + System.getenv("SystemRoot");
       
  1463                 String[]envp = {"FOO=BAR","BAZ=GORP","QUUX=",
       
  1464                                 "+=+", "_=_", "~=~"};
       
  1465                 String output = nativeEnv(envp);
       
  1466                 String expected = "+=+\nBAZ=GORP\nFOO=BAR\nQUUX=\n"+systemRoot+"\n_=_\n~=~\n";
       
  1467                 equal(output, expected);
       
  1468             }
  1453         } catch (Throwable t) { unexpected(t); }
  1469         } catch (Throwable t) { unexpected(t); }
  1454 
  1470 
  1455         //----------------------------------------------------------------
  1471         //----------------------------------------------------------------
  1456         // System.getenv() must be consistent with System.getenv(String)
  1472         // System.getenv() must be consistent with System.getenv(String)
  1457         //----------------------------------------------------------------
  1473         //----------------------------------------------------------------