39 |
40 |
40 public class TestUnrecognizedVMOptionsHandling { |
41 public class TestUnrecognizedVMOptionsHandling { |
41 |
42 |
42 public static void main(String args[]) throws Exception { |
43 public static void main(String args[]) throws Exception { |
43 // The first two JAVA processes are expected to fail, but with a correct VM option suggestion |
44 // The first two JAVA processes are expected to fail, but with a correct VM option suggestion |
44 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
45 ProcessBuilder pb = GCArguments.createJavaProcessBuilder( |
45 "-XX:+UseDynamicNumberOfGcThreads", |
46 "-XX:+UseDynamicNumberOfGcThreads", |
46 "-version" |
47 "-version" |
47 ); |
48 ); |
48 OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start()); |
49 OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start()); |
49 outputWithError.shouldContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?"); |
50 outputWithError.shouldContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?"); |
50 if (outputWithError.getExitValue() == 0) { |
51 if (outputWithError.getExitValue() == 0) { |
51 throw new RuntimeException("Not expected to get exit value 0"); |
52 throw new RuntimeException("Not expected to get exit value 0"); |
52 } |
53 } |
53 |
54 |
54 pb = ProcessTools.createJavaProcessBuilder( |
55 pb = GCArguments.createJavaProcessBuilder( |
55 "-XX:MaxiumHeapSize=500m", |
56 "-XX:MaxiumHeapSize=500m", |
56 "-version" |
57 "-version" |
57 ); |
58 ); |
58 outputWithError = new OutputAnalyzer(pb.start()); |
59 outputWithError = new OutputAnalyzer(pb.start()); |
59 outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?"); |
60 outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?"); |
60 if (outputWithError.getExitValue() == 0) { |
61 if (outputWithError.getExitValue() == 0) { |
61 throw new RuntimeException("Not expected to get exit value 0"); |
62 throw new RuntimeException("Not expected to get exit value 0"); |
62 } |
63 } |
63 |
64 |
64 // The last JAVA process should run successfully for the purpose of sanity check |
65 // The last JAVA process should run successfully for the purpose of sanity check |
65 pb = ProcessTools.createJavaProcessBuilder( |
66 pb = GCArguments.createJavaProcessBuilder( |
66 "-XX:+UseDynamicNumberOfGCThreads", |
67 "-XX:+UseDynamicNumberOfGCThreads", |
67 "-version" |
68 "-version" |
68 ); |
69 ); |
69 OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start()); |
70 OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start()); |
70 outputWithNoError.shouldNotContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?"); |
71 outputWithNoError.shouldNotContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?"); |