diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index 25d9fcce5..ec14e0357 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -42,6 +42,10 @@ test engine(s) supported by JUnit 5. This task in itself does not understand what a test case is nor does it execute the tests itself.
++ This task captures testoutput and configuration data inside of + the temporary directory. +
Note: This task depends on external libraries not included in the Apache Ant
distribution. See Library Dependencies for
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
index dc9847d2a..22a11e095 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
@@ -53,7 +53,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
@Override
public void sysOutAvailable(final byte[] data) {
if (this.sysOutStore == null) {
- this.sysOutStore = new SysOutErrContentStore(true);
+ this.sysOutStore = new SysOutErrContentStore(context, true);
}
try {
this.sysOutStore.store(data);
@@ -65,7 +65,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
@Override
public void sysErrAvailable(final byte[] data) {
if (this.sysErrStore == null) {
- this.sysErrStore = new SysOutErrContentStore(false);
+ this.sysErrStore = new SysOutErrContentStore(context, false);
}
try {
this.sysErrStore.store(data);
@@ -212,13 +212,15 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
}
};
+ private final TestExecutionContext context;
private final String tmpFileSuffix;
private ByteBuffer inMemoryStore = ByteBuffer.allocate(DEFAULT_CAPACITY_IN_BYTES);
private boolean usingFileStore = false;
private Path filePath;
private FileOutputStream fileOutputStream;
- private SysOutErrContentStore(final boolean isSysOut) {
+ private SysOutErrContentStore(final TestExecutionContext context, final boolean isSysOut) {
+ this.context = context;
this.tmpFileSuffix = isSysOut ? ".sysout" : ".syserr";
}
@@ -261,7 +263,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
private FileOutputStream createFileStore() throws IOException {
this.filePath = FileUtils.getFileUtils()
- .createTempFile(null, this.tmpFileSuffix, null, true, true)
+ .createTempFile(context.getProject().orElse(null), null, this.tmpFileSuffix, null, true, true)
.toPath();
return new FileOutputStream(this.filePath.toFile());
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
index 0d16ed082..fa28844e7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -226,7 +226,7 @@ public class JUnitLauncherTask extends Task {
private java.nio.file.Path dumpProjectProperties() throws IOException {
final java.nio.file.Path propsPath = FileUtils.getFileUtils()
- .createTempFile(null, "properties", null, true, true)
+ .createTempFile(getProject(), null, "properties", null, true, true)
.toPath();
final Hashtable