< prev index next >

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java

Print this page

        

*** 22,32 **** */ package jdk.jpackage.test; import java.awt.Desktop; import java.io.File; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; --- 22,31 ----
*** 40,55 **** import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; import static jdk.jpackage.test.PackageType.LINUX_DEB; import static jdk.jpackage.test.PackageType.LINUX_RPM; /** * Instance of PackageTest is for configuring and running a single jpackage * command to produce platform specific package bundle. * ! * Provides methods hook up custom configuration of jpackage command and * verification of the output bundle. */ public final class PackageTest { /** --- 39,55 ---- import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; import static jdk.jpackage.test.PackageType.LINUX_DEB; import static jdk.jpackage.test.PackageType.LINUX_RPM; + import jdk.jpackage.test.Functional.ThrowingConsumer; /** * Instance of PackageTest is for configuring and running a single jpackage * command to produce platform specific package bundle. * ! * Provides methods to hook up custom configuration of jpackage command and * verification of the output bundle. */ public final class PackageTest { /**
*** 89,124 **** public PackageTest setJPackageExitCode(int v) { expectedJPackageExitCode = v; return this; } ! private PackageTest addInitializer(Consumer<JPackageCommand> v, String id) { if (id != null) { if (namedInitializers.contains(id)) { return this; } namedInitializers.add(id); } currentTypes.stream().forEach(type -> handlers.get(type).addInitializer( ! v)); return this; } ! public PackageTest addInitializer(Consumer<JPackageCommand> v) { return addInitializer(v, null); } public PackageTest addBundleVerifier( BiConsumer<JPackageCommand, Executor.Result> v) { currentTypes.stream().forEach( type -> handlers.get(type).addBundleVerifier(v)); return this; } ! public PackageTest addBundleVerifier(Consumer<JPackageCommand> v) { ! return addBundleVerifier((cmd, unused) -> v.accept(cmd)); } public PackageTest addBundlePropertyVerifier(String propertyName, BiConsumer<String, String> pred) { return addBundleVerifier(cmd -> { --- 89,125 ---- public PackageTest setJPackageExitCode(int v) { expectedJPackageExitCode = v; return this; } ! private PackageTest addInitializer(ThrowingConsumer<JPackageCommand> v, String id) { if (id != null) { if (namedInitializers.contains(id)) { return this; } namedInitializers.add(id); } currentTypes.stream().forEach(type -> handlers.get(type).addInitializer( ! ThrowingConsumer.toConsumer(v))); return this; } ! public PackageTest addInitializer(ThrowingConsumer<JPackageCommand> v) { return addInitializer(v, null); } public PackageTest addBundleVerifier( BiConsumer<JPackageCommand, Executor.Result> v) { currentTypes.stream().forEach( type -> handlers.get(type).addBundleVerifier(v)); return this; } ! public PackageTest addBundleVerifier(ThrowingConsumer<JPackageCommand> v) { ! return addBundleVerifier( ! (cmd, unused) -> ThrowingConsumer.toConsumer(v).accept(cmd)); } public PackageTest addBundlePropertyVerifier(String propertyName, BiConsumer<String, String> pred) { return addBundleVerifier(cmd -> {
*** 155,173 **** LinuxHelper.addDebBundleDesktopIntegrationVerifier(this, integrated); }); return this; } ! public PackageTest addInstallVerifier(Consumer<JPackageCommand> v) { currentTypes.stream().forEach( ! type -> handlers.get(type).addInstallVerifier(v)); return this; } ! public PackageTest addUninstallVerifier(Consumer<JPackageCommand> v) { currentTypes.stream().forEach( ! type -> handlers.get(type).addUninstallVerifier(v)); return this; } public PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa, String... faLauncherDefaultArgs) { --- 156,176 ---- LinuxHelper.addDebBundleDesktopIntegrationVerifier(this, integrated); }); return this; } ! public PackageTest addInstallVerifier(ThrowingConsumer<JPackageCommand> v) { currentTypes.stream().forEach( ! type -> handlers.get(type).addInstallVerifier( ! ThrowingConsumer.toConsumer(v))); return this; } ! public PackageTest addUninstallVerifier(ThrowingConsumer<JPackageCommand> v) { currentTypes.stream().forEach( ! type -> handlers.get(type).addUninstallVerifier( ! ThrowingConsumer.toConsumer(v))); return this; } public PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa, String... faLauncherDefaultArgs) {
*** 178,192 **** "Not running file associations test")) { return; } Test.withTempFile(fa.getSuffix(), testFile -> { if (PackageType.LINUX.contains(cmd.packageType())) { LinuxHelper.initFileAssociationsTestFile(testFile); } - try { final Path appOutput = Path.of(HelloApp.OUTPUT_FILENAME); Files.deleteIfExists(appOutput); Test.trace(String.format("Use desktop to open [%s] file", testFile)); --- 181,195 ---- "Not running file associations test")) { return; } Test.withTempFile(fa.getSuffix(), testFile -> { + testFile = testFile.toAbsolutePath().normalize(); if (PackageType.LINUX.contains(cmd.packageType())) { LinuxHelper.initFileAssociationsTestFile(testFile); } final Path appOutput = Path.of(HelloApp.OUTPUT_FILENAME); Files.deleteIfExists(appOutput); Test.trace(String.format("Use desktop to open [%s] file", testFile));
*** 198,212 **** expectedArgs.add(testFile.toString()); // Wait a little bit after file has been created to // make sure there are no pending writes into it. Thread.sleep(3000); ! HelloApp.verifyOutputFile(appOutput, expectedArgs.toArray( ! String[]::new)); ! } catch (IOException | InterruptedException ex) { ! throw new RuntimeException(ex); ! } }); }); forTypes(PackageType.LINUX, () -> { LinuxHelper.addFileAssociationsVerifier(this, fa); --- 201,211 ---- expectedArgs.add(testFile.toString()); // Wait a little bit after file has been created to // make sure there are no pending writes into it. Thread.sleep(3000); ! HelloApp.verifyOutputFile(appOutput, expectedArgs.toArray(String[]::new)); }); }); forTypes(PackageType.LINUX, () -> { LinuxHelper.addFileAssociationsVerifier(this, fa);
*** 343,357 **** Test.trace(String.format("Verify installed: %s", cmd.getPrintableCommandLine())); if (cmd.isRuntime()) { Test.assertDirectoryExists( cmd.appRuntimeInstallationDirectory(), false); - Test.assertDirectoryExists( - cmd.appInstallationDirectory().resolve("app"), false); } else { ! Test.assertExecutableFileExists(cmd.launcherInstallationPath(), ! true); } if (PackageType.WINDOWS.contains(cmd.packageType())) { new WindowsHelper.AppVerifier(cmd); } --- 342,353 ---- Test.trace(String.format("Verify installed: %s", cmd.getPrintableCommandLine())); if (cmd.isRuntime()) { Test.assertDirectoryExists( cmd.appRuntimeInstallationDirectory(), false); } else { ! Test.assertExecutableFileExists(cmd.launcherInstallationPath(), true); } if (PackageType.WINDOWS.contains(cmd.packageType())) { new WindowsHelper.AppVerifier(cmd); }
*** 361,372 **** private void verifyPackageUninstalled(JPackageCommand cmd) { Test.trace(String.format("Verify uninstalled: %s", cmd.getPrintableCommandLine())); if (!cmd.isRuntime()) { ! Test.assertFileExists(cmd.launcherInstallationPath(), false); ! Test.assertDirectoryExists(cmd.appInstallationDirectory(), false); } if (PackageType.WINDOWS.contains(cmd.packageType())) { new WindowsHelper.AppVerifier(cmd); } --- 357,368 ---- private void verifyPackageUninstalled(JPackageCommand cmd) { Test.trace(String.format("Verify uninstalled: %s", cmd.getPrintableCommandLine())); if (!cmd.isRuntime()) { ! Test.assertPathExists(cmd.launcherInstallationPath(), false); ! Test.assertPathExists(cmd.appInstallationDirectory(), false); } if (PackageType.WINDOWS.contains(cmd.packageType())) { new WindowsHelper.AppVerifier(cmd); }
< prev index next >