32 |
32 |
33 import java.io.File; |
33 import java.io.File; |
34 import java.nio.file.Files; |
34 import java.nio.file.Files; |
35 import java.util.HashMap; |
35 import java.util.HashMap; |
36 import java.util.Map; |
36 import java.util.Map; |
37 import jdk.tools.jlink.internal.ModulePoolImpl; |
37 import jdk.tools.jlink.internal.ResourcePoolManager; |
38 |
38 |
39 import jdk.tools.jlink.internal.plugins.ExcludePlugin; |
39 import jdk.tools.jlink.internal.plugins.ExcludePlugin; |
40 import jdk.tools.jlink.plugin.ModuleEntry; |
40 import jdk.tools.jlink.plugin.ResourcePool; |
41 import jdk.tools.jlink.plugin.ModulePool; |
41 import jdk.tools.jlink.plugin.ResourcePoolBuilder; |
|
42 import jdk.tools.jlink.plugin.ResourcePoolEntry; |
42 |
43 |
43 public class ExcludePluginTest { |
44 public class ExcludePluginTest { |
44 |
45 |
45 public static void main(String[] args) throws Exception { |
46 public static void main(String[] args) throws Exception { |
46 new ExcludePluginTest().test(); |
47 new ExcludePluginTest().test(); |
73 public void check(String s, String sample, boolean exclude) throws Exception { |
74 public void check(String s, String sample, boolean exclude) throws Exception { |
74 Map<String, String> prop = new HashMap<>(); |
75 Map<String, String> prop = new HashMap<>(); |
75 prop.put(ExcludePlugin.NAME, s); |
76 prop.put(ExcludePlugin.NAME, s); |
76 ExcludePlugin excludePlugin = new ExcludePlugin(); |
77 ExcludePlugin excludePlugin = new ExcludePlugin(); |
77 excludePlugin.configure(prop); |
78 excludePlugin.configure(prop); |
78 ModulePool resources = new ModulePoolImpl(); |
79 ResourcePoolManager resourcesMgr = new ResourcePoolManager(); |
79 ModuleEntry resource = ModuleEntry.create(sample, new byte[0]); |
80 ResourcePoolEntry resource = ResourcePoolEntry.create(sample, new byte[0]); |
80 resources.add(resource); |
81 resourcesMgr.add(resource); |
81 ModulePool result = new ModulePoolImpl(); |
82 ResourcePoolManager resultMgr = new ResourcePoolManager(); |
82 excludePlugin.visit(resources, result); |
83 ResourcePool resPool = excludePlugin.transform(resourcesMgr.resourcePool(), |
|
84 resultMgr.resourcePoolBuilder()); |
83 if (exclude) { |
85 if (exclude) { |
84 if (result.contains(resource)) { |
86 if (resPool.contains(resource)) { |
85 throw new AssertionError(sample + " should be excluded by " + s); |
87 throw new AssertionError(sample + " should be excluded by " + s); |
86 } |
88 } |
87 } else { |
89 } else { |
88 if (!result.contains(resource)) { |
90 if (!resPool.contains(resource)) { |
89 throw new AssertionError(sample + " shouldn't be excluded by " + s); |
91 throw new AssertionError(sample + " shouldn't be excluded by " + s); |
90 } |
92 } |
91 } |
93 } |
92 } |
94 } |
93 } |
95 } |