jdk/test/tools/jlink/plugins/PluginsNegativeTest.java
changeset 44545 83b611b88ac8
parent 43185 d75d9ff8d4e7
equal deleted inserted replaced
44480:2c33418a6d57 44545:83b611b88ac8
    28  * @modules jdk.jlink/jdk.tools.jlink
    28  * @modules jdk.jlink/jdk.tools.jlink
    29  *          jdk.jlink/jdk.tools.jlink.internal
    29  *          jdk.jlink/jdk.tools.jlink.internal
    30  *          jdk.jlink/jdk.tools.jlink.plugin
    30  *          jdk.jlink/jdk.tools.jlink.plugin
    31  * @run main/othervm PluginsNegativeTest
    31  * @run main/othervm PluginsNegativeTest
    32  */
    32  */
    33 import java.lang.reflect.Layer;
       
    34 import java.util.ArrayList;
    33 import java.util.ArrayList;
    35 import java.util.Collections;
    34 import java.util.Collections;
    36 import java.util.List;
    35 import java.util.List;
    37 import java.util.Map;
    36 import java.util.Map;
    38 
    37 
    61         testEmptyOutputResource();
    60         testEmptyOutputResource();
    62     }
    61     }
    63 
    62 
    64     private void testDuplicateBuiltInProviders() {
    63     private void testDuplicateBuiltInProviders() {
    65         List<Plugin> javaPlugins = new ArrayList<>();
    64         List<Plugin> javaPlugins = new ArrayList<>();
    66         javaPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
    65         javaPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot()));
    67         for (Plugin javaPlugin : javaPlugins) {
    66         for (Plugin javaPlugin : javaPlugins) {
    68             System.out.println("Registered plugin: " + javaPlugin.getName());
    67             System.out.println("Registered plugin: " + javaPlugin.getName());
    69         }
    68         }
    70         for (Plugin javaPlugin : javaPlugins) {
    69         for (Plugin javaPlugin : javaPlugins) {
    71             String pluginName = javaPlugin.getName();
    70             String pluginName = javaPlugin.getName();
    72             try {
    71             try {
    73                 PluginRepository.registerPlugin(new CustomPlugin(pluginName));
    72                 PluginRepository.registerPlugin(new CustomPlugin(pluginName));
    74                 try {
    73                 try {
    75                     PluginRepository.getPlugin(pluginName, Layer.boot());
    74                     PluginRepository.getPlugin(pluginName, ModuleLayer.boot());
    76                     throw new AssertionError("Exception is not thrown for duplicate plugin: " + pluginName);
    75                     throw new AssertionError("Exception is not thrown for duplicate plugin: " + pluginName);
    77                 } catch (Exception ignored) {
    76                 } catch (Exception ignored) {
    78                 }
    77                 }
    79             } finally {
    78             } finally {
    80                 PluginRepository.unregisterPlugin(pluginName);
    79                 PluginRepository.unregisterPlugin(pluginName);
    81             }
    80             }
    82         }
    81         }
    83     }
    82     }
    84 
    83 
    85     private void testUnknownProvider() {
    84     private void testUnknownProvider() {
    86         if (PluginRepository.getPlugin("unknown", Layer.boot()) != null) {
    85         if (PluginRepository.getPlugin("unknown", ModuleLayer.boot()) != null) {
    87             throw new AssertionError("Exception expected for unknown plugin name");
    86             throw new AssertionError("Exception expected for unknown plugin name");
    88         }
    87         }
    89     }
    88     }
    90 
    89 
    91     private static Plugin createPlugin(String name) {
    90     private static Plugin createPlugin(String name) {