stevel 2004/04/14 08:19:13
Modified: src/main/org/apache/tools/ant/taskdefs/optional/junit
XMLJUnitResultFormatter.java XMLConstants.java
Log:
new attributes for the tests: hostname and timestamp.
Revision Changes Path
1.36 +23 -0
ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
Index: XMLJUnitResultFormatter.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XMLJUnitResultFormatter.java 9 Mar 2004 16:48:31 -0000 1.35
+++ XMLJUnitResultFormatter.java 14 Apr 2004 15:19:13 -0000 1.36
@@ -25,12 +25,16 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
+import java.util.Date;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.DOMElementWriter;
+import org.apache.tools.ant.util.DateUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
@@ -100,6 +104,13 @@
rootElement = doc.createElement(TESTSUITE);
rootElement.setAttribute(ATTR_NAME, suite.getName());
+ //add the timestamp
+ final String timestamp = DateUtils.format(new Date(),
+ DateUtils.ISO8601_DATETIME_PATTERN);
+ rootElement.setAttribute(TIMESTAMP,timestamp);
+ //and the hostname.
+ rootElement.setAttribute(HOSTNAME,getHostname());
+
// Output properties
Element propsElement = doc.createElement(PROPERTIES);
rootElement.appendChild(propsElement);
@@ -113,6 +124,18 @@
propElement.setAttribute(ATTR_VALUE,
props.getProperty(name));
propsElement.appendChild(propElement);
}
+ }
+ }
+
+ /**
+ * get the local hostname
+ * @return the name of the local host, or "localhost" if we cannot work
it out
+ */
+ private String getHostname() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ return "localhost";
}
}
1.12 +9 -0
ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLConstants.java
Index: XMLConstants.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLConstants.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XMLConstants.java 9 Mar 2004 16:48:31 -0000 1.11
+++ XMLConstants.java 14 Apr 2004 15:19:13 -0000 1.12
@@ -86,4 +86,13 @@
/** classname attribute for testcase elements */
String ATTR_CLASSNAME = "classname";
+ /**
+ * timestamp of test cases
+ */
+ String TIMESTAMP = "timestamp";
+
+ /**
+ * name of host running the tests
+ */
+ String HOSTNAME = "hostname";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]