6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8003562 8005428 8015912 8027481 8048063
27 * @summary Basic tests for jdeps tool
28 * @build Test p.Foo p.Bar javax.activity.NotCompactProfile
29 * @run main Basic
30 */
31
32 import java.io.File;
33 import java.io.IOException;
34 import java.io.PrintWriter;
35 import java.io.StringWriter;
36 import java.nio.file.Files;
37 import java.nio.file.Path;
38 import java.nio.file.Paths;
39 import java.util.*;
40 import java.util.regex.*;
41 import static java.nio.file.StandardCopyOption.*;
42
43 public class Basic {
44 private static boolean symbolFileExist = initProfiles();
45 private static boolean initProfiles() {
46 // check if ct.sym exists; if not use the profiles.properties file
47 Path home = Paths.get(System.getProperty("java.home"));
48 if (home.endsWith("jre")) {
93 new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"});
94 // test -filter:archive option
95 test(new File(testDir, "p"),
96 new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"},
97 new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"},
98 new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"});
99 // test -p option
100 test(new File(testDir, "Test.class"),
101 new String[] {"p.Foo", "p.Bar"},
102 new String[] {"not found", "not found"},
103 new String[] {"-verbose:class", "-p", "p"});
104 // test -e option
105 test(new File(testDir, "Test.class"),
106 new String[] {"p.Foo", "p.Bar"},
107 new String[] {"not found", "not found"},
108 new String[] {"-verbose:class", "-e", "p\\..*"});
109 test(new File(testDir, "Test.class"),
110 new String[] {"java.lang"},
111 new String[] {"compact1"},
112 new String[] {"-verbose:package", "-e", "java\\.lang\\..*"});
113
114 // test -classpath and -include options
115 test(null,
116 new String[] {"java.lang", "java.util", "java.lang.management",
117 "javax.activity", "javax.crypto"},
118 new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"},
119 new String[] {"-classpath", testDir.getPath(), "-include", "p.+|Test.class"});
120 test(new File(testDir, "Test.class"),
121 new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"},
122 new String[] {"compact1", "compact1", testDir.getName(), testDir.getName()},
123 new String[] {"-v", "-classpath", testDir.getPath(), "Test.class"});
124
125 // split package p - move p/Foo.class to dir1 and p/Bar.class to dir2
126 Path testClassPath = testDir.toPath();
127 Path dirP = testClassPath.resolve("p");
128 Path dir1 = testClassPath.resolve("dir1");
129 Path subdir1P = dir1.resolve("p");
130 Path dir2 = testClassPath.resolve("dir2");
131 Path subdir2P = dir2.resolve("p");
132 if (!Files.exists(subdir1P))
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8003562 8005428 8015912 8027481 8048063 8068937
27 * @summary Basic tests for jdeps tool
28 * @build Test p.Foo p.Bar p.C p.SubClass q.Gee javax.activity.NotCompactProfile
29 * @run main Basic
30 */
31
32 import java.io.File;
33 import java.io.IOException;
34 import java.io.PrintWriter;
35 import java.io.StringWriter;
36 import java.nio.file.Files;
37 import java.nio.file.Path;
38 import java.nio.file.Paths;
39 import java.util.*;
40 import java.util.regex.*;
41 import static java.nio.file.StandardCopyOption.*;
42
43 public class Basic {
44 private static boolean symbolFileExist = initProfiles();
45 private static boolean initProfiles() {
46 // check if ct.sym exists; if not use the profiles.properties file
47 Path home = Paths.get(System.getProperty("java.home"));
48 if (home.endsWith("jre")) {
93 new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"});
94 // test -filter:archive option
95 test(new File(testDir, "p"),
96 new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"},
97 new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"},
98 new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"});
99 // test -p option
100 test(new File(testDir, "Test.class"),
101 new String[] {"p.Foo", "p.Bar"},
102 new String[] {"not found", "not found"},
103 new String[] {"-verbose:class", "-p", "p"});
104 // test -e option
105 test(new File(testDir, "Test.class"),
106 new String[] {"p.Foo", "p.Bar"},
107 new String[] {"not found", "not found"},
108 new String[] {"-verbose:class", "-e", "p\\..*"});
109 test(new File(testDir, "Test.class"),
110 new String[] {"java.lang"},
111 new String[] {"compact1"},
112 new String[] {"-verbose:package", "-e", "java\\.lang\\..*"});
113
114 // parse p.C, p.SubClass and q.*
115 // p.SubClass have no dependency other than p.C
116 // q.Gee depends on p.SubClass that should be found
117 test(testDir,
118 new String[] {"java.lang", "p"},
119 new String[] {"compact1", testDir.getName()},
120 new String[] {"-include", "p.C|p.SubClass|q\\..*"});
121 test(testDir,
122 new String[] {"java.lang", "p"},
123 new String[] {"compact1", testDir.getName()},
124 new String[] {"-classpath", testDir.getPath(), "-include", "p.C|p.SubClass|q\\..*"});
125
126
127 // test -classpath and -include options
128 test(null,
129 new String[] {"java.lang", "java.util", "java.lang.management",
130 "javax.activity", "javax.crypto"},
131 new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"},
132 new String[] {"-classpath", testDir.getPath(), "-include", "p.+|Test.class"});
133 test(new File(testDir, "Test.class"),
134 new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"},
135 new String[] {"compact1", "compact1", testDir.getName(), testDir.getName()},
136 new String[] {"-v", "-classpath", testDir.getPath(), "Test.class"});
137
138 // split package p - move p/Foo.class to dir1 and p/Bar.class to dir2
139 Path testClassPath = testDir.toPath();
140 Path dirP = testClassPath.resolve("p");
141 Path dir1 = testClassPath.resolve("dir1");
142 Path subdir1P = dir1.resolve("p");
143 Path dir2 = testClassPath.resolve("dir2");
144 Path subdir2P = dir2.resolve("p");
145 if (!Files.exists(subdir1P))
|