1 /* |
1 /* |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 import jdk.test.lib.process.OutputAnalyzer; |
33 import jdk.test.lib.process.OutputAnalyzer; |
34 import jdk.test.lib.process.ProcessTools; |
34 import jdk.test.lib.process.ProcessTools; |
35 |
35 |
36 public class ModulesTest { |
36 public class ModulesTest { |
37 public static void main(String[] args) throws Exception { |
37 public static void main(String[] args) throws Exception { |
38 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
38 testModuleTrace("-Xlog:module=trace", "-version"); |
39 "-Xlog:modules=trace", "-version"); |
39 testModuleLoad("-Xlog:module+load", "-version"); |
40 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
40 testModuleUnload("-Xlog:module+unload", "-version"); |
|
41 |
|
42 // same as -Xlog:module+load -Xlog:module+unload |
|
43 testModuleLoad("-verbose:module", "-version"); |
|
44 } |
|
45 |
|
46 static void testModuleTrace(String... args) throws Exception { |
|
47 OutputAnalyzer output = run(args); |
41 output.shouldContain("define_javabase_module(): Definition of module:"); |
48 output.shouldContain("define_javabase_module(): Definition of module:"); |
42 output.shouldContain("define_javabase_module(): creation of package"); |
49 output.shouldContain("define_javabase_module(): creation of package"); |
43 output.shouldContain("define_module(): creation of module"); |
50 output.shouldContain("define_module(): creation of module"); |
44 output.shouldContain("define_module(): creation of package"); |
51 output.shouldContain("define_module(): creation of package"); |
45 output.shouldContain("set_bootloader_unnamed_module(): recording unnamed"); |
52 output.shouldContain("set_bootloader_unnamed_module(): recording unnamed"); |
46 output.shouldContain("add_module_exports(): package"); |
53 output.shouldContain("add_module_exports(): package"); |
47 output.shouldContain("add_reads_module(): Adding read from module"); |
54 output.shouldContain("add_reads_module(): Adding read from module"); |
48 output.shouldContain("Setting package: class:"); |
55 output.shouldContain("Setting package: class:"); |
49 output.shouldHaveExitValue(0); |
56 output.shouldHaveExitValue(0); |
50 } |
57 } |
|
58 |
|
59 static void testModuleLoad(String... args) throws Exception { |
|
60 OutputAnalyzer output = run(args); |
|
61 output.shouldContain("java.base location:"); |
|
62 output.shouldContain("java.management location:"); |
|
63 output.shouldHaveExitValue(0); |
|
64 } |
|
65 |
|
66 static void testModuleUnload(String... args) throws Exception { |
|
67 OutputAnalyzer output = run(args); |
|
68 output.shouldHaveExitValue(0); |
|
69 } |
|
70 |
|
71 static OutputAnalyzer run(String... args) throws Exception { |
|
72 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); |
|
73 return new OutputAnalyzer(pb.start()); |
|
74 } |
51 } |
75 } |
52 |
76 |