38
38
import java .util .regex .Pattern ;
39
39
import java .util .stream .Collectors ;
40
40
import java .util .stream .Stream ;
41
+ import jdk .incubator .jpackage .internal .AppImageFile ;
41
42
import jdk .incubator .jpackage .internal .ApplicationLayout ;
42
43
import jdk .jpackage .test .Functional .ThrowingConsumer ;
43
44
import jdk .jpackage .test .Functional .ThrowingFunction ;
@@ -235,9 +236,7 @@ public JPackageCommand setFakeRuntime() {
235
236
236
237
Files .createDirectories (fakeRuntimeDir );
237
238
238
- if (TKit .isWindows () || TKit .isLinux ()) {
239
- // Needed to make WindowsAppBundler happy as it copies MSVC dlls
240
- // from `bin` directory.
239
+ if (TKit .isLinux ()) {
241
240
// Need to make the code in rpm spec happy as it assumes there is
242
241
// always something in application image.
243
242
fakeRuntimeDir .resolve ("bin" ).toFile ().mkdir ();
@@ -246,7 +245,7 @@ public JPackageCommand setFakeRuntime() {
246
245
if (TKit .isOSX ()) {
247
246
// Make MacAppImageBuilder happy
248
247
createBulkFile .accept (fakeRuntimeDir .resolve (Path .of (
249
- "Contents/Home/ lib/jli/libjli.dylib" )));
248
+ "lib/jli/libjli.dylib" )));
250
249
}
251
250
252
251
// Mak sure fake runtime takes some disk space.
@@ -680,13 +679,56 @@ public Executor.Result executeAndAssertImageCreated() {
680
679
681
680
public JPackageCommand assertImageCreated () {
682
681
verifyIsOfType (PackageType .IMAGE );
682
+ assertAppLayout ();
683
+ return this ;
684
+ }
685
+
686
+ JPackageCommand assertAppLayout () {
687
+ if (isPackageUnpacked () || isImagePackageType ()) {
688
+ final Path rootDir = isPackageUnpacked () ? pathToUnpackedPackageFile (
689
+ appInstallationDirectory ()) : outputBundle ();
690
+ final Path appImageFileName = AppImageFile .getPathInAppImage (
691
+ Path .of ("" )).getFileName ();
692
+ try (Stream <Path > walk = ThrowingSupplier .toSupplier (
693
+ () -> Files .walk (rootDir )).get ()) {
694
+ List <String > appImageFiles = walk
695
+ .filter (path -> path .getFileName ().equals (appImageFileName ))
696
+ .map (Path ::toString )
697
+ .collect (Collectors .toList ());
698
+ if (isImagePackageType () || TKit .isOSX ()) {
699
+ List <String > expected = List .of (
700
+ AppImageFile .getPathInAppImage (rootDir ).toString ());
701
+ TKit .assertStringListEquals (expected , appImageFiles ,
702
+ String .format (
703
+ "Check there is only one file with [%s] name in the package" ,
704
+ appImageFileName ));
705
+ } else {
706
+ TKit .assertStringListEquals (List .of (), appImageFiles ,
707
+ String .format (
708
+ "Check there are no files with [%s] name in the package" ,
709
+ appImageFileName ));
710
+ }
711
+ }
712
+ } else if (TKit .isOSX ()) {
713
+ TKit .assertFileExists (AppImageFile .getPathInAppImage (
714
+ appInstallationDirectory ()));
715
+ } else {
716
+ TKit .assertPathExists (AppImageFile .getPathInAppImage (
717
+ appInstallationDirectory ()), false );
718
+ }
719
+
683
720
TKit .assertDirectoryExists (appRuntimeDirectory ());
684
721
685
722
if (!isRuntime ()) {
686
723
TKit .assertExecutableFileExists (appLauncherPath ());
687
724
TKit .assertFileExists (appLauncherCfgPath (null ));
688
725
}
689
726
727
+ if (TKit .isOSX ()) {
728
+ TKit .assertFileExists (appRuntimeDirectory ().resolve (
729
+ "Contents/MacOS/libjli.dylib" ));
730
+ }
731
+
690
732
return this ;
691
733
}
692
734
@@ -785,14 +827,6 @@ public static String escapeAndJoin(List<String> args) {
785
827
}).collect (Collectors .joining (" " ));
786
828
}
787
829
788
- public static Path relativePathInRuntime (JavaTool tool ) {
789
- Path path = tool .relativePathInJavaHome ();
790
- if (TKit .isOSX ()) {
791
- path = Path .of ("Contents/Home" ).resolve (path );
792
- }
793
- return path ;
794
- }
795
-
796
830
public static Stream <String > filterOutput (Stream <String > jpackageOutput ) {
797
831
// Skip "WARNING: Using incubator ..." first line of output
798
832
return jpackageOutput .skip (1 );
0 commit comments