Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/tools/jpackage/windows/WinRenameTest.java
66644 views
1
/*
2
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.io.IOException;
25
import java.nio.file.Path;
26
import java.nio.file.Files;
27
import jdk.jpackage.test.HelloApp;
28
import jdk.jpackage.test.TKit;
29
import jdk.jpackage.test.Functional.ThrowingConsumer;
30
import jdk.jpackage.test.JPackageCommand;
31
import jdk.jpackage.test.Annotations.Test;
32
33
/*
34
* @test
35
* @summary jpackage test app can run after changing executable's extension
36
* @library ../helpers
37
* @key jpackagePlatformPackage
38
* @build jdk.jpackage.test.*
39
* @build WinRenameTest
40
* @requires (os.family == "windows")
41
* @modules jdk.jpackage/jdk.jpackage.internal
42
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
43
* --jpt-run=WinRenameTest
44
*/
45
public class WinRenameTest {
46
47
@Test
48
public static void test() throws IOException {
49
String javaAppDesc = "com.hello/com.hello.Hello";
50
JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc);
51
52
cmd.executeAndAssertImageCreated();
53
54
Path launcherPath = cmd.appLauncherPath();
55
HelloApp.assertApp(launcherPath).executeAndVerifyOutput();
56
57
String lp = launcherPath.toString();
58
TKit.assertTrue(lp.endsWith(".exe"), "UNexpected launcher path: " + lp);
59
60
Path newLauncherPath = Path.of(lp.replaceAll(".exe", ".anything"));
61
Files.move(launcherPath, newLauncherPath);
62
63
HelloApp.assertApp(newLauncherPath).executeAndVerifyOutput();
64
}
65
}
66
67