8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails JDK-8200758-branch
authorherrick
Thu, 17 Oct 2019 08:00:37 -0400
branchJDK-8200758-branch
changeset 58671 3b578a5976df
parent 58670 6fb9e12d5595
child 58695 64adf683bc7b
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails Submitted-by: asemenyuk Reviewed-by: aherrick, almatvee
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java
test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java	Thu Oct 17 07:55:35 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java	Thu Oct 17 08:00:37 2019 -0400
@@ -431,7 +431,7 @@
         }
 
         if (TKit.isLinux()) {
-            LinuxHelper.getLauncherPath(this).getParent().resolve(launcherName);
+            return LinuxHelper.getLauncherPath(this).getParent().resolve(launcherName);
         }
 
         return appLayout().launchersDirectory().resolve(launcherName);
--- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java	Thu Oct 17 07:55:35 2019 -0400
+++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java	Thu Oct 17 08:00:37 2019 -0400
@@ -34,6 +34,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import jdk.jpackage.test.*;
+import jdk.jpackage.test.Functional.ThrowingConsumer;
 import jdk.jpackage.test.Annotations.*;
 
 /*
@@ -218,25 +219,37 @@
      */
     @Test
     public void testTemp() throws IOException {
-        JPackageCommand cmd = JPackageCommand.helloAppImage()
-                .removeArgumentWithValue("--package-type")
-                .addArguments("--verbose")
-                .setFakeRuntime();
+        TKit.withTempDirectory("temp-root", tempRoot -> {
+            Function<JPackageCommand, Path> getTempDir = cmd -> {
+                return tempRoot.resolve(cmd.outputBundle().getFileName());
+            };
 
-        TKit.withTempDirectory("temp-root", tempDir -> {
-            cmd.addArguments("--temp", tempDir);
+            ThrowingConsumer<JPackageCommand> addTempDir = cmd -> {
+                Path tempDir = getTempDir.apply(cmd);
+                Files.createDirectories(tempDir);
+                cmd.addArguments("--temp", tempDir);
+            };
 
-            cmd.execute().assertExitCodeIsZero();
+            new PackageTest().configureHelloApp().addInitializer(addTempDir)
+            .addBundleVerifier(cmd -> {
+                // Check jpackage actually used the supplied directory.
+                Path tempDir = getTempDir.apply(cmd);
+                TKit.assertNotEquals(0, tempDir.toFile().list().length,
+                        String.format(
+                                "Check jpackage wrote some data in the supplied temporary directory [%s]",
+                                tempDir));
+            })
+            .run();
 
-            // Check jpackage actually used the supplied directory.
-            TKit.assertNotEquals(0, tempDir.toFile().list().length,
-                    String.format(
-                            "Check jpackage wrote some data in the supplied temporary directory [%s]",
-                            tempDir));
-
+            new PackageTest().configureHelloApp().addInitializer(addTempDir)
+            .addInitializer(cmd -> {
+                // Clean output from the previus jpackage run.
+                Files.delete(cmd.outputBundle());
+            })
             // Temporary directory should not be empty,
             // jpackage should exit with error.
-            cmd.execute().assertExitCodeIs(1);
+            .setExpectedExitCode(1)
+            .run();
         });
     }