Author: richard.opalka(a)jboss.com
Date: 2008-01-24 10:40:42 -0500 (Thu, 24 Jan 2008)
New Revision: 5534
Modified:
common/trunk/src/main/java/org/jboss/wsf/test/TCK14ToJunitReportConverter.java
Log:
[JBWS-1962] fixing problem with not released file descriptors + added javadoc
Modified: common/trunk/src/main/java/org/jboss/wsf/test/TCK14ToJunitReportConverter.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/test/TCK14ToJunitReportConverter.java 2008-01-24
14:44:21 UTC (rev 5533)
+++
common/trunk/src/main/java/org/jboss/wsf/test/TCK14ToJunitReportConverter.java 2008-01-24
15:40:42 UTC (rev 5534)
@@ -97,30 +97,52 @@
}
}
+ /**
+ * Converts TCK log to Junit report file
+ * @param pckg package of the test
+ * @param f TCK report file
+ * @throws IOException if some I/O problem occurs
+ */
private static void convertFile(String pckg, File f) throws IOException
{
BufferedReader reader = new BufferedReader(new FileReader(f));
StringBuilder sb = new StringBuilder();
- String line = reader.readLine();
- boolean passed = false;
- while (line != null)
+ boolean testPassed = false;
+ try
{
- if (line.trim().length() > 0)
+ String line = reader.readLine();
+ while (line != null)
{
+ if ((line.trim().length() > 0) && testPassed)
+ {
+ // TCK test passed if and only if the last line in log is 'test
result: Passed'
+ testPassed = false;
+ }
sb.append(line);
sb.append("\n");
- passed = false;
+ if (line.indexOf("test result: Passed") != -1)
+ {
+ testPassed = true;
+ }
+ line = reader.readLine();
}
- if (line.indexOf("test result: Passed") != -1)
- {
- passed = true;
- }
- line = reader.readLine();
}
- createReport(sb.toString(), passed, pckg, f);
+ finally
+ {
+ reader.close();
+ }
+ createJunitReport(sb.toString(), testPassed, pckg, f);
}
- private static void createReport(String consoleOutput, boolean passed, String pckg,
File file) throws IOException
+ /**
+ * Flushes Junit report to the file system
+ * @param consoleOutput TCK log
+ * @param passed indicates whether TCK test passed
+ * @param pckg test package
+ * @param file TCK log file
+ * @throws IOException if some I/O problem occurs
+ */
+ private static void createJunitReport(String consoleOutput, boolean passed, String
pckg, File file) throws IOException
{
String fileName = file.getName().substring(0, file.getName().length() - 4);
StringBuilder sb = new StringBuilder();
@@ -133,11 +155,17 @@
sb.append(" <system-err><![CDATA[]]></system-err>" +
nl);
sb.append("</testsuite>" + nl);
File junitReportFile = new File(junitReportDir, "TEST-" +
pckg.replace('/', '.') + "." + fileName + ".xml");
- System.out.println("Creating JUnit report file " +
junitReportFile.getAbsolutePath());
- FileOutputStream os = new FileOutputStream(junitReportFile);
- os.write(sb.toString().getBytes());
- os.flush();
- os.close();
+ System.out.println("Creating JUnit report file: " +
junitReportFile.getAbsolutePath());
+ FileOutputStream os = null;
+ try
+ {
+ os = new FileOutputStream(junitReportFile);
+ os.write(sb.toString().getBytes());
+ }
+ finally
+ {
+ if (os != null) os.close();
+ }
}
private static String replace(String oldString, String newString, String data)
Show replies by date