80 * However, if the JVM process fails with mapping failure, the string "Hi" will not be in the output, |
80 * However, if the JVM process fails with mapping failure, the string "Hi" will not be in the output, |
81 * and your test case will fail intermittently. |
81 * and your test case will fail intermittently. |
82 * |
82 * |
83 * Instead, the test case should be written as |
83 * Instead, the test case should be written as |
84 * |
84 * |
85 * CCDSTestUtils.run(args).assertNormalExit("Hi"); |
85 * CDSTestUtils.run(args).assertNormalExit("Hi"); |
86 * |
86 * |
87 * EXAMPLES/HOWTO |
87 * EXAMPLES/HOWTO |
88 * |
88 * |
89 * 1. For simple substring matching: |
89 * 1. For simple substring matching: |
90 * |
90 * |
91 * CCDSTestUtils.run(args).assertNormalExit("Hi"); |
91 * CDSTestUtils.run(args).assertNormalExit("Hi"); |
92 * CCDSTestUtils.run(args).assertNormalExit("a", "b", "x"); |
92 * CDSTestUtils.run(args).assertNormalExit("a", "b", "x"); |
93 * CCDSTestUtils.run(args).assertAbnormalExit("failure 1", "failure2"); |
93 * CDSTestUtils.run(args).assertAbnormalExit("failure 1", "failure2"); |
94 * |
94 * |
95 * 2. For more complex output matching: using Lambda expressions |
95 * 2. For more complex output matching: using Lambda expressions |
96 * |
96 * |
97 * CCDSTestUtils.run(args) |
97 * CDSTestUtils.run(args) |
98 * .assertNormalExit(output -> output.shouldNotContain("this should not be printed"); |
98 * .assertNormalExit(output -> output.shouldNotContain("this should not be printed"); |
99 * CCDSTestUtils.run(args) |
99 * CDSTestUtils.run(args) |
100 * .assertAbnormalExit(output -> { |
100 * .assertAbnormalExit(output -> { |
101 * output.shouldNotContain("this should not be printed"); |
101 * output.shouldNotContain("this should not be printed"); |
102 * output.shouldHaveExitValue(123); |
102 * output.shouldHaveExitValue(123); |
103 * }); |
103 * }); |
104 * |
104 * |
105 * 3. Chaining several checks: |
105 * 3. Chaining several checks: |
106 * |
106 * |
107 * CCDSTestUtils.run(args) |
107 * CDSTestUtils.run(args) |
108 * .assertNormalExit(output -> output.shouldNotContain("this should not be printed") |
108 * .assertNormalExit(output -> output.shouldNotContain("this should not be printed") |
109 * .assertNormalExit("should have this", "should have that"); |
109 * .assertNormalExit("should have this", "should have that"); |
110 * |
110 * |
111 * 4. [Rare use case] if a test sometimes exit normally, and sometimes abnormally: |
111 * 4. [Rare use case] if a test sometimes exit normally, and sometimes abnormally: |
112 * |
112 * |
113 * CCDSTestUtils.run(args) |
113 * CDSTestUtils.run(args) |
114 * .ifNormalExit("ths string is printed when exiting with 0") |
114 * .ifNormalExit("ths string is printed when exiting with 0") |
115 * .ifAbNormalExit("ths string is printed when exiting with 1"); |
115 * .ifAbNormalExit("ths string is printed when exiting with 1"); |
116 * |
116 * |
117 * NOTE: you usually don't want to write your test case like this -- it should always |
117 * NOTE: you usually don't want to write your test case like this -- it should always |
118 * exit with the same exit code. (But I kept this API because some existing test cases |
118 * exit with the same exit code. (But I kept this API because some existing test cases |
386 for (String p : opts.prefix) cmd.add(p); |
386 for (String p : opts.prefix) cmd.add(p); |
387 |
387 |
388 cmd.add("-Xshare:" + opts.xShareMode); |
388 cmd.add("-Xshare:" + opts.xShareMode); |
389 cmd.add("-Dtest.timeout.factor=" + TestTimeoutFactor); |
389 cmd.add("-Dtest.timeout.factor=" + TestTimeoutFactor); |
390 |
390 |
391 if (opts.archiveName == null) |
391 if (!opts.useSystemArchive) { |
392 opts.archiveName = getDefaultArchiveName(); |
392 if (opts.archiveName == null) |
393 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); |
393 opts.archiveName = getDefaultArchiveName(); |
|
394 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); |
|
395 } |
394 |
396 |
395 if (opts.useVersion) |
397 if (opts.useVersion) |
396 cmd.add("-version"); |
398 cmd.add("-version"); |
397 |
399 |
398 for (String s : opts.suffix) cmd.add(s); |
400 for (String s : opts.suffix) cmd.add(s); |