Browse Source

make junitlauncher use ant.tmpdir as well

master
Stefan Bodewig 5 years ago
parent
commit
041b058c7b
3 changed files with 12 additions and 6 deletions
  1. +4
    -0
      manual/Tasks/junitlauncher.html
  2. +6
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
  3. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java

+ 4
- 0
manual/Tasks/junitlauncher.html View File

@@ -42,6 +42,10 @@
test engine(s) supported by JUnit 5. This task in itself does <i>not</i> understand what a test
case is nor does it execute the tests itself.
</p>
<p>
This task captures testoutput and configuration data inside of
the <a href="../running.html#tmpdir">temporary directory</a>.
</p>
<p>
<strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for


+ 6
- 4
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java View File

@@ -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());
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java View File

@@ -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<String, Object> props = this.getProject().getProperties();
final Properties projProperties = new Properties();
@@ -367,7 +367,7 @@ public class JUnitLauncherTask extends Task {

private java.nio.file.Path newLaunchDefinitionXml() {
return FileUtils.getFileUtils()
.createTempFile(null, ".xml", null, true, true)
.createTempFile(getProject(), null, ".xml", null, true, true)
.toPath();
}



Loading…
Cancel
Save