/* * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
try {
jl.build(null);
failed = true;
} catch (Exception ex) { // XXX OK
} if (failed) { thrownew Exception("Should have failed");
}
System.out.println(jl);
Plugin p = Jlink.newPlugin("toto", Collections.emptyMap(), null); if (p != null) { thrownew Exception("Plugin should be null");
}
Plugin p2 = Jlink.newPlugin("compress", Map.of("compress", "1"), null); if (p2 == null) { thrownew Exception("Plugin should not be null");
}
}
privatestaticvoid test() throws Exception {
Jlink jlink = new Jlink();
Path output = Paths.get("integrationout");
List<Path> modulePaths = new ArrayList<>();
File jmods
= JImageGenerator.getJModsDir(new File(System.getProperty("test.jdk")));
modulePaths.add(jmods.toPath());
Set<String> mods = new HashSet<>();
mods.add("java.management");
Set<String> limits = new HashSet<>();
limits.add("java.management");
JlinkConfiguration config = new Jlink.JlinkConfiguration(output,
mods, ByteOrder.nativeOrder(),
JlinkTask.newModuleFinder(modulePaths, limits, mods));
List<Plugin> lst = new ArrayList<>();
//Strip debug
{
Map<String, String> config1 = new HashMap<>();
Plugin strip = Jlink.newPlugin("strip-debug", config1, null);
config1.put(strip.getName(), "");
lst.add(strip);
} // compress
{
Map<String, String> config1 = new HashMap<>();
String pluginName = "compress";
config1.put(pluginName, "2");
Plugin compress
= Jlink.newPlugin(pluginName, config1, null); if(!pluginName.equals(compress.getName())) { thrownew AssertionError("compress plugin name doesn't match test constant");
}
lst.add(compress);
} // Post processor
{
lst.add(new MyPostProcessor());
} // Image builder
DefaultImageBuilder builder = new DefaultImageBuilder(output, Collections.emptyMap());
PluginsConfiguration plugins
= new Jlink.PluginsConfiguration(lst, builder, null);
jlink.build(config, plugins);
if (!Files.exists(output)) { thrownew AssertionError("Directory not created");
}
File jimage = new File(output.toString(), "lib" + File.separator + "modules"); if (!jimage.exists()) { thrownew AssertionError("jimage not generated");
}
File release = new File(output.toString(), "release"); if (!release.exists()) { thrownew AssertionError("release not generated");
}
Properties props = new Properties(); try (FileReader reader = new FileReader(release)) {
props.load(reader);
}
checkReleaseProperty(props, "JAVA_VERSION");
if (!Files.exists(output.resolve("toto.txt"))) { thrownew AssertionError("Post processing not called");
}
}
staticvoid checkReleaseProperty(Properties props, String name) { if (! props.containsKey(name)) { thrownew AssertionError("release file does not contain property : " + name);
}
// property value is of min. length 3 and double quoted at the ends.
String value = props.getProperty(name); if (value.length() < 3 ||
value.charAt(0) != '"' ||
value.charAt(value.length() - 1) != '"') { thrownew AssertionError("release property " + name + " is not quoted property");
}
}
}
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.