incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1401948 - /incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
Date Thu, 25 Oct 2012 01:59:50 GMT
Author: liuzhe
Date: Thu Oct 25 01:59:50 2012
New Revision: 1401948

URL: http://svn.apache.org/viewvc?rev=1401948&view=rev
Log:
Fixed: Some properties are not generated if testing is terminated before finishing all tests


Modified:
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java?rev=1401948&r1=1401947&r2=1401948&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
(original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
Thu Oct 25 01:59:50 2012
@@ -32,7 +32,12 @@ import org.junit.runner.notification.Fai
 import org.junit.runner.notification.RunListener;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
+/**
+ * Generate XML test report
+ *
+ */
 public class XMLReporter extends RunListener {
 
 	private File outputDir = Testspace.getFile("output");
@@ -152,33 +157,37 @@ public class XMLReporter extends RunList
 	}
 	
 	private void finishSuite() {
-		testsuiteEl.setAttribute("time", Double.toString((System.currentTimeMillis() - testStart)
/ 1000.0));
-		testsuiteEl.setAttribute("failures", Long.toString(failures));
-		testsuiteEl.setAttribute("errors", Long.toString(errors));
-		testsuiteEl.setAttribute("tests", Long.toString(tests));
-		testsuiteEl.setAttribute("ignored", Long.toString(ignored));
-		Element props = doc.createElement("properties");
-		testsuiteEl.appendChild(props);
-		// Add some extra information
-		System.setProperty("info.os.name", SystemUtil.getOSName());
-		System.setProperty("info.os.version", SystemUtil.getOSVersion());
-		System.setProperty("info.os.arch", SystemUtil.getOSArch());
-		System.setProperty("info.os.arch", SystemUtil.getOSArch());
-		System.setProperty("info.ip", SystemUtil.getIPAddress());
-		System.setProperty("info.hostname", SystemUtil.getHostName());
-		Set<Entry<Object, Object>> entries = System.getProperties().entrySet();
-		for (Entry<Object, Object> e : entries) {
-			Element prop = doc.createElement("property");
-			prop.setAttribute("name", "" + e.getKey());
-			prop.setAttribute("value", "" + e.getValue());
-			props.appendChild(prop);
-		}
-		
 		store();
 	}
 
 	private void store() {
 		if (doc != null) {
+			testsuiteEl.setAttribute("time", Double.toString((System.currentTimeMillis() - testStart)
/ 1000.0));
+			testsuiteEl.setAttribute("failures", Long.toString(failures));
+			testsuiteEl.setAttribute("errors", Long.toString(errors));
+			testsuiteEl.setAttribute("tests", Long.toString(tests));
+			testsuiteEl.setAttribute("ignored", Long.toString(ignored));
+			NodeList els = testsuiteEl.getElementsByTagName("properties");
+			if (els.getLength() > 0) 
+				testsuiteEl.removeChild(els.item(0));
+			
+			Element props = doc.createElement("properties");
+			testsuiteEl.appendChild(props);
+			// Add some extra information
+			System.setProperty("info.os.name", SystemUtil.getOSName());
+			System.setProperty("info.os.version", SystemUtil.getOSVersion());
+			System.setProperty("info.os.arch", SystemUtil.getOSArch());
+			System.setProperty("info.os.arch", SystemUtil.getOSArch());
+			System.setProperty("info.ip", SystemUtil.getIPAddress());
+			System.setProperty("info.hostname", SystemUtil.getHostName());
+			Set<Entry<Object, Object>> entries = System.getProperties().entrySet();
+			for (Entry<Object, Object> e : entries) {
+				Element prop = doc.createElement("property");
+				prop.setAttribute("name", "" + e.getKey());
+				prop.setAttribute("value", "" + e.getValue());
+				props.appendChild(prop);
+			}
+			
 			FileUtil.storeXML(doc, file);
 			File htmlFile = new File(outputDir, "result.html");
 			InputStream is = getClass().getResourceAsStream("XMLReporter.xsl");



Mime
View raw message