git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@421327 13f79535-47bb-0310-9956-ffa450edef68master
@@ -115,6 +115,16 @@ | |||||
</junitreport> | </junitreport> | ||||
</target> | </target> | ||||
<target name="testNoFrames"> | |||||
<mkdir dir="${outputdir}/html"/> | |||||
<junitreport todir="${outputdir}"> | |||||
<fileset dir="${jrdir}"> | |||||
<include name="TEST-*.xml"/> | |||||
</fileset> | |||||
<report todir="${outputdir}/html" format="noframes"/> | |||||
</junitreport> | |||||
</target> | |||||
<target name="testWithStyleFromDir"> | <target name="testWithStyleFromDir"> | ||||
<mkdir dir="${outputdir}/html"/> | <mkdir dir="${outputdir}/html"/> | ||||
<junitreport todir="${outputdir}"> | <junitreport todir="${outputdir}"> | ||||
@@ -126,7 +136,7 @@ | |||||
format="frames"/> | format="frames"/> | ||||
</junitreport> | </junitreport> | ||||
</target> | </target> | ||||
<!-- bug report 40022 --> | <!-- bug report 40022 --> | ||||
<target name="testWithStyleFromDirAndXslImport"> | <target name="testWithStyleFromDirAndXslImport"> | ||||
<mkdir dir="${outputdir}/html"/> | <mkdir dir="${outputdir}/html"/> | ||||
@@ -224,12 +224,6 @@ public class AggregateTransformer { | |||||
TempFile tempFileTask = new TempFile(); | TempFile tempFileTask = new TempFile(); | ||||
tempFileTask.bindToOwner(task); | tempFileTask.bindToOwner(task); | ||||
String tempFileProperty = getClass().getName() + String.valueOf(counter++); | |||||
File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), | |||||
project.getProperty("java.io.tmpdir")); | |||||
tempFileTask.setDestDir(tmp); | |||||
tempFileTask.setProperty(tempFileProperty); | |||||
tempFileTask.execute(); | |||||
XSLTProcess xsltTask = new XSLTProcess(); | XSLTProcess xsltTask = new XSLTProcess(); | ||||
xsltTask.bindToOwner(task); | xsltTask.bindToOwner(task); | ||||
@@ -237,8 +231,19 @@ public class AggregateTransformer { | |||||
xsltTask.addConfigured(getStylesheet()); | xsltTask.addConfigured(getStylesheet()); | ||||
// acrobatic cast. | // acrobatic cast. | ||||
xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); | xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); | ||||
File dummyFile = new File(project.getProperty(tempFileProperty)); | |||||
xsltTask.setOut(dummyFile); | |||||
File outputFile = null; | |||||
if (format.equals(FRAMES)) { | |||||
String tempFileProperty = getClass().getName() + String.valueOf(counter++); | |||||
File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), | |||||
project.getProperty("java.io.tmpdir")); | |||||
tempFileTask.setDestDir(tmp); | |||||
tempFileTask.setProperty(tempFileProperty); | |||||
tempFileTask.execute(); | |||||
outputFile = new File(project.getProperty(tempFileProperty)); | |||||
} else { | |||||
outputFile = new File(toDir, "junit-noframes.html"); | |||||
} | |||||
xsltTask.setOut(outputFile); | |||||
for (Iterator i = params.iterator(); i.hasNext();) { | for (Iterator i = params.iterator(); i.hasNext();) { | ||||
XSLTProcess.Param param = (XSLTProcess.Param) i.next(); | XSLTProcess.Param param = (XSLTProcess.Param) i.next(); | ||||
XSLTProcess.Param newParam = xsltTask.createParam(); | XSLTProcess.Param newParam = xsltTask.createParam(); | ||||
@@ -259,10 +264,12 @@ public class AggregateTransformer { | |||||
} | } | ||||
final long dt = System.currentTimeMillis() - t0; | final long dt = System.currentTimeMillis() - t0; | ||||
task.log("Transform time: " + dt + "ms"); | task.log("Transform time: " + dt + "ms"); | ||||
Delete delete = new Delete(); | |||||
delete.bindToOwner(task); | |||||
delete.setFile(dummyFile); | |||||
delete.execute(); | |||||
if (format.equals(FRAMES)) { | |||||
Delete delete = new Delete(); | |||||
delete.bindToOwner(task); | |||||
delete.setFile(outputFile); | |||||
delete.execute(); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -38,7 +38,7 @@ public class FileResource extends Resource implements Touchable { | |||||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
private static final int NULL_FILE | private static final int NULL_FILE | ||||
= Resource.getMagicNumber("null file".getBytes()); | = Resource.getMagicNumber("null file".getBytes()); | ||||
private File file; | private File file; | ||||
private File baseDir; | private File baseDir; | ||||
@@ -150,6 +150,19 @@ public class JUnitReportTest extends BuildFileTest { | |||||
assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); | assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); | ||||
} | } | ||||
//Bugzilla Report 40021 | |||||
public void testNoFrames() throws Exception { | |||||
executeTarget("testNoFrames"); | |||||
File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html"); | |||||
// tests one the file object | |||||
assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); | |||||
assertTrue("Cant read the report file.", reportFile.canRead() ); | |||||
assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); | |||||
// conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |||||
URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |||||
InputStream reportStream = reportUrl.openStream(); | |||||
assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); | |||||
} | |||||
//Bugzilla Report 39708 | //Bugzilla Report 39708 | ||||
public void testWithStyleFromDirAndXslImport() throws Exception { | public void testWithStyleFromDirAndXslImport() throws Exception { | ||||
executeTarget("testWithStyleFromDirAndXslImport"); | executeTarget("testWithStyleFromDirAndXslImport"); | ||||