Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/ArgumentsTest.java
41149 views
1
/*
2
* Copyright (c) 2018, 2020, 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.nio.file.Path;
25
import java.util.List;
26
import jdk.jpackage.test.HelloApp;
27
import jdk.jpackage.test.Functional.ThrowingConsumer;
28
import jdk.jpackage.test.JPackageCommand;
29
import jdk.jpackage.test.Annotations.BeforeEach;
30
import jdk.jpackage.test.Annotations.Test;
31
import jdk.jpackage.test.Annotations.Parameter;
32
33
34
/*
35
* Tricky arguments used in the test require a bunch of levels of character
36
* escaping for proper encoding them in a single string to be used as a value of
37
* `--arguments` option. String with encoded arguments doesn't go through the
38
* system to jpackage executable as is because OS is interpreting escape
39
* characters. This is true for Windows at least.
40
*
41
* String mapping performed by the system corrupts the string and jpackage exits
42
* with error. There is no problem with string corruption when jpackage is used
43
* as tool provider. This is not jpackage issue, so just always run this test
44
* with jpackage used as tool provider.
45
* /
46
47
/*
48
* @test
49
* @summary jpackage create image with --arguments test
50
* @library ../helpers
51
* @build jdk.jpackage.test.*
52
* @modules jdk.jpackage/jdk.jpackage.internal
53
* @compile ArgumentsTest.java
54
* @run main/othervm -Xmx512m jdk.jpackage.test.Main
55
* --jpt-run=ArgumentsTest
56
*/
57
public class ArgumentsTest {
58
59
@BeforeEach
60
public static void useJPackageToolProvider() {
61
JPackageCommand.useToolProviderByDefault();
62
}
63
64
@Test
65
@Parameter("Goodbye")
66
@Parameter("com.hello/com.hello.Hello")
67
public static void testApp(String javaAppDesc) {
68
testIt(javaAppDesc, null);
69
}
70
71
private static void testIt(String javaAppDesc,
72
ThrowingConsumer<JPackageCommand> initializer) {
73
74
JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc).addArguments(
75
"--arguments", JPackageCommand.escapeAndJoin(TRICKY_ARGUMENTS));
76
if (initializer != null) {
77
ThrowingConsumer.toConsumer(initializer).accept(cmd);
78
}
79
80
cmd.executeAndAssertImageCreated();
81
82
Path launcherPath = cmd.appLauncherPath();
83
if (!cmd.isFakeRuntime(String.format(
84
"Not running [%s] launcher", launcherPath))) {
85
HelloApp.assertApp(launcherPath)
86
.addDefaultArguments(TRICKY_ARGUMENTS)
87
.executeAndVerifyOutput();
88
}
89
}
90
91
private final static List<String> TRICKY_ARGUMENTS = List.of(
92
"argument",
93
"Some Arguments",
94
"Value \"with\" quotes"
95
);
96
}
97
98