author | herrick |
Sat, 29 Jun 2019 09:11:19 -0400 | |
branch | JDK-8200758-branch |
changeset 57445 | 405ddd80496e |
parent 57419 | 44c2481650ce |
permissions | -rw-r--r-- |
57307 | 1 |
/* |
2 |
* Copyright (c) 2018, 2019, 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.Files; |
|
57407 | 25 |
import java.nio.file.Path; |
57307 | 26 |
|
27 |
public abstract class JPackageCreateAppImageBase { |
|
28 |
private static final String appOutput = JPackagePath.getAppOutputFile(); |
|
29 |
||
30 |
private static void validateResult(String[] result) throws Exception { |
|
31 |
if (result.length != 2) { |
|
32 |
throw new AssertionError( |
|
33 |
"Unexpected number of lines: " + result.length); |
|
34 |
} |
|
35 |
||
57395
521c02b9eed0
8224130: create additional automated tests for create-app-image
herrick
parents:
57307
diff
changeset
|
36 |
if (!result[0].trim().endsWith("jpackage test application")) { |
57307 | 37 |
throw new AssertionError("Unexpected result[0]: " + result[0]); |
38 |
} |
|
39 |
||
40 |
if (!result[1].trim().equals("args.length: 0")) { |
|
41 |
throw new AssertionError("Unexpected result[1]: " + result[1]); |
|
42 |
} |
|
43 |
} |
|
44 |
||
57405
539d8b3f9e1e
8224597: create automated tests for platform create-app-image options
herrick
parents:
57395
diff
changeset
|
45 |
public static void validate(String app) throws Exception { |
57445
405ddd80496e
8226904: current working directory wrong running jpackage app
herrick
parents:
57419
diff
changeset
|
46 |
Path outPath = Path.of(appOutput); |
57419
44c2481650ce
8225092: Several jpackage tests failes when run with jcov enabled
herrick
parents:
57407
diff
changeset
|
47 |
int retVal = JPackageHelper.execute(null, app); |
57407 | 48 |
|
49 |
if (outPath.toFile().exists()) { |
|
50 |
System.out.println("output contents: "); |
|
51 |
System.out.println(Files.readString(outPath) + "\n"); |
|
52 |
} else { |
|
53 |
System.out.println("no output file: " + outPath |
|
54 |
+ " from command: " + app); |
|
55 |
} |
|
56 |
||
57307 | 57 |
if (retVal != 0) { |
58 |
throw new AssertionError( |
|
57407 | 59 |
"Test application (" + app + ") exited with error: " + retVal); |
57307 | 60 |
} |
61 |
||
57407 | 62 |
if (!outPath.toFile().exists()) { |
57307 | 63 |
throw new AssertionError(appOutput + " was not created"); |
64 |
} |
|
65 |
||
57407 | 66 |
String output = Files.readString(outPath); |
57419
44c2481650ce
8225092: Several jpackage tests failes when run with jcov enabled
herrick
parents:
57407
diff
changeset
|
67 |
String[] result = JPackageHelper.splitAndFilter(output); |
57307 | 68 |
validateResult(result); |
69 |
} |
|
70 |
||
71 |
public static void testCreateAppImage(String [] cmd) throws Exception { |
|
72 |
JPackageHelper.executeCLI(true, cmd); |
|
57405
539d8b3f9e1e
8224597: create automated tests for platform create-app-image options
herrick
parents:
57395
diff
changeset
|
73 |
validate(JPackagePath.getApp()); |
57307 | 74 |
} |
75 |
||
76 |
public static void testCreateAppImageToolProvider(String [] cmd) throws Exception { |
|
77 |
JPackageHelper.executeToolProvider(true, cmd); |
|
57405
539d8b3f9e1e
8224597: create automated tests for platform create-app-image options
herrick
parents:
57395
diff
changeset
|
78 |
validate(JPackagePath.getApp()); |
57307 | 79 |
} |
80 |
} |