Path: blob/master/test/jdk/tools/jlink/JLinkOptionsTest.java
41144 views
/*1* Copyright (c) 2015, 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*/22import java.util.ArrayList;23import java.util.List;24import java.util.Map;25import java.util.Set;26import jdk.tools.jlink.plugin.ResourcePool;27import jdk.tools.jlink.plugin.ResourcePoolBuilder;28import jdk.tools.jlink.internal.PluginRepository;29import jdk.tools.jlink.plugin.Plugin;3031import tests.Helper;3233/*34* @test35* @summary Test jlink options36* @author Jean-Francois Denise37* @library ../lib38* @modules java.base/jdk.internal.jimage39* jdk.jdeps/com.sun.tools.classfile40* jdk.jlink/jdk.tools.jlink.internal41* jdk.jlink/jdk.tools.jlink.plugin42* jdk.jlink/jdk.tools.jmod43* jdk.jlink/jdk.tools.jimage44* jdk.compiler45* @build tests.*46* @run main JLinkOptionsTest47*/48public class JLinkOptionsTest {4950private static class TestPlugin implements Plugin {51private final String name;52private final String option;5354private TestPlugin(String name, String option) {55this.name = name;56this.option = option;57}585960@Override61public String getOption() {62return option;63}6465@Override66public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {67return out.build();68}6970@Override71public String getName() {72return name;73}7475@Override76public String getDescription() {77return name;78}79}8081public static void main(String[] args) throws Exception {82Helper helper = Helper.newHelper();83if (helper == null) {84System.err.println("Test not run");85return;86}87helper.generateDefaultModules();88{89// multiple plugins with same option9091PluginRepository.92registerPlugin(new TestPlugin("test1", "test1"));93PluginRepository.94registerPlugin(new TestPlugin("test2", "test1"));95helper.generateDefaultImage("composite2").assertFailure("Error: More than one plugin enabled by test1 option");96PluginRepository.unregisterPlugin("test1");97PluginRepository.unregisterPlugin("test2");98}99}100}101102103