test/jdk/tools/jpackage/linux/ShortcutHintTest.java
author herrick
Wed, 23 Oct 2019 10:37:54 -0400
branchJDK-8200758-branch
changeset 58762 0fe62353385b
parent 58761 88e2753a2334
child 58888 d802578912f3
permissions -rw-r--r--
8232281: jpackage is not always reporting an error when no main class specified Reviewed-by: asemenyuk, asemenuk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     1
/*
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     4
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     8
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    13
 * accompanied this code).
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    14
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    18
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    21
 * questions.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    22
 */
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    23
58762
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
    24
import java.nio.charset.StandardCharsets;
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
    25
import java.nio.file.Files;
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    26
import java.util.Map;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    27
import java.nio.file.Path;
58762
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
    28
import java.util.List;
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
    29
import java.util.stream.Collectors;
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    30
import jdk.jpackage.test.FileAssociations;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    31
import jdk.jpackage.test.PackageType;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    32
import jdk.jpackage.test.PackageTest;
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    33
import jdk.jpackage.test.TKit;
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    34
import jdk.jpackage.test.Annotations.Test;
58762
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
    35
import jdk.jpackage.test.*;
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    36
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    37
/**
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    38
 * Test --linux-shortcut parameter. Output of the test should be
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    39
 * shortcuthinttest_1.0-1_amd64.deb or shortcuthinttest-1.0-1.amd64.rpm package
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    40
 * bundle. The output package should provide the same functionality as the
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    41
 * default package and also create a desktop shortcut.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    42
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    43
 * Finding a shortcut of the application launcher through GUI depends on desktop
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    44
 * environment.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    45
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    46
 * deb:
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    47
 * Search online for `Ways To Open A Ubuntu Application` for instructions.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    48
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    49
 * rpm:
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    50
 *
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    51
 */
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    52
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    53
/*
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    54
 * @test
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    55
 * @summary jpackage with --linux-shortcut
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    56
 * @library ../helpers
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    57
 * @key jpackagePlatformPackage
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    58
 * @requires jpackage.test.SQETest == null
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    59
 * @build jdk.jpackage.test.*
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    60
 * @requires (os.family == "linux")
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    61
 * @modules jdk.jpackage/jdk.jpackage.internal
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    62
 * @compile ShortcutHintTest.java
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    63
 * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    64
 *  --jpt-run=ShortcutHintTest
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    65
 */
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    66
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    67
/*
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    68
 * @test
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    69
 * @summary jpackage with --linux-shortcut
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    70
 * @library ../helpers
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    71
 * @key jpackagePlatformPackage
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    72
 * @build jdk.jpackage.test.*
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    73
 * @requires (os.family == "linux")
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    74
 * @requires jpackage.test.SQETest != null
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    75
 * @modules jdk.jpackage/jdk.jpackage.internal
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    76
 * @compile ShortcutHintTest.java
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    77
 * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    78
 *  --jpt-run=ShortcutHintTest.testBasic
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    79
 */
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58416
diff changeset
    80
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    81
public class ShortcutHintTest {
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    82
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    83
    @Test
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    84
    public static void testBasic() {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    85
        createTest().addInitializer(cmd -> {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    86
            cmd.addArgument("--linux-shortcut");
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    87
        }).run();
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    88
    }
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    89
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    90
    private static PackageTest createTest() {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    91
        return new PackageTest()
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    92
                .forTypes(PackageType.LINUX)
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    93
                .configureHelloApp()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    94
                .addBundleDesktopIntegrationVerifier(true);
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
    95
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    96
    }
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    97
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    98
    /**
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    99
     * Adding `--icon` to jpackage command line should create desktop shortcut
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   100
     * even though `--linux-shortcut` is omitted.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   101
     */
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   102
    @Test
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   103
    public static void testCustomIcon() {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   104
        createTest().addInitializer(cmd -> {
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   105
            cmd.setFakeRuntime();
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   106
            cmd.addArguments("--icon", TKit.TEST_SRC_ROOT.resolve(
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   107
                    "apps/dukeplug.png"));
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   108
        }).run();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   109
    }
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   110
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   111
    /**
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   112
     * Adding `--file-associations` to jpackage command line should create
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   113
     * desktop shortcut even though `--linux-shortcut` is omitted.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   114
     */
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   115
    @Test
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   116
    public static void testFileAssociations() {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   117
        createTest().addInitializer(cmd -> {
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   118
            cmd.setFakeRuntime();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   119
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   120
            FileAssociations fa = new FileAssociations(
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   121
                    "ShortcutHintTest_testFileAssociations");
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   122
            fa.createFile();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   123
            cmd.addArguments("--file-associations", fa.getPropertiesFile());
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   124
        }).run();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   125
    }
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   126
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   127
    /**
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   128
     * Additional launcher with icon should create desktop shortcut even though
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   129
     * `--linux-shortcut` is omitted.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   130
     */
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   131
    @Test
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   132
    public static void testAdditionaltLaunchers() {
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   133
        createTest().addInitializer(cmd -> {
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   134
            cmd.setFakeRuntime();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   135
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   136
            final String launcherName = "Foo";
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   137
            final Path propsFile = TKit.workDir().resolve(
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   138
                    launcherName + ".properties");
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   139
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   140
            cmd.addArguments("--add-launcher", String.format("%s=%s",
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   141
                    launcherName, propsFile));
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   142
58416
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   143
            TKit.createPropertiesFile(propsFile, Map.entry("icon",
f09bf58c1f17 8231605: Improve test helpers
herrick
parents: 58301
diff changeset
   144
                    TKit.TEST_SRC_ROOT.resolve("apps/dukeplug.png").toString()));
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   145
        }).run();
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   146
    }
58762
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   147
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   148
    /**
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   149
     * .desktop file from resource dir.
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   150
     */
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   151
    @Test
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   152
    public static void testDesktopFileFromResourceDir() {
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   153
        final String expectedVersionString = "Version=12345678";
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   154
        TKit.withTempDirectory("resources", tempDir -> {
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   155
            createTest().addInitializer(cmd -> {
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   156
                cmd.setFakeRuntime();
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   157
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   158
                cmd.addArgument("--linux-shortcut");
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   159
                cmd.addArguments("--resource-dir", tempDir);
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   160
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   161
                // Create custom .desktop file in resource directory
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   162
                TKit.createTextFile(tempDir.resolve(cmd.name() + ".desktop"),
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   163
                        List.of(
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   164
                                "[Desktop Entry]",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   165
                                "Name=APPLICATION_NAME",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   166
                                "Exec=APPLICATION_LAUNCHER",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   167
                                "Terminal=false",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   168
                                "Type=Application",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   169
                                "Categories=DEPLOY_BUNDLE_CATEGORY",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   170
                                expectedVersionString
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   171
                        ));
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   172
            })
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   173
            .addInstallVerifier(cmd -> {
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   174
                Path desktopFile = cmd.appLayout().destktopIntegrationDirectory().resolve(
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   175
                        String.format("%s-%s.desktop",
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   176
                                LinuxHelper.getPackageName(cmd), cmd.name()));
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   177
                TKit.assertFileExists(desktopFile);
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   178
                TKit.assertTextStream(expectedVersionString)
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   179
                        .label(String.format("[%s] file", desktopFile))
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   180
                        .predicate(String::equals)
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   181
                        .apply(Files.readAllLines(desktopFile).stream());
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   182
            }).run();
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   183
        });
0fe62353385b 8232281: jpackage is not always reporting an error when no main class specified
herrick
parents: 58761
diff changeset
   184
    }
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   185
}