Path: blob/master/test/jdk/tools/jlink/JLinkPluginsTest.java
41144 views
/*1* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.IOException;24import java.nio.file.Files;25import java.nio.file.Path;26import java.nio.file.Paths;27import java.util.Collections;2829import tests.Helper;3031/*32* @test33* @summary Test image creation34* @author Jean-Francois Denise35* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)36* @library ../lib37* @modules java.base/jdk.internal.jimage38* jdk.jdeps/com.sun.tools.classfile39* jdk.jlink/jdk.tools.jlink.internal40* jdk.jlink/jdk.tools.jmod41* jdk.jlink/jdk.tools.jimage42* jdk.compiler43* @build tests.*44* @run main/othervm -verbose:gc -Xmx1g JLinkPluginsTest45*/46public class JLinkPluginsTest {4748private static String createProperties(String fileName, String content) throws IOException {49Path p = Paths.get(fileName);50Files.write(p, Collections.singletonList(content));51return p.toAbsolutePath().toString();52}5354public static void main(String[] args) throws Exception {55Helper helper = Helper.newHelper();56if (helper == null) {57System.err.println("Test not run");58return;59}60helper.generateDefaultModules();61{62// Skip debug63String[] userOptions = {"--strip-debug"};64String moduleName = "skipdebugcomposite";65helper.generateDefaultJModule(moduleName, "composite2");66Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();67helper.checkImage(imageDir, moduleName, null, null);68}69{70// Filter out files71String[] userOptions = {"--exclude-resources", "*.jcov, */META-INF/*"};72String moduleName = "excludecomposite";73helper.generateDefaultJModule(moduleName, "composite2");74String[] res = {".jcov", "/META-INF/"};75Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();76helper.checkImage(imageDir, moduleName, res, null);77}78{79// disable generate jli classes - JDK-816006380String[] userOptions = {"--disable-plugin", "generate-jli-classes"};81String moduleName = "jlidisabled";82helper.generateDefaultJModule(moduleName, "composite2");83Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();84helper.checkImage(imageDir, moduleName, null, null);85}86{87// disable invalid plugin - JDK-816006388String[] userOptions = {"--disable-plugin", "non-existent-plugin"};89String moduleName = "invaliddisabled";90helper.generateDefaultJModule(moduleName, "composite2");91helper.generateDefaultImage(userOptions, moduleName).92assertFailure("Error: No such plugin: non-existent-plugin");93}94}95}969798