33 import java.io.ByteArrayInputStream; |
33 import java.io.ByteArrayInputStream; |
34 import java.io.File; |
34 import java.io.File; |
35 import java.nio.file.Files; |
35 import java.nio.file.Files; |
36 import java.util.HashMap; |
36 import java.util.HashMap; |
37 import java.util.Map; |
37 import java.util.Map; |
38 import jdk.tools.jlink.internal.ModulePoolImpl; |
38 import jdk.tools.jlink.internal.ResourcePoolManager; |
39 |
39 |
40 import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; |
40 import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; |
41 import jdk.tools.jlink.plugin.ModuleEntry; |
41 import jdk.tools.jlink.plugin.ResourcePool; |
42 import jdk.tools.jlink.plugin.ModulePool; |
42 import jdk.tools.jlink.plugin.ResourcePoolEntry; |
43 |
43 |
44 public class ExcludeFilesPluginTest { |
44 public class ExcludeFilesPluginTest { |
45 public static void main(String[] args) throws Exception { |
45 public static void main(String[] args) throws Exception { |
46 new ExcludeFilesPluginTest().test(); |
46 new ExcludeFilesPluginTest().test(); |
47 } |
47 } |
69 public void checkFiles(String s, String sample, String module, boolean exclude) throws Exception { |
69 public void checkFiles(String s, String sample, String module, boolean exclude) throws Exception { |
70 Map<String, String> prop = new HashMap<>(); |
70 Map<String, String> prop = new HashMap<>(); |
71 prop.put(ExcludeFilesPlugin.NAME, s); |
71 prop.put(ExcludeFilesPlugin.NAME, s); |
72 ExcludeFilesPlugin fplug = new ExcludeFilesPlugin(); |
72 ExcludeFilesPlugin fplug = new ExcludeFilesPlugin(); |
73 fplug.configure(prop); |
73 fplug.configure(prop); |
74 ModulePoolImpl files = new ModulePoolImpl(); |
74 ResourcePoolManager files = new ResourcePoolManager(); |
75 ModulePoolImpl fresult = new ModulePoolImpl(); |
75 ResourcePoolManager fresult = new ResourcePoolManager(); |
76 ModuleEntry f = ModuleEntry.create("/" + module + "/" + sample, |
76 ResourcePoolEntry f = ResourcePoolEntry.create("/" + module + "/" + sample, |
77 ModuleEntry.Type.CONFIG, new byte[0]); |
77 ResourcePoolEntry.Type.CONFIG, new byte[0]); |
78 files.add(f); |
78 files.add(f); |
79 |
79 |
80 fplug.visit(files, fresult); |
80 ResourcePool resPool = fplug.transform(files.resourcePool(), fresult.resourcePoolBuilder()); |
81 |
81 |
82 if (exclude) { |
82 if (exclude) { |
83 if (fresult.contains(f)) { |
83 if (resPool.contains(f)) { |
84 throw new Exception(sample + " should be excluded by " + s); |
84 throw new Exception(sample + " should be excluded by " + s); |
85 } |
85 } |
86 } else { |
86 } else { |
87 if (!fresult.contains(f)) { |
87 if (!resPool.contains(f)) { |
88 throw new Exception(sample + " shouldn't be excluded by " + s); |
88 throw new Exception(sample + " shouldn't be excluded by " + s); |
89 } |
89 } |
90 } |
90 } |
91 } |
91 } |
92 } |
92 } |