jdk/test/java/lang/ProcessBuilder/Basic.java
changeset 20191 f0e23e7272d6
parent 19399 e2e5122cd62e
child 21813 f7e97f5bb5a2
child 22597 7515a991bb37
equal deleted inserted replaced
20190:15c72885e3fd 20191:f0e23e7272d6
   296                     System.exit(5);
   296                     System.exit(5);
   297                 if (! new String(buf,0,n).equals(expected))
   297                 if (! new String(buf,0,n).equals(expected))
   298                     System.exit(5);
   298                     System.exit(5);
   299                 System.err.print("standard error");
   299                 System.err.print("standard error");
   300                 System.out.print("standard output");
   300                 System.out.print("standard output");
   301             } else if (action.equals("testInheritIO")) {
   301             } else if (action.equals("testInheritIO")
       
   302                     || action.equals("testRedirectInherit")) {
   302                 List<String> childArgs = new ArrayList<String>(javaChildArgs);
   303                 List<String> childArgs = new ArrayList<String>(javaChildArgs);
   303                 childArgs.add("testIO");
   304                 childArgs.add("testIO");
   304                 ProcessBuilder pb = new ProcessBuilder(childArgs);
   305                 ProcessBuilder pb = new ProcessBuilder(childArgs);
   305                 pb.inheritIO();
   306                 if (action.equals("testInheritIO"))
       
   307                     pb.inheritIO();
       
   308                 else
       
   309                     redirectIO(pb, INHERIT, INHERIT, INHERIT);
   306                 ProcessResults r = run(pb);
   310                 ProcessResults r = run(pb);
   307                 if (! r.out().equals(""))
   311                 if (! r.out().equals(""))
   308                     System.exit(7);
   312                     System.exit(7);
   309                 if (! r.err().equals(""))
   313                 if (! r.err().equals(""))
   310                     System.exit(8);
   314                     System.exit(8);
  1017         //----------------------------------------------------------------
  1021         //----------------------------------------------------------------
  1018         // Testing INHERIT is harder.
  1022         // Testing INHERIT is harder.
  1019         // Note that this requires __FOUR__ nested JVMs involved in one test,
  1023         // Note that this requires __FOUR__ nested JVMs involved in one test,
  1020         // if you count the harness JVM.
  1024         // if you count the harness JVM.
  1021         //----------------------------------------------------------------
  1025         //----------------------------------------------------------------
  1022         {
  1026         for (String testName : new String[] { "testInheritIO", "testRedirectInherit" } ) {
  1023             redirectIO(pb, PIPE, PIPE, PIPE);
  1027             redirectIO(pb, PIPE, PIPE, PIPE);
  1024             List<String> command = pb.command();
  1028             List<String> command = pb.command();
  1025             command.set(command.size() - 1, "testInheritIO");
  1029             command.set(command.size() - 1, testName);
  1026             Process p = pb.start();
  1030             Process p = pb.start();
  1027             new PrintStream(p.getOutputStream()).print("standard input");
  1031             new PrintStream(p.getOutputStream()).print("standard input");
  1028             p.getOutputStream().close();
  1032             p.getOutputStream().close();
  1029             ProcessResults r = run(p);
  1033             ProcessResults r = run(p);
  1030             equal(r.exitValue(), 0);
  1034             equal(r.exitValue(), 0);