From: <st...@us...> - 2007-12-12 21:43:28
|
Revision: 5687 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5687&view=rev Author: steve_l Date: 2007-12-12 13:43:26 -0800 (Wed, 12 Dec 2007) Log Message: ----------- SFOS-557 add ant junit report format for xunit test runs constants from ant, new test listener underway Modified Paths: -------------- trunk/core/components/xunit/ivy.xml trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/components.sf Modified: trunk/core/components/xunit/ivy.xml =================================================================== --- trunk/core/components/xunit/ivy.xml 2007-12-12 21:42:45 UTC (rev 5686) +++ trunk/core/components/xunit/ivy.xml 2007-12-12 21:43:26 UTC (rev 5687) @@ -48,10 +48,6 @@ name="sf-tasks" changing="true" rev="latest.integration" conf="build->default"/> -<!-- <dependency org="org.smartfrog" - name="sf-xml" changing="true" - rev="latest.integration" - conf="compile->master;runtime->default"/>--> <dependency org="org.smartfrog" name="sf-testharness" changing="true" rev="latest.integration" @@ -62,6 +58,13 @@ rev="latest.integration" conf="daemon->default;compile->default;runtime->runtime;redist->redist"/> + <!-- ant is pulled in to test the AntXML; if junitreport can handle it, + then it must be OK --> + <dependency org="org.smartfrog" + name="sf-ant" changing="true" + rev="latest.integration" + conf="test->ant-optional"/> + <!--Xom is pulled in for AntXML support. It is mandatory during compile and test, but only needed at runtime if you want the (classic) Ant XML output--> Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java 2007-12-12 21:42:45 UTC (rev 5686) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java 2007-12-12 21:43:26 UTC (rev 5687) @@ -36,9 +36,7 @@ import java.io.OutputStream; import java.rmi.RemoteException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.List; import java.util.TimeZone; import nu.xom.Attribute; import nu.xom.Serializer; @@ -86,9 +84,8 @@ /** * This is built up as we go along */ - private Element root; + private Element root,stdout,stderr; - private List<LogEntry> logEntries; public AntXmlListener(String hostname, File destFile, @@ -103,9 +100,6 @@ } - - - /** * get the filename of this * @@ -127,7 +121,8 @@ public synchronized void open() throws IOException, RemoteException { root = new Element(TESTSUITES); document=new Document(root); - logEntries=new ArrayList<LogEntry>(); + stdout=new Element(XMLConstants.SYSTEM_OUT); + stderr=new Element(XMLConstants.SYSTEM_OUT); maybeAddAttribute(root, XMLConstants.HOSTNAME, hostname); maybeAddAttribute(root, XMLConstants.ATTR_NAME, suitename); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); @@ -156,7 +151,8 @@ } finally { //cleanup document=null; - logEntries=null; + stdout=null; + stderr=null; } } @@ -203,8 +199,6 @@ } } } - - } @@ -283,7 +277,10 @@ * @throws RemoteException on network trouble */ public void log(LogEntry event) throws RemoteException { - logEntries.add(event); + String text = event.logString(); + Element target; + target = (event.getLevel() == LogEntry.LOG_LEVEL_STDERR) ? stderr : stdout; + target.appendChild(text); stats.incLoggedMessages(); } /** @@ -344,10 +341,7 @@ } } - - - /* This is what a single, complex test case looks like. @@ -415,14 +409,6 @@ //process the fault ThrowableTraceInfo fault = test.getFault(); if (fault != null) { -// StackTraceElement[] stack = fault.getStack(); -// StringBuilder trace = new StringBuilder(); -// for (StackTraceElement elt : stack) { -// trace.append(elt.toString()); -// trace.append('\n'); -// } -// Element thrown = addElement(testcase, type, fault.toString() -// +"\n"+trace.toString()); Element thrown = addElement(testcase, type, fault.toString()); maybeAddAttribute(thrown, XMLConstants.ATTR_MESSAGE, @@ -434,16 +420,14 @@ } /** - * Run through the log creating all the entries + * append the log elements if they are not already in the document */ void addLogEntries() { - Element stdout=addElement(XMLConstants.SYSTEM_OUT, null); - Element stderr=addElement(XMLConstants.SYSTEM_OUT, null); - for(LogEntry entry:logEntries) { - String text=entry.logString(); - Element target; - target=(entry.getLevel()==LogEntry.LOG_LEVEL_STDERR)?stderr:stdout; - target.appendChild(text); + if(stdout.getParent()==null) { + root.appendChild(stdout); } + if(stderr.getParent()==null) { + root.appendChild(stderr); + } } } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf 2007-12-12 21:42:45 UTC (rev 5686) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf 2007-12-12 21:43:26 UTC (rev 5687) @@ -27,15 +27,29 @@ */ #include "/org/smartfrog/components.sf" + /** + * Schema for test listeners + */ +TestListenerSchema extends Schema { + name extends String; +} + +/** + * Schema for directory driven test listeners + */ +DirectoryBasedTestListenerSchema extends Schema { + outputDirectory extends FilenameType ; + name extends String; +} + + +/** * this is a declaration of a test listener */ TestListener extends Prim { - - testListenerSchema extends Schema { - name extends String; - } + testListenerSchema extends TestListenerSchema ; } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/components.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/components.sf 2007-12-12 21:42:45 UTC (rev 5686) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/components.sf 2007-12-12 21:43:26 UTC (rev 5687) @@ -38,14 +38,13 @@ XmlTestIndex extends Prim { sfClass "org.smartfrog.services.xunit.listeners.XmlTestIndexImpl"; xmlTestIndexSchema extends XmlTestIndexSchema; + name "XmlTestIndex"; } /** * XML listener is the most complex beast */ -XmlListenerSchema extends Schema { -/** output directories are compulsory and can be a path or a File ref*/ - outputDirectory extends FilenameType ; +XmlListenerSchema extends DirectoryBasedTestListenerSchema { //outputFile extends Compulsory ; //XML preamble: comments, XSLT references, etc. preamble extends OptionalString; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |