2121 * questions.
2222 */
2323
24+ import static java .util .Map .entry ;
2425import static java .util .stream .Collectors .joining ;
2526import static java .util .stream .Collectors .toMap ;
2627import static jdk .internal .util .OperatingSystem .MACOS ;
3435import java .util .Collection ;
3536import java .util .HashSet ;
3637import java .util .List ;
38+ import java .util .Map ;
3739import java .util .Objects ;
3840import java .util .Optional ;
3941import java .util .Set ;
4345import java .util .stream .Stream ;
4446import java .util .stream .StreamSupport ;
4547import jdk .jpackage .internal .util .FileUtils ;
48+ import jdk .jpackage .internal .util .IdentityWrapper ;
4649import jdk .jpackage .internal .util .function .ThrowingSupplier ;
4750import jdk .jpackage .test .Annotations .Parameter ;
4851import jdk .jpackage .test .Annotations .ParameterSupplier ;
@@ -333,7 +336,7 @@ public void verify() {
333336 }
334337 }
335338
336- private record DirectoryVerifier (Path path ) implements PathVerifier {
339+ private record DirectoryVerifier (Path path , IdentityWrapper < Content > origin ) implements PathVerifier {
337340 DirectoryVerifier {
338341 Objects .requireNonNull (path );
339342 }
@@ -394,7 +397,7 @@ public Iterable<PathVerifier> verifiers(Path appContentRoot) {
394397 if (Files .isRegularFile (srcFile )) {
395398 return new RegularFileVerifier (dstFile , srcFile );
396399 } else {
397- return new DirectoryVerifier (dstFile );
400+ return new DirectoryVerifier (dstFile , new IdentityWrapper <>( this ) );
398401 }
399402 }).toList ());
400403 } catch (IOException ex ) {
@@ -410,7 +413,7 @@ public Iterable<PathVerifier> verifiers(Path appContentRoot) {
410413 var cur = appContentPath ;
411414 for (int i = 0 ; i != level ; i ++) {
412415 cur = cur .getParent ();
413- verifiers .add (new DirectoryVerifier (cur ));
416+ verifiers .add (new DirectoryVerifier (cur , new IdentityWrapper <>( this ) ));
414417 }
415418 }
416419
@@ -454,22 +457,38 @@ public String toString() {
454457 }
455458
456459 /**
457- * Creates a content from {@link TKit#TEST_SRC_ROOT} directory.
460+ * Creates a content from a directory tree .
458461 *
459- * @param path source path relative to {@link TKit#TEST_SRC_ROOT} directory
462+ * @param path name of directory where to create a directory tree
460463 */
461- private static ContentFactory createTestSrcContent (Path path ) {
464+ private static ContentFactory createDirTreeContent (Path path ) {
462465 if (path .isAbsolute ()) {
463466 throw new IllegalArgumentException ();
464467 }
465468
466469 return new FileContentFactory (() -> {
467- return TKit .TEST_SRC_ROOT .resolve (path );
470+ var basedir = TKit .createTempDirectory ("content" ).resolve (path );
471+
472+ for (var textFile : Map .ofEntries (
473+ entry ("woods/moose" , "The moose" ),
474+ entry ("woods/bear" , "The bear" ),
475+ entry ("woods/trees/jay" , "The gray jay" )
476+ ).entrySet ()) {
477+ var src = basedir .resolve (textFile .getKey ());
478+ Files .createDirectories (src .getParent ());
479+ TKit .createTextFile (src , Stream .of (textFile .getValue ()));
480+ }
481+
482+ for (var emptyDir : List .of ("sky" )) {
483+ Files .createDirectories (basedir .resolve (emptyDir ));
484+ }
485+
486+ return basedir ;
468487 }, path );
469488 }
470489
471- private static ContentFactory createTestSrcContent (String path ) {
472- return createTestSrcContent (Path .of (path ));
490+ private static ContentFactory createDirTreeContent (String path ) {
491+ return createDirTreeContent (Path .of (path ));
473492 }
474493
475494 /**
@@ -621,9 +640,9 @@ public String toString() {
621640 private final Path pathInAppContentRoot ;
622641 }
623642
624- private static final ContentFactory TEST_JAVA = createTestSrcContent ("apps/PrintEnv.java" );
643+ private static final ContentFactory TEST_JAVA = createTextFileContent ("apps/PrintEnv.java" , "Not what someone would expect " );
625644 private static final ContentFactory TEST_DUKE = createTextFileContent ("duke.txt" , "Hi Duke!" );
626- private static final ContentFactory TEST_DIR = createTestSrcContent ("apps" );
645+ private static final ContentFactory TEST_DIR = createDirTreeContent ("apps" );
627646 private static final ContentFactory TEST_BAD = new NonExistantPath ();
628647
629648 // On OSX `--app-content` paths will be copied into the "Contents" folder
0 commit comments