< prev index next >
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
Print this page
*** 50,67 ****
public static final Path TEST_SRC_ROOT = Functional.identity(() -> {
Path root = Path.of(System.getProperty("test.src"));
for (int i = 0; i != 10; ++i) {
if (root.resolve("apps").toFile().isDirectory()) {
! return root.toAbsolutePath();
}
root = root.resolve("..");
}
throw new RuntimeException("Failed to locate apps directory");
}).get();
public final static String ICON_SUFFIX = Functional.identity(() -> {
if (isOSX()) {
return ".icns";
}
--- 50,71 ----
public static final Path TEST_SRC_ROOT = Functional.identity(() -> {
Path root = Path.of(System.getProperty("test.src"));
for (int i = 0; i != 10; ++i) {
if (root.resolve("apps").toFile().isDirectory()) {
! return root.normalize().toAbsolutePath();
}
root = root.resolve("..");
}
throw new RuntimeException("Failed to locate apps directory");
}).get();
+ public static final Path SRC_ROOT = Functional.identity(() -> {
+ return TEST_SRC_ROOT.resolve("../../../../src/jdk.incubator.jpackage").normalize().toAbsolutePath();
+ }).get();
+
public final static String ICON_SUFFIX = Functional.identity(() -> {
if (isOSX()) {
return ".icns";
}
*** 148,165 ****
public static Path workDir() {
return currentTest.workDir();
}
- static Path defaultInputDir() {
- return workDir().resolve("input");
- }
-
- static Path defaultOutputDir() {
- return workDir().resolve("output");
- }
-
static String getCurrentDefaultAppName() {
// Construct app name from swapping and joining test base name
// and test function name.
// Say the test name is `FooTest.testBasic`. Then app name would be `BasicFooTest`.
String appNamePrefix = currentTest.functionName();
--- 152,161 ----
*** 273,294 ****
return Files.createTempDirectory(workDir(), TEMP_FILE_PREFIX);
}
return Files.createDirectory(createUniqueFileName(role));
}
! public static Path createTempFile(String role, String suffix) throws
IOException {
! if (role == null) {
! return Files.createTempFile(workDir(), TEMP_FILE_PREFIX, suffix);
! }
! return Files.createFile(createUniqueFileName(role));
}
! public static Path withTempFile(String role, String suffix,
ThrowingConsumer<Path> action) {
final Path tempFile = ThrowingSupplier.toSupplier(() -> createTempFile(
! role, suffix)).get();
boolean keepIt = true;
try {
ThrowingConsumer.toConsumer(action).accept(tempFile);
keepIt = false;
return tempFile;
--- 269,288 ----
return Files.createTempDirectory(workDir(), TEMP_FILE_PREFIX);
}
return Files.createDirectory(createUniqueFileName(role));
}
! public static Path createTempFile(Path templateFile) throws
IOException {
! return Files.createFile(createUniqueFileName(
! templateFile.getFileName().toString()));
}
! public static Path withTempFile(Path templateFile,
ThrowingConsumer<Path> action) {
final Path tempFile = ThrowingSupplier.toSupplier(() -> createTempFile(
! templateFile)).get();
boolean keepIt = true;
try {
ThrowingConsumer.toConsumer(action).accept(tempFile);
keepIt = false;
return tempFile;
*** 447,460 ****
currentTest.notifySkipped(ex);
throw ex;
}
public static Path createRelativePathCopy(final Path file) {
! Path fileCopy = workDir().resolve(file.getFileName()).toAbsolutePath().normalize();
!
! ThrowingRunnable.toRunnable(() -> Files.copy(file, fileCopy,
! StandardCopyOption.REPLACE_EXISTING)).run();
final Path basePath = Path.of(".").toAbsolutePath().normalize();
try {
return basePath.relativize(fileCopy);
} catch (IllegalArgumentException ex) {
--- 441,455 ----
currentTest.notifySkipped(ex);
throw ex;
}
public static Path createRelativePathCopy(final Path file) {
! Path fileCopy = ThrowingSupplier.toSupplier(() -> {
! Path localPath = createTempFile(file);
! Files.copy(file, localPath, StandardCopyOption.REPLACE_EXISTING);
! return localPath;
! }).get().toAbsolutePath().normalize();
final Path basePath = Path.of(".").toAbsolutePath().normalize();
try {
return basePath.relativize(fileCopy);
} catch (IllegalArgumentException ex) {
*** 711,746 ****
"Actual list is longer than expected by %d elements",
expected.size() - actual.size()), msg));
}
}
! public final static class TextStreamAsserter {
! TextStreamAsserter(String value) {
this.value = value;
predicate(String::contains);
}
! public TextStreamAsserter label(String v) {
label = v;
return this;
}
! public TextStreamAsserter predicate(BiPredicate<String, String> v) {
predicate = v;
return this;
}
! public TextStreamAsserter negate() {
negate = true;
return this;
}
! public TextStreamAsserter orElseThrow(RuntimeException v) {
return orElseThrow(() -> v);
}
! public TextStreamAsserter orElseThrow(Supplier<RuntimeException> v) {
createException = v;
return this;
}
public void apply(Stream<String> lines) {
--- 706,741 ----
"Actual list is longer than expected by %d elements",
expected.size() - actual.size()), msg));
}
}
! public final static class TextStreamVerifier {
! TextStreamVerifier(String value) {
this.value = value;
predicate(String::contains);
}
! public TextStreamVerifier label(String v) {
label = v;
return this;
}
! public TextStreamVerifier predicate(BiPredicate<String, String> v) {
predicate = v;
return this;
}
! public TextStreamVerifier negate() {
negate = true;
return this;
}
! public TextStreamVerifier orElseThrow(RuntimeException v) {
return orElseThrow(() -> v);
}
! public TextStreamVerifier orElseThrow(Supplier<RuntimeException> v) {
createException = v;
return this;
}
public void apply(Stream<String> lines) {
*** 777,788 ****
private boolean negate;
private Supplier<RuntimeException> createException;
final private String value;
}
! public static TextStreamAsserter assertTextStream(String what) {
! return new TextStreamAsserter(what);
}
private static PrintStream openLogStream() {
if (LOG_FILE == null) {
return null;
--- 772,783 ----
private boolean negate;
private Supplier<RuntimeException> createException;
final private String value;
}
! public static TextStreamVerifier assertTextStream(String what) {
! return new TextStreamVerifier(what);
}
private static PrintStream openLogStream() {
if (LOG_FILE == null) {
return null;
*** 807,823 ****
static String getConfigPropertyName(String propertyName) {
return "jpackage.test." + propertyName;
}
! static Set<String> tokenizeConfigProperty(String propertyName) {
final String val = TKit.getConfigProperty(propertyName);
if (val == null) {
return null;
}
! return Stream.of(val.toLowerCase().split(",")).map(String::strip).filter(
! Predicate.not(String::isEmpty)).collect(Collectors.toSet());
}
static final Path LOG_FILE = Functional.identity(() -> {
String val = getConfigProperty("logfile");
if (val == null) {
--- 802,828 ----
static String getConfigPropertyName(String propertyName) {
return "jpackage.test." + propertyName;
}
! static List<String> tokenizeConfigPropertyAsList(String propertyName) {
final String val = TKit.getConfigProperty(propertyName);
if (val == null) {
return null;
}
! return Stream.of(val.toLowerCase().split(","))
! .map(String::strip)
! .filter(Predicate.not(String::isEmpty))
! .collect(Collectors.toList());
! }
!
! static Set<String> tokenizeConfigProperty(String propertyName) {
! List<String> tokens = tokenizeConfigPropertyAsList(propertyName);
! if (tokens == null) {
! return null;
! }
! return tokens.stream().collect(Collectors.toSet());
}
static final Path LOG_FILE = Functional.identity(() -> {
String val = getConfigProperty("logfile");
if (val == null) {
< prev index next >