From: <st...@us...> - 2008-02-08 16:25:20
|
Revision: 5890 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5890&view=rev Author: steve_l Date: 2008-02-08 08:25:16 -0800 (Fri, 08 Feb 2008) Log Message: ----------- SFOS-659 make TestRunnerImpl a subclass of EventCompoundImpl SFOS-557 add ant junit report format for xunit test runs Modified Paths: -------------- trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/ChainListenerImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf trunk/core/components/xunit/test/org/smartfrog/services/sfunit/test/system/antxml/components.sf Added Paths: ----------- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf Modified: trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -146,7 +146,6 @@ //now start anything that is not a test for (Prim elem:sfChildList()) { - if (!(elem instanceof TestBlock)) { elem.sfStart(); } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -39,7 +39,7 @@ * Its key feature is that it provides a thread local context variable that can be used to retrieve the current * context of a running test. * - * Because it extends ConditionCompound, it has the event workflow lifecycle, and the + * Because it extends ConditionCompound, it has the event workflow lifecycle * created 10-Oct-2006 11:39:29 */ @@ -72,7 +72,6 @@ +"or the tests are themselves deploying tests."; /** * Error Text - * </p> * {@value} */ public static final String ERROR_OVERWRITING_SELF = "The component is overwriting its own configuration"; @@ -180,6 +179,9 @@ } } + /** + * Reset our test suite context + */ private void resetTestSuiteContext() { getTestSuiteContext().set(null); } @@ -228,40 +230,6 @@ } /** - * flatten a string list, validating type as we go. recurses as much as we - * need to. At its most efficient if no flattening is needed. - * - * @param src source list - * @param listName name of the list, for reporting errors - * @return a flatter list - * @throws SmartFrogInitException if there is an element that is not of the right type - */ - public List<String> flattenStringList(List src, String listName) - throws SmartFrogInitException { - if (src == null) { - return new ArrayList<String>(0); - } - List<String> dest = new ArrayList<String>(src.size()); - for(Object element:src) { - if (element instanceof List) { - List<String> l2 = flattenStringList((List) element, listName); - for (String s:l2) { - dest.add(s); - } - } else if (!(element instanceof String)) { - throw new SmartFrogInitException("An element in " - + - listName + - " is not string or a list: " + - element.toString() + " class=" + element.getClass()); - } else { - dest.add((String) element); - } - } - return dest; - } - - /** * Get the test listener factory from this configuration * @return the test listener factory */ Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -31,6 +31,7 @@ import org.smartfrog.sfcore.utils.ComponentHelper; import org.smartfrog.sfcore.utils.ShouldDetachOrTerminate; import org.smartfrog.sfcore.utils.SmartFrogThread; +import org.smartfrog.sfcore.workflow.eventbus.EventCompoundImpl; import org.smartfrog.services.xunit.serial.Statistics; import org.smartfrog.services.xunit.serial.ThrowableTraceInfo; import org.smartfrog.services.xunit.log.TestListenerLog; @@ -49,7 +50,7 @@ * has been written for TestBlock instances. */ -public class TestRunnerImpl extends CompoundImpl implements TestRunner, +public class TestRunnerImpl extends EventCompoundImpl implements TestRunner, Runnable, TestBlock { private Log log; @@ -108,9 +109,13 @@ */ private RunnerConfiguration configuration = new RunnerConfiguration(); + /** Error text {@value} */ public static final String ERROR_TESTS_IN_PROGRESS = "Component is already running tests"; + /** Error text {@value} */ public static final String TESTS_FAILED = "Tests Failed"; - private static final String TEST_WAS_INTERRUPTED = "Test was interrupted"; + /** Error text {@value} */ + public static final String TEST_WAS_INTERRUPTED = "Test was interrupted"; + private Prim listenerPrim; /** * constructor @@ -121,6 +126,15 @@ helper = new ComponentHelper(this); } + + /** + * {@inheritDoc} + * @return false, always + */ + @Override + protected boolean isOldNotationSupported() { + return false; + } private synchronized SmartFrogThread getWorker() { return worker; } @@ -167,18 +181,21 @@ */ public synchronized void sfStart() throws SmartFrogException, RemoteException { - //this will deploy all our children, including the test suites + // super.sfStart(); + //create and deploy all the children + synchCreateChildren(); + //now start working with them name = sfCompleteName(); - Object o = sfResolve(ATTR_LISTENER, - configuration.getListenerFactory(), + listenerPrim = sfResolve(ATTR_LISTENER, + (Prim)configuration.getListenerFactory(), true); - if (!(o instanceof TestListenerFactory)) { + if (!(listenerPrim instanceof TestListenerFactory)) { throw new SmartFrogException("The attribute " + ATTR_LISTENER - + "must refer to an implementation of TestListenerFactory"); + + " must refer to an implementation of TestListenerFactory"); } - TestListenerFactory listenerFactory = (TestListenerFactory) o; + TestListenerFactory listenerFactory = (TestListenerFactory) listenerPrim; String listenerName = ((Prim) listenerFactory).sfResolve( TestListenerFactory.ATTR_NAME, "", @@ -405,7 +422,7 @@ * * @param testSuite test suite to patch * @throws RemoteException network trouble - * @throws SmartFrogException other problems + * @throws SmartFrogRuntimeException other problems */ private synchronized void updateResultAttributes(Prim testSuite) throws SmartFrogRuntimeException, RemoteException { Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/ChainListenerImpl.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/ChainListenerImpl.java 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/ChainListenerImpl.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -24,6 +24,8 @@ import org.smartfrog.services.xunit.base.TestSuite; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.compound.CompoundImpl; import java.rmi.RemoteException; import java.util.ArrayList; @@ -35,7 +37,7 @@ * created 21-Apr-2006 11:27:58 */ -public class ChainListenerImpl extends PrimImpl implements TestListenerFactory { +public class ChainListenerImpl extends CompoundImpl implements TestListenerFactory { /** * The name of a factory @@ -83,6 +85,13 @@ TestListenerFactory factory = (TestListenerFactory) elt; factories.add(factory); } + //the children are live, so let's add them to the listener list. + for (Prim child : sfChildList()) { + if (child instanceof TestListenerFactory) { + factories.add((TestListenerFactory) child); + } + } + } /** 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 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -30,6 +30,7 @@ import org.smartfrog.services.xunit.serial.Statistics; import org.smartfrog.services.xunit.serial.TestInfo; import org.smartfrog.services.xunit.serial.ThrowableTraceInfo; +import org.smartfrog.services.filesystem.FileSystem; import org.smartfrog.sfcore.common.SmartFrogException; import java.io.BufferedOutputStream; @@ -191,13 +192,7 @@ out.flush(); out.close(); } finally { - if(out!=null) { - try { - out.close(); - } catch (IOException ignored) { - - } - } + FileSystem.close(out); } } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java 2008-02-08 16:25:16 UTC (rev 5890) @@ -1,3 +1,35 @@ +/* (C) Copyright 2008 Hewlett-Packard Development Company, LP + +Disclaimer of Warranty + +The Software is provided "AS IS," without a warranty of any kind. ALL +EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, +INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY +EXCLUDED. SmartFrog is not a Hewlett-Packard Product. The Software has +not undergone complete testing and may contain errors and defects. It +may not function properly and is subject to change or withdrawal at +any time. The user must assume the entire risk of using the +Software. No support or maintenance is provided with the Software by +Hewlett-Packard. Do not install the Software if you are not accustomed +to using experimental software. + +Limitation of Liability + +TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL HEWLETT-PACKARD +OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR +FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, +HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF +OR RELATED TO THE FURNISHING, PERFORMANCE, OR USE OF THE SOFTWARE, OR +THE INABILITY TO USE THE SOFTWARE, EVEN IF HEWLETT-PACKARD HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. FURTHERMORE, SINCE THE +SOFTWARE IS PROVIDED WITHOUT CHARGE, YOU AGREE THAT THERE HAS BEEN NO +BARGAIN MADE FOR ANY ASSUMPTIONS OF LIABILITY OR DAMAGES BY +HEWLETT-PACKARD FOR ANY REASON WHATSOEVER, RELATING TO THE SOFTWARE OR +ITS MEDIA, AND YOU HEREBY WAIVE ANY CLAIM IN THIS REGARD. + +*/ + package org.smartfrog.services.xunit.listeners.antxml; import org.smartfrog.services.xunit.listeners.xml.AbstractXmlListenerComponent; @@ -24,6 +56,7 @@ <system-err><![CDATA[]]></system-err> * */ + /** * This is a listener of tests * Implement the {@link XmlListenerFactory} interface and so provide a component Added: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf (rev 0) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf 2008-02-08 16:25:16 UTC (rev 5890) @@ -0,0 +1,52 @@ +/** (C) Copyright 1998-2006 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ + + + /** + * adds ant XML output + */ +#include "/org/smartfrog/services/xunit/listeners/xml/components.sf" + + +/** + * any extra schema + */ + +AntXmlTestListenerSchema extends Schema { + + +} + + +/** + */ +AntXmlTestListener extends XmlListener { + sfClass "org.smartfrog.services.xunit.listeners.antxml.AntXmlTestListenerComponent"; + antxmlListenerSchema extends AntXmlTestListenerSchema; + htmlTestListenerSchema extends HtmlTestListenerSchema; + name "AntXmlTestListener"; + suffix ".xml"; + useProcessname false; + useHostname false; + publishFrequency 30; + preamble "<!-- generated by SmartFrog -->"; +} + + 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 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/components.sf 2008-02-08 16:25:16 UTC (rev 5890) @@ -98,9 +98,14 @@ ChainListener extends TestListener { sfClass "org.smartfrog.services.xunit.listeners.ChainListenerImpl"; name "ChainListener"; + chainListenerSchema extends Schema { + //this is a list of deployed listeners listeners extends Vector ; } + listeners []; + + //you can also add any child as a listener; it will be deployed and added to the list } Modified: trunk/core/components/xunit/test/org/smartfrog/services/sfunit/test/system/antxml/components.sf =================================================================== --- trunk/core/components/xunit/test/org/smartfrog/services/sfunit/test/system/antxml/components.sf 2008-02-08 16:23:13 UTC (rev 5889) +++ trunk/core/components/xunit/test/org/smartfrog/services/sfunit/test/system/antxml/components.sf 2008-02-08 16:25:16 UTC (rev 5890) @@ -24,53 +24,58 @@ #include "/org/smartfrog/services/assertions/components.sf" -sfUnit extends SFUnitTestSuite { - listener extends ConsoleListener; +//these are components we run underneath +SimpleTestCompound extends ExpectTerminate { + action extends Sequence { + } } +FailingTestCompound extends TestCompound { + action extends FailAbnormal; +} + + + antxml extends AntXmlTestListener { outputDirectory PROPERTY test.reports.dir; } -sfUnitAntXml extends sfUnit { - listener extends antxml; -} +testRunnerAntXml extends TestRunner { + description "lots of tests"; -SimpleTestCompound extends TestCompound { - action extends Sequence { - } -} + sfShouldTerminate true; -Failure extends FailAbnormal; + listener extends ChainListener { + console extends ConsoleListener; -FailingTestCompound extends TestCompound { - action extends Failure; -} + dataDir extends Mkdir { + parentDir PROPERTY test.data.dir; + dir "sfdata"; + } -TestSFUnit extends ExpectTerminate { - - action extends sfUnit { - etc extends SimpleTestCompound; + ant extends antxml { + outputDirectory LAZY dataDir; + } } -} + tests1 extends SFUnitTestSuite { + name "tests1"; + description "run some basic tests"; + one extends SimpleTestCompound; + two extends FailingTestCompound; - -testSFUnit extends ExpectTerminate { - action extends sfUnit { - etc extends SimpleTestCompound; } } - -testSFUnitAntXml extends ExpectTerminate { - action extends sfUnitAntXml { - etc extends SimpleTestCompound; +testSFUnitAntXmlNested extends ExpectTerminate { + action extends testRunnerAntXml { } } +testSFUnitAntXml extends testRunnerAntXml { +} @@ -78,3 +83,4 @@ + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |