< prev index next >

test/jdk/demo/jfc/J2Ddemo/J2DdemoTest.java

Print this page




  22  */
  23 
  24 /* @test
  25  * @key headful
  26  * @summary Test J2Ddemo.jar
  27  * @run main/timeout=200 J2DdemoTest
  28  */
  29 
  30 import java.io.InputStream;
  31 import java.io.IOException;
  32 import java.io.File;
  33 import java.io.BufferedInputStream;
  34 import java.io.PrintStream;
  35 
  36 public class J2DdemoTest {
  37 
  38     public static void main(String args[]) throws Exception {
  39         DemoRun test;
  40 
  41         /* Run the J2Ddemo.jar with the -runs=1 option */
  42         test = new DemoRun("jfc/J2Ddemo/J2Ddemo.jar", "-runs=1");
  43         test.runit();
  44 
  45         /* Make sure patterns in output look ok */
  46         if (test.output_contains("ERROR")) {
  47             throw new RuntimeException("Test failed - ERROR seen in output");
  48         }
  49         if (test.output_contains("Exception")) {
  50             throw new RuntimeException("Test failed - Exception seen in output");
  51         }
  52 
  53         /* Must be a pass. */
  54         System.out.println("Test passed - cleanly terminated");
  55     }
  56 
  57     /*
  58      * Helper class to direct process output to a StringBuffer
  59      */
  60     static class MyInputStream implements Runnable {
  61         private String              name;
  62         private BufferedInputStream in;


 141                 vm_opts = vopts.split("\\p{Space}+");
 142             } else {
 143                 vm_opts = new String[0];
 144             }
 145 
 146             /* Command line */
 147             String cmd[] = new String[1 + vm_opts.length + 3];
 148             String cmdLine;
 149             int i;
 150 
 151             i = 0;
 152             cmdLine = "";
 153             cmdLine += (cmd[i++] = java);
 154             cmdLine += " ";
 155             for ( String vopt : vm_opts ) {
 156                 cmdLine += (cmd[i++] = vopt);
 157                 cmdLine += " ";
 158             }
 159             cmdLine += (cmd[i++] = "-jar");
 160             cmdLine += " ";
 161             String demo_path;
 162             String test_dir = System.getenv("TEST_IMAGE_DIR");
 163             System.out.println("TEST_IMAGE_DIR="+test_dir);
 164             if (test_dir != null) {
 165                 demo_path = test_dir + File.separator + "jdk" + File.separator +
 166                             "demos" + File.separator + demo_name;
 167             } else {
 168                 demo_path = sdk_home + File.separator +
 169                             "demo" + File.separator + demo_name;
 170             }
 171             System.out.println("demo_path="+demo_path);
 172             cmdLine += cmd[i++] = demo_path;
 173             cmdLine += " ";
 174             cmdLine += (cmd[i++] = demo_options);
 175 
 176             /* Begin process */
 177             Process p;
 178 
 179             System.out.println("Starting: " + cmdLine);
 180             try {
 181                 p = Runtime.getRuntime().exec(cmd);
 182             } catch ( IOException e ) {
 183                 throw new RuntimeException("Test failed - exec got IO exception");
 184             }
 185 
 186             /* Save process output in StringBuffers */
 187             output = new MyInputStream("Input Stream", p.getInputStream());
 188             error  = new MyInputStream("Error Stream", p.getErrorStream());
 189 
 190             /* Wait for process to complete, and if exit code is non-zero we fail */
 191             int exitStatus;
 192             try {




  22  */
  23 
  24 /* @test
  25  * @key headful
  26  * @summary Test J2Ddemo.jar
  27  * @run main/timeout=200 J2DdemoTest
  28  */
  29 
  30 import java.io.InputStream;
  31 import java.io.IOException;
  32 import java.io.File;
  33 import java.io.BufferedInputStream;
  34 import java.io.PrintStream;
  35 
  36 public class J2DdemoTest {
  37 
  38     public static void main(String args[]) throws Exception {
  39         DemoRun test;
  40 
  41         /* Run the J2Ddemo.jar with the -runs=1 option */
  42         test = new DemoRun("demo/jfc/J2Ddemo/J2Ddemo.jar", "-runs=1");
  43         test.runit();
  44 
  45         /* Make sure patterns in output look ok */
  46         if (test.output_contains("ERROR")) {
  47             throw new RuntimeException("Test failed - ERROR seen in output");
  48         }
  49         if (test.output_contains("Exception")) {
  50             throw new RuntimeException("Test failed - Exception seen in output");
  51         }
  52 
  53         /* Must be a pass. */
  54         System.out.println("Test passed - cleanly terminated");
  55     }
  56 
  57     /*
  58      * Helper class to direct process output to a StringBuffer
  59      */
  60     static class MyInputStream implements Runnable {
  61         private String              name;
  62         private BufferedInputStream in;


 141                 vm_opts = vopts.split("\\p{Space}+");
 142             } else {
 143                 vm_opts = new String[0];
 144             }
 145 
 146             /* Command line */
 147             String cmd[] = new String[1 + vm_opts.length + 3];
 148             String cmdLine;
 149             int i;
 150 
 151             i = 0;
 152             cmdLine = "";
 153             cmdLine += (cmd[i++] = java);
 154             cmdLine += " ";
 155             for ( String vopt : vm_opts ) {
 156                 cmdLine += (cmd[i++] = vopt);
 157                 cmdLine += " ";
 158             }
 159             cmdLine += (cmd[i++] = "-jar");
 160             cmdLine += " ";
 161             cmdLine += (cmd[i++] = sdk_home + File.separator + demo_name);











 162             cmdLine += " ";
 163             cmdLine += (cmd[i++] = demo_options);
 164 
 165             /* Begin process */
 166             Process p;
 167 
 168             System.out.println("Starting: " + cmdLine);
 169             try {
 170                 p = Runtime.getRuntime().exec(cmd);
 171             } catch ( IOException e ) {
 172                 throw new RuntimeException("Test failed - exec got IO exception");
 173             }
 174 
 175             /* Save process output in StringBuffers */
 176             output = new MyInputStream("Input Stream", p.getInputStream());
 177             error  = new MyInputStream("Error Stream", p.getErrorStream());
 178 
 179             /* Wait for process to complete, and if exit code is non-zero we fail */
 180             int exitStatus;
 181             try {


< prev index next >