89 .jmod(helper.getJmodDir().resolve(moduleName + ".jmod"))
90 .create().assertSuccess();
91 pluginModulePath = customPluginJmod.getParent();
92 Files.write(configFile, "jdk.jlink.image.builder=custom-image-builder\n".getBytes());
93 }
94
95 private JLinkTask getJLinkTask() {
96 return JImageGenerator.getJLinkTask()
97 .option("--plugins-configuration")
98 .option(configFile.toString());
99 }
100
101 public void testHelp() {
102 Result result = JImageGenerator.getJLinkTask()
103 .option("--help")
104 .pluginModulePath(pluginModulePath)
105 .call();
106 result.assertSuccess();
107 String message = result.getMessage();
108 if (!message.contains("Image Builder Name: custom-image-builder\n" +
109 " --custom-image-option-1 custom-image-option-description")) {
110 System.err.println(result.getMessage());
111 throw new AssertionError("Custom image builder not found");
112 }
113 }
114
115 public void testCustomImageBuilder() throws IOException {
116 Path image = getJLinkTask()
117 .modulePath(helper.defaultModulePath())
118 .output(helper.createNewImageDir("testCustomImageBuilder"))
119 .addMods("leaf1")
120 .pluginModulePath(pluginModulePath)
121 .call().assertSuccess();
122 checkImageBuilder(image);
123 }
124
125 public void testFirstOption() throws IOException {
126 Path image = getJLinkTask()
127 .modulePath(helper.defaultModulePath())
128 .output(helper.createNewImageDir("testFirstOption"))
156 }
157
158 public void testTwoImageBuildersInModule() throws IOException {
159 Result result = JImageGenerator.getJLinkTask()
160 .modulePath(helper.defaultModulePath())
161 .pluginModulePath(pluginModulePath)
162 .option("--list-plugins")
163 .call();
164 result.assertSuccess();
165 String message = result.getMessage();
166 if (!message.contains("Image Builder Name: custom-image-builder")) {
167 System.err.println(message);
168 throw new AssertionError("List-plugins does not contain custom-image-builder");
169 }
170 if (!message.contains("Image Builder Name: second-image-builder")) {
171 System.err.println(message);
172 throw new AssertionError("List-plugins does not contain second-image-builder");
173 }
174 }
175
176 @Test(enabled = false, priority = Integer.MAX_VALUE - 1)
177 public void testTwoPackages() throws IOException {
178 String moduleName = "customplugin_1";
179 Path src = helper.getJmodSrcDir().resolve(moduleName);
180 copyModule(src);
181 Path jmod = buildModule(moduleName);
182
183 try {
184 JImageGenerator.getJLinkTask()
185 .pluginModulePath(pluginModulePath)
186 .option("--list-plugins")
187 .call().assertFailure("Modules customplugin_1 and customplugin both contain package plugin");
188 } finally {
189 Files.delete(jmod);
190 }
191 }
192
193 private Path buildModule(String moduleName) throws IOException {
194 Path src = helper.getJmodSrcDir().resolve(moduleName);
195 Path classes = helper.getJmodClassesDir().resolve(moduleName);
196 JImageGenerator.compile(src, classes, "-XaddExports:jdk.jlink/jdk.tools.jlink.internal=customplugin");
|
89 .jmod(helper.getJmodDir().resolve(moduleName + ".jmod"))
90 .create().assertSuccess();
91 pluginModulePath = customPluginJmod.getParent();
92 Files.write(configFile, "jdk.jlink.image.builder=custom-image-builder\n".getBytes());
93 }
94
95 private JLinkTask getJLinkTask() {
96 return JImageGenerator.getJLinkTask()
97 .option("--plugins-configuration")
98 .option(configFile.toString());
99 }
100
101 public void testHelp() {
102 Result result = JImageGenerator.getJLinkTask()
103 .option("--help")
104 .pluginModulePath(pluginModulePath)
105 .call();
106 result.assertSuccess();
107 String message = result.getMessage();
108 if (!message.contains("Image Builder Name: custom-image-builder\n" +
109 "Image Builder Description: custom-image-builder-description\n" +
110 " --custom-image-option-1 custom-image-option-description")) {
111 System.err.println(result.getMessage());
112 throw new AssertionError("Custom image builder not found");
113 }
114 }
115
116 public void testCustomImageBuilder() throws IOException {
117 Path image = getJLinkTask()
118 .modulePath(helper.defaultModulePath())
119 .output(helper.createNewImageDir("testCustomImageBuilder"))
120 .addMods("leaf1")
121 .pluginModulePath(pluginModulePath)
122 .call().assertSuccess();
123 checkImageBuilder(image);
124 }
125
126 public void testFirstOption() throws IOException {
127 Path image = getJLinkTask()
128 .modulePath(helper.defaultModulePath())
129 .output(helper.createNewImageDir("testFirstOption"))
157 }
158
159 public void testTwoImageBuildersInModule() throws IOException {
160 Result result = JImageGenerator.getJLinkTask()
161 .modulePath(helper.defaultModulePath())
162 .pluginModulePath(pluginModulePath)
163 .option("--list-plugins")
164 .call();
165 result.assertSuccess();
166 String message = result.getMessage();
167 if (!message.contains("Image Builder Name: custom-image-builder")) {
168 System.err.println(message);
169 throw new AssertionError("List-plugins does not contain custom-image-builder");
170 }
171 if (!message.contains("Image Builder Name: second-image-builder")) {
172 System.err.println(message);
173 throw new AssertionError("List-plugins does not contain second-image-builder");
174 }
175 }
176
177 @Test(priority = Integer.MAX_VALUE - 1)
178 public void testTwoPackages() throws IOException {
179 String moduleName = "customplugin_1";
180 Path src = helper.getJmodSrcDir().resolve(moduleName);
181 copyModule(src);
182 Path jmod = buildModule(moduleName);
183
184 try {
185 JImageGenerator.getJLinkTask()
186 .pluginModulePath(pluginModulePath)
187 .option("--list-plugins")
188 .call().assertFailure("Modules customplugin_1 and customplugin both contain package plugin");
189 } finally {
190 Files.delete(jmod);
191 }
192 }
193
194 private Path buildModule(String moduleName) throws IOException {
195 Path src = helper.getJmodSrcDir().resolve(moduleName);
196 Path classes = helper.getJmodClassesDir().resolve(moduleName);
197 JImageGenerator.compile(src, classes, "-XaddExports:jdk.jlink/jdk.tools.jlink.internal=customplugin");
|