1 /*
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 */
62
63 @Test
64 public void testSystemModules() {
65 Path jimage = Paths.get(System.getProperty("java.home"), "lib", "modules");
66 if (Files.notExists(jimage))
67 return;
68
69 ModuleFinder.ofSystem().findAll().stream()
70 .forEach(this::checkAttributes);
71 }
72
73 // JMOD files are created with OS name and arch matching the bundle name
74 private boolean checkOSName(String name) {
75 if (OS_NAME.startsWith("Windows")) {
76 return name.equals("windows");
77 }
78
79 switch (OS_NAME) {
80 case "Linux":
81 return name.equals("linux");
82 case "SunOS":
83 return name.equals("solaris");
84 case "Mac OS X":
85 return name.equals("macos");
86 default:
87 // skip validation on unknown platform
88 System.out.println("Skip checking OS name in ModuleTarget: " + name);
89 return true;
90 }
91 }
92
93 private boolean checkOSArch(String name) {
94 if (name.equals(OS_ARCH))
95 return true;
96
97 switch (OS_ARCH) {
98 case "i386":
99 case "x86":
100 return name.equals("x86");
101 case "amd64":
102 case "x86_64":
103 return name.equals("amd64");
|
1 /*
2 * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 */
62
63 @Test
64 public void testSystemModules() {
65 Path jimage = Paths.get(System.getProperty("java.home"), "lib", "modules");
66 if (Files.notExists(jimage))
67 return;
68
69 ModuleFinder.ofSystem().findAll().stream()
70 .forEach(this::checkAttributes);
71 }
72
73 // JMOD files are created with OS name and arch matching the bundle name
74 private boolean checkOSName(String name) {
75 if (OS_NAME.startsWith("Windows")) {
76 return name.equals("windows");
77 }
78
79 switch (OS_NAME) {
80 case "Linux":
81 return name.equals("linux");
82 case "Mac OS X":
83 return name.equals("macos");
84 default:
85 // skip validation on unknown platform
86 System.out.println("Skip checking OS name in ModuleTarget: " + name);
87 return true;
88 }
89 }
90
91 private boolean checkOSArch(String name) {
92 if (name.equals(OS_ARCH))
93 return true;
94
95 switch (OS_ARCH) {
96 case "i386":
97 case "x86":
98 return name.equals("x86");
99 case "amd64":
100 case "x86_64":
101 return name.equals("amd64");
|