@Test publicvoid test() { // Configure a bunch of additional launchers and also setup // file association to make sure it will be linked only to the main // launcher.
final JPackageCommand cmd; if (mainLauncherIsModular) { // Create non modular jar.
nonModularJarCmd.executePrerequisiteActions();
cmd = modularJarCmd;
cmd.addArguments("--description", "Test modular app with multiple add-launchers where one is modular app and other is non modular app");
cmd.addArguments("--input", nonModularJarCmd.getArgumentValue( "--input"));
} else { // Create modular jar.
modularJarCmd.executePrerequisiteActions();
cmd = nonModularJarCmd;
cmd.addArguments("--description", "Test non modular app with multiple add-launchers where one is modular app and other is non modular app");
cmd.addArguments("--module-path", modularJarCmd.getArgumentValue( "--module-path"));
cmd.addArguments("--add-modules", modularAppDesc.moduleName());
cmd.ignoreDefaultRuntime(true); // because of --add-modules
}
final String expectedMod = JavaAppDesc.parse(modularAppDesc.toString())
.setBundleFileName(null)
.setSrcJavaPath(null)
.toString();
new AdditionalLauncher("ModularAppLauncher")
.addRawProperties(Map.entry("module", expectedMod))
.addRawProperties(Map.entry("main-jar", ""))
.applyTo(cmd);
new AdditionalLauncher("NonModularAppLauncher") // Use space ( ) character instead of equality sign (=) as // a key/value separator
.setPersistenceHandler((path, properties) -> TKit.createTextFile(path,
properties.stream().map(entry -> String.join(" ", entry.getKey(),
entry.getValue()))))
.addRawProperties(Map.entry("main-class", nonModularAppDesc.className()))
.addRawProperties(Map.entry("main-jar", nonModularAppDesc.jarFileName()))
.applyTo(cmd);
cmd.executeAndAssertHelloAppImageCreated();
// check value of app.mainmodule in ModularAppLauncher's cfg file
CfgFile cfg = cmd.readLauncherCfgFile("ModularAppLauncher");
String moduleValue = cfg.getValue("Application", "app.mainmodule");
String mainClass = null;
String classpath = null;
TKit.assertEquals(expectedMod, moduleValue,
String.format("Check value of app.mainmodule=[%s]" + "in ModularAppLauncher cfg file is as expected", expectedMod));
// check values of app.mainclass and app.classpath in cfg file
cfg = cmd.readLauncherCfgFile("NonModularAppLauncher");
moduleValue = null;
mainClass = cfg.getValue("Application", "app.mainclass");
classpath = cfg.getValue("Application", "app.classpath");
String ExpectedCN = nonModularAppDesc.className();
TKit.assertEquals(ExpectedCN, mainClass,
String.format("Check value of app.mainclass=[%s]" + "in NonModularAppLauncher cfg file is as expected", ExpectedCN));
TKit.assertTrue(classpath.startsWith("$APPDIR" + File.separator
+ nonModularAppDesc.jarFileName()), "Check app.classpath value in ModularAppLauncher cfg file");
}
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 und die Messung sind noch experimentell.