Author: julien(a)jboss.com
Date: 2007-10-10 17:56:06 -0400 (Wed, 10 Oct 2007)
New Revision: 8592
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java
Removed:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
Log:
simplified and consolidated pojo test test model and its underlying xml schema
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -26,20 +26,17 @@
import org.jboss.unit.runner.model.ModelBuilder;
import org.jboss.unit.runner.model.ParameterValueDef;
import org.jboss.unit.runner.model.ParametersDef;
-import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.runner.model.TestSuiteDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
+import org.jboss.unit.runner.model.pojo.TestClassDef;
+import org.jboss.unit.runner.model.pojo.TestCaseDef;
import static org.jboss.unit.util.CollectionTools.list;
import static org.jboss.unit.util.CollectionTools.set;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.ParserConfigurationException;
import java.io.InputStream;
-import java.io.IOException;
import java.util.Iterator;
/**
@@ -97,66 +94,32 @@
POJOTestSuiteDef pojoSuite =
assertInstanceOf(composite.getSuites().iterator().next(), POJOTestSuiteDef.class);
- TestDefDef myTestDef = pojoSuite.getTestDef("MyTest");
- assertNotNull(myTestDef);
- assertEquals("MyTest", myTestDef.getId());
- assertNotNull(myTestDef.getTestClass());
- assertEquals("org.foo.bar.MyTest", myTestDef.getTestClass().getName());
- assertNotNull(myTestDef.getTestClass().getTestCases());
- assertEquals(0, myTestDef.getTestClass().getTestCases().size());
+ Iterator<TestClassDef> testClasses = pojoSuite.getTestClasses().iterator();
- TestDefDef myTestDef2 = pojoSuite.getTestDef("MyTest2");
- assertNotNull(myTestDef2);
- assertEquals("MyTest2", myTestDef2.getId());
- assertNotNull(myTestDef2.getTestClass());
- assertEquals("org.foo.bar.MyTest2",
myTestDef2.getTestClass().getName());
- assertNotNull(myTestDef2.getTestClass().getTestCases());
- assertEquals(2, myTestDef2.getTestClass().getTestCases().size());
- assertNotNull(myTestDef2.getTestClass().getTestCase("foo"));
- assertEquals("foo",
myTestDef2.getTestClass().getTestCase("foo").getName());
- assertNotNull(myTestDef2.getTestClass().getTestCase("bar"));
- assertEquals("bar",
myTestDef2.getTestClass().getTestCase("bar").getName());
-
- assertEquals(2, pojoSuite.getTests().size());
-
//
- Iterator<TestDef> iterator = pojoSuite.getTests().iterator();
- TestDef test1 = iterator.next();
- assertEquals("MyTest", test1.getRefId());
- ParametersDef parameters = test1.getParameters();
- assertNotNull(parameters);
- assertEquals(set("blah", "foo"), parameters.getNames());
- ParameterValueDef blah = parameters.getParameter("blah");
- assertEquals(list("bluh"), blah.list());
- ParameterValueDef foo = parameters.getParameter("foo");
- assertEquals(list("bar1", null), foo.list());
+ assertTrue(testClasses.hasNext());
+ TestClassDef otherTestClass = assertNotNull(testClasses.next());
+ assertEquals("org.foo.bar.OtherTest", otherTestClass.getName());
+ assertEquals(0, otherTestClass.getTestCases().size());
+ assertNotNull(otherTestClass.getParameters());
+ assertEquals(set("foo"), otherTestClass.getParameters().getNames());
+ ParameterValueDef fooParam =
assertNotNull(otherTestClass.getParameters().getParameter("foo"));
+ assertEquals(list("bar"), fooParam.list());
//
- TestDef test2 = iterator.next();
- assertNotNull(test2.getRefId());
- ParametersDef test2Parameters = test2.getParameters();
- assertNotNull(test2Parameters);
- assertEquals(set("foo"), test2Parameters.getNames());
- ParameterValueDef fff = test2Parameters.getParameter("foo");
- assertEquals(list("bar"), fff.list());
-
- //
- TestDefDef myTestDef3 = pojoSuite.getTestDef(test2.getRefId());
- assertNotNull(myTestDef3);
-
- assertEquals(test2.getRefId(), myTestDef3.getId());
- assertNotNull(myTestDef3.getTestClass());
- assertEquals("org.foo.bar.OtherTest",
myTestDef3.getTestClass().getName());
- assertNotNull(myTestDef3.getTestClass().getTestCases());
- assertEquals(0, myTestDef3.getTestClass().getTestCases().size());
-
-
- //
-// ParametersDef suiteParams = pojoSuite.getParameters();
-// assertNotNull(suiteParams);
-// assertEquals(set("red"), suiteParams.getMap().keySet());
-// ParameterValueDef blue = suiteParams.getMap().get("red");
-// assertEquals(list("blue"), blue.list());
+ assertTrue(testClasses.hasNext());
+ TestClassDef barClass = assertNotNull(testClasses.next());
+ assertEquals("org.Bar", barClass.getName());
+ assertEquals(2, barClass.getTestCases().size());
+ TestCaseDef barFooCase = assertNotNull(barClass.getTestCase("foo"));
+ assertEquals("foo", barFooCase.getName());
+ TestCaseDef barBarCase = assertNotNull(barClass.getTestCase("bar"));
+ assertEquals("bar", barBarCase.getName());
+ assertEquals(set("foo", "blah"),
barClass.getParameters().getNames());
+ ParameterValueDef barClassFooParam =
assertNotNull(barClass.getParameters().getParameter("foo"));
+ assertEquals(list("bar1", null), barClassFooParam.list());
+ ParameterValueDef barClassBlahParam =
assertNotNull(barClass.getParameters().getParameter("blah"));
+ assertEquals(list("bluh"), barClassBlahParam.list());
}
private static void testParameterValueDef()
@@ -181,5 +144,4 @@
{
}
}
-
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java 2007-10-10 20:55:52 UTC
(rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java 2007-10-10 21:56:06 UTC
(rev 8592)
@@ -35,7 +35,7 @@
*/
public final class TestId implements Serializable
{
-
+
/** . */
private final String[] names;
Added: modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java 2007-10-10 21:56:06
UTC (rev 8592)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit;
+
+import org.jboss.unit.util.CollectionTools;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class TestIdFormat
+{
+
+ /**
+ * Parse a fqn representation of a test id.
+ *
+ * @param fqn the fqn to parse
+ * @return the test id value
+ * @throws IllegalArgumentException if the argument is not valid
+ */
+ public abstract TestId parse(String fqn) throws IllegalArgumentException;
+
+ public abstract String toString(TestId testId) throws IllegalArgumentException;
+
+ public static final TestIdFormat CLASSIC = new TestIdFormat()
+ {
+ public TestId parse(String fqn)
+ {
+ if (fqn == null)
+ {
+ throw new IllegalArgumentException("No null fqn accepted");
+ }
+
+ //
+ int from = 0;
+ List<String> names = new ArrayList<String>();
+
+ //
+ do
+ {
+ int pos = fqn.indexOf('.', from);
+
+ //
+ if (pos == -1)
+ {
+ names.add(fqn.substring(from));
+ break;
+ }
+
+ //
+ names.add(fqn.substring(from, pos));
+
+ //
+ from = pos + 1;
+ }
+ while (true);
+
+ //
+ return new TestId(names);
+ }
+
+ public String toString(TestId testId)
+ {
+ if (testId == null)
+ {
+ throw new IllegalArgumentException("No null test id accepted");
+ }
+
+ //
+ if (testId.getLength() == 0)
+ {
+ return "";
+ }
+
+ //
+ StringBuilder builder = new StringBuilder();
+ for (String name : CollectionTools.iterable(testId.iterator()))
+ {
+ builder.append(name);
+ builder.append('.');
+ }
+
+ //
+ return builder.substring(0, builder.length() - 1);
+ }
+ };
+
+}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -29,14 +29,11 @@
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
-import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.TestId;
import org.jboss.unit.Failure;
import org.jboss.unit.info.TestSuiteInfo;
-import org.jboss.unit.info.TestCaseInfo;
import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
import org.jboss.unit.driver.TestDriver;
@@ -64,70 +61,46 @@
protected void internalRun(TestFilter filter)
{
- for (TestDef test : suite.getTests())
+ for (TestClassDef testClass : suite.getTestClasses())
{
- // Get def id
- String testDefId = test.getRefId();
+ String className = testClass.getName();
//
- if (testDefId != null)
+ try
{
- // Get related test definition
- TestDefDef testDef = suite.getTestDef(testDefId);
+ Class clazz =
Thread.currentThread().getContextClassLoader().loadClass(className);
//
- if (testDef != null)
+ TestDriver driver = new POJOTestSuiteDriver(clazz);
+ TestSuiteInfo testSuiteInfo = (TestSuiteInfo)driver.getInfo();
+
+ //
+ List<String> testCaseNames = new ArrayList<String>();
+ for (TestCaseDef testCase : testClass.getTestCases())
{
- TestClassDef testClass = testDef.getTestClass();
- String className = testClass.getName();
+ testCaseNames.add(testCase.getName());
+ }
+ if (testCaseNames.size() == 0)
+ {
+ testCaseNames.addAll(testSuiteInfo.getNames());
+ }
- //
- try
- {
- Class clazz =
Thread.currentThread().getContextClassLoader().loadClass(className);
+ // Create parametrization
+ ParametrizationSet parametrizations =
suite.getParameters().getParametrization();
+ parametrizations.merge(testClass.getParameters().getParametrization());
- //
- TestDriver driver = new POJOTestSuiteDriver(clazz);
- TestSuiteInfo testSuiteInfo = (TestSuiteInfo)driver.getInfo();
-
- //
- List<String> testCaseNames = new ArrayList<String>();
- for (TestCaseDef testCase : testClass.getTestCases())
- {
- testCaseNames.add(testCase.getName());
- }
- if (testCaseNames.size() == 0)
- {
- testCaseNames.addAll(testSuiteInfo.getNames());
- }
-
- // Create parametrization
- ParametrizationSet parametrizations =
suite.getParameters().getParametrization();
- parametrizations.merge(test.getParameters().getParametrization());
-
- //
- for (String testCaseName : testCaseNames)
- {
- TestId testCaseId = new TestId(testCaseName);
- TestCaseInfo testCaseInfo =
(TestCaseInfo)testSuiteInfo.findTest(testCaseId);
- TestDriverRunner runner = new TestDriverRunner(driver,
parametrizations, testCaseId);
- runner.addListener(lifeCycleFilter);
- runner.run(filter);
- }
- }
- catch (Exception e)
- {
- fireEvent(new
RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test id " +
testDefId,e)));
- }
- }
- else
+ //
+ for (String testCaseName : testCaseNames)
{
- fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test
definition found for id " + testDefId)));
+ TestId testCaseId = new TestId(testCaseName);
+ TestDriverRunner runner = new TestDriverRunner(driver, parametrizations,
testCaseId);
+ runner.addListener(lifeCycleFilter);
+ runner.run(filter);
}
}
- else
+ catch (Exception e)
{
- fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test
definition found for id " + testDefId)));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot
execute test class " + className,e)));
}
}
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -32,9 +32,10 @@
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
+import org.jboss.unit.TestIdFormat;
+import org.jboss.unit.TestId;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -180,12 +181,15 @@
}
//
- String refid = refidAttr.getValue();
+ String refIdLitteral = refidAttr.getValue();
//
- TestDef test = new TestDef(refid);
+ TestId refId = TestIdFormat.CLASSIC.parse(refIdLitteral);
//
+ TestDef test = new TestDef(refId);
+
+ //
test.setParameters(buildParameters(testElt));
//
@@ -199,111 +203,45 @@
return suite;
}
- private TestClassDef buildTestClassDef(Element classElt)
- {
- Attr nameAttr = classElt.getAttributeNode("name");
- if (nameAttr == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- String classname = nameAttr.getValue();
- TestClassDef testClass = new TestClassDef(classname);
-
- //
- for (Element caseElt : children(classElt, "case"))
- {
-
- Attr caseNameAttr = caseElt.getAttributeNode("name");
- if (caseNameAttr == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- testClass.addTestCase(new TestCaseDef(caseNameAttr.getValue()));
- }
-
- //
- return testClass;
- }
-
private TestSuiteDef buildPOJOTestSuite(Element suiteElt)
{
POJOTestSuiteDef suite = new POJOTestSuiteDef();
-
+
//
- for (Element testDefElt : children(suiteElt, "test-def"))
+ for (Element testElt : children(suiteElt, "test"))
{
- Attr idAttr = testDefElt.getAttributeNode("id");
- if (idAttr == null)
- {
- throw new IllegalArgumentException();
- }
+ Element classElt = child(testElt, "class");
//
- String id = idAttr.getValue();
-
- //
- Element classElt = child(testDefElt, "class");
- if (classElt == null)
+ Attr nameAttr = classElt.getAttributeNode("name");
+ if (nameAttr == null)
{
throw new IllegalArgumentException();
}
//
- TestClassDef testClass = buildTestClassDef(classElt);
+ String classname = nameAttr.getValue();
+ TestClassDef testClass = new TestClassDef(classname);
- //
- TestDefDef testDef = new TestDefDef(id);
- testDef.setTestClass(testClass);
+ testClass.setParameters(buildParameters(testElt));
//
- suite.addDef(testDef);
- }
-
- //
- for (Element testElt : children(suiteElt, "test"))
- {
- Attr refidAttr = testElt.getAttributeNode("refid");
- Element classElt = child(testElt, "class");
-
- //
- String refid;
-
- //
- if (refidAttr != null)
+ for (Element caseElt : children(classElt, "case"))
{
- refid = refidAttr.getValue();
- }
- else if (classElt != null)
- {
- String id = "blah";
+ Attr caseNameAttr = caseElt.getAttributeNode("name");
+ if (caseNameAttr == null)
+ {
+ throw new IllegalArgumentException();
+ }
- TestClassDef testClass = buildTestClassDef(classElt);
-
- TestDefDef testDef = new TestDefDef(id);
-
- testDef.setTestClass(testClass);
-
- suite.addDef(testDef);
-
- refid = id;
+ //
+ String testCaseName = caseNameAttr.getValue();
+ TestCaseDef testCase = new TestCaseDef(testCaseName);
+ testClass.addTestCase(testCase);
}
- else
- {
- throw new IllegalArgumentException();
- }
//
- TestDef test = new TestDef(refid);
-
- //
- test.setParameters(buildParameters(testElt));
-
- //
- suite.addTest(test);
+ suite.addClass(testClass);
}
//
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.unit.runner.model;
+import org.jboss.unit.TestId;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -30,21 +32,21 @@
{
/** . */
- private String refId;
+ private TestId refId;
/** . */
private ParametersDef parameters = new ParametersDef();
- public TestDef(String testId)
+ public TestDef(TestId refId)
{
- if (testId == null)
+ if (refId == null)
{
- throw new IllegalArgumentException("No null test id accepted");
+ throw new IllegalArgumentException("No null ref id accepted");
}
- this.refId = testId;
+ this.refId = refId;
}
- public String getRefId()
+ public TestId getRefId()
{
return refId;
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -35,26 +35,9 @@
public abstract class TestSuiteDef
{
- /** The tests. */
- protected final List<TestDef> tests = new ArrayList<TestDef>();
-
/** . */
protected ParametersDef parameters = new ParametersDef();
- public void addTest(TestDef test)
- {
- if (test == null)
- {
- throw new IllegalArgumentException();
- }
- tests.add(test);
- }
-
- public Collection<TestDef> getTests()
- {
- return tests;
- }
-
public ParametersDef getParameters()
{
return parameters;
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -24,9 +24,14 @@
import org.jboss.unit.runner.model.TestSuiteDef;
import org.jboss.unit.runner.model.BuilderException;
+import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.impl.generic.GenericTestRunner;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -34,6 +39,9 @@
public class GenericTestSuiteDef extends TestSuiteDef
{
+ /** The tests. */
+ private List<TestDef> tests = new ArrayList<TestDef>();
+
/** . */
private String className;
@@ -51,4 +59,18 @@
{
return new GenericTestRunner(this);
}
+
+ public void addTest(TestDef test)
+ {
+ if (test == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ tests.add(test);
+ }
+
+ public Collection<TestDef> getTests()
+ {
+ return tests;
+ }
}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -28,8 +28,8 @@
import org.jboss.unit.runner.impl.pojo.POJOTestRunner;
import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -39,31 +39,22 @@
{
/** The definitions. */
- private Map<String, TestDefDef> testDefs = new HashMap<String,
TestDefDef>();
+ private List<TestClassDef> testClasses = new ArrayList<TestClassDef>();
- public void addDef(TestDefDef testDef)
+ public void addClass(TestClassDef testDef)
{
if (testDef == null)
{
- throw new IllegalArgumentException("No null test def accepted");
+ throw new IllegalArgumentException("No null test class accepted");
}
- testDefs.put(testDef.getId(), testDef);
+ testClasses.add(testDef);
}
- public Collection<TestDefDef> getTestDefs()
+ public Collection<TestClassDef> getTestClasses()
{
- return testDefs.values();
+ return testClasses;
}
- public TestDefDef getTestDef(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null test def name accepted");
- }
- return testDefs.get(name);
- }
-
public TestRunner createRunner() throws BuilderException
{
return new POJOTestRunner(this);
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.unit.runner.model.pojo;
+import org.jboss.unit.runner.model.ParametersDef;
+
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
@@ -39,6 +41,9 @@
/** . */
private Map<String,TestCaseDef> testCases = new HashMap<String,
TestCaseDef>();
+ /** . */
+ private ParametersDef parameters = new ParametersDef();
+
public TestClassDef(String name)
{
if (name == null)
@@ -77,4 +82,14 @@
}
return testCases.get(name);
}
+
+ public ParametersDef getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ParametersDef parameters)
+ {
+ this.parameters = parameters;
+ }
}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -1,65 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.runner.model.pojo;
-
-/**
- * The definition of a tested class.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestDefDef
-{
-
- /** . */
- private final String id;
-
- /** . */
- private TestClassDef testClass;
-
- public TestDefDef(String id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.id = id;
- }
-
- public String getId()
- {
- return id;
- }
-
- public TestClassDef getTestClass()
- {
- return testClass;
- }
-
- public void setTestClass(TestClassDef testClass)
- {
- this.testClass = testClass;
- }
-}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java 2007-10-10
20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java 2007-10-10
21:56:06 UTC (rev 8592)
@@ -27,6 +27,7 @@
import java.util.HashSet;
import java.util.Set;
import java.util.List;
+import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,6 +36,17 @@
public class CollectionTools
{
+ public static <U> Iterable<U> iterable(final Iterator<U> iterator)
+ {
+ return new Iterable<U>()
+ {
+ public Iterator<U> iterator()
+ {
+ return iterator;
+ }
+ };
+ }
+
public static <U> Set<U> set()
{
return new HashSet<U>();
Modified:
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
===================================================================
---
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10
21:56:06 UTC (rev 8592)
@@ -70,10 +70,9 @@
nested class element or it can refer to an existing test definition. The nested
parameters are used to parameterize
the test configuration, they override any existing parameter defined at the pojo
level.</xsd:documentation></xsd:annotation>
<xsd:sequence>
+ <xsd:element name="class" type="pojo_classType"
minOccurs="1" maxOccurs="1"/>
<xsd:element name="parameter" type="parameterType"
minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="class" type="pojo_classType"
minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
- <xsd:attribute name="refid" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="genericType">
Modified: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml 2007-10-10
20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml 2007-10-10
21:56:06 UTC (rev 8592)
@@ -4,31 +4,24 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
- <test-def id="blahblah">
+ <test>
<class name="org.jboss.test.unit.blah.TestedClass1"/>
- </test-def>
- <test-def id="bluh">
+ </test>
+ <test>
<class name="org.jboss.test.unit.blah.TestedClass1">
<case name="testFoo"/>
</class>
- </test-def>
- <test-def id="blih">
- <class name="org.jboss.test.unit.blah.TestedClass2"/>
- </test-def>
- <test refid="blahblah">
</test>
- <test refid="XYZ">
- </test>
- <test refid="bluh">
- </test>
<test>
- <class name="blah"/>
- </test>
- <test refid="blih">
+ <class name="org.jboss.test.unit.blah.TestedClass2">
+ </class>
<parameter name="foo">
<value>foo</value>
<value>fii</value>
</parameter>
</test>
+ <test>
+ <class name="XYZ"/>
+ </test>
</pojo>
</jboss-unit>
Modified:
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
===================================================================
---
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml 2007-10-10
20:55:52 UTC (rev 8591)
+++
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml 2007-10-10
21:56:06 UTC (rev 8592)
@@ -7,21 +7,16 @@
<parameter name="red" value="blue"/>
- <test-def id="MyTest">
- <class name="org.foo.bar.MyTest"/>
- <!--
- <parameters>
- </parameters>
- -->
- </test-def>
- <test-def id="MyTest2">
- <class name="org.foo.bar.MyTest2">
+ <test>
+ <class name="org.foo.bar.OtherTest"/>
+ <parameter name="foo" value="bar"/>
+ </test>
+
+ <test>
+ <class name="org.Bar">
<case name="foo"/>
<case name="bar"/>
</class>
- </test-def>
-
- <test refid="MyTest">
<parameter name="blah" value="bluh"/>
<parameter name="foo">
<value>bar1</value>
@@ -29,25 +24,5 @@
</parameter>
</test>
- <test>
- <parameter name="foo" value="bar"/>
- <class name="org.foo.bar.OtherTest"/>
- </test>
-
- <!--
- <test>
- <class name="">
- <case name="abc"/>
- </class>
- <parameters>
- <parameter name="blah" value="bluh"/>
- <parameter name="foo">
- <value>bar1</value>
- <null/>
- </parameter>
- </parameters>
- </test>
- -->
-
</pojo>
</jboss-unit>