JBoss Portal SVN: r8506 - modules/test/trunk/unit/src/main/org/jboss/test/unit/runner.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 20:01:43 -0400 (Mon, 01 Oct 2007)
New Revision: 8506
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
Log:
- add test case for composite test runner
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-01 22:01:06 UTC (rev 8505)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-02 00:01:43 UTC (rev 8506)
@@ -26,13 +26,15 @@
import org.jboss.unit.runner.AbstractTestRunner;
import org.jboss.unit.runner.TestFilter;
import org.jboss.unit.runner.TestRunnerEvent;
-import org.jboss.unit.runner.event.EndRunnerEvent;
-import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventListener;
import org.jboss.unit.runner.impl.composite.CompositeTestRunner;
-import org.jboss.unit.runner.impl.event.EventDrivenTestRunner;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.util.CollectionTools.*;
+
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,22 +43,134 @@
public class CompositeTestRunnerTests
{
+ private static List<TestRunnerEvent> events = new ArrayList<TestRunnerEvent>();
+
+ private static TestRunnerEventListener listener = new TestRunnerEventListener()
+ {
+ public void onEvent(TestRunnerEvent event)
+ {
+ events.add(event);
+ }
+ };
+
public static void main(String[] args)
{
+ testCompose();
+ testComposeWithRuntimeException1();
+ testComposeWithRuntimeException2();
+ testComposeWithRuntimeError1();
+ testComposeWithRuntimeError2();
+ }
+ private static void testCompose()
+ {
MyRunner1 runner1 = new MyRunner1();
MyRunner1 runner2 = new MyRunner1();
+ Collection<TestRunner> runners = new ArrayList<TestRunner>();
+ runners.add(runner1);
+ runners.add(runner2);
+ CompositeTestRunner runner = new CompositeTestRunner(runners);
+ runner.addListener(listener);
+ runner.run();
+ assertTrue(runner1.invoked);
+ assertTrue(runner2.invoked);
+ assertEquals(4, events.size());
+ assertEquals(list(runner1.event, runner2.event), events.subList(1, 3));
+ events.clear();
+ }
+ private static void testComposeWithRuntimeException1()
+ {
+ MyRunner1 runner1 = new MyRunner1();
+ MyRunner2 runner2 = new MyRunner2();
Collection<TestRunner> runners = new ArrayList<TestRunner>();
runners.add(runner1);
runners.add(runner2);
+ CompositeTestRunner runner = new CompositeTestRunner(runners);
+ runner.addListener(listener);
+ try
+ {
+ runner.run();
+ fail();
+ }
+ catch (RuntimeException e)
+ {
+ assertSame(runner2.exception, e);
+ }
+ assertEquals(2, events.size());
+ assertTrue(runner1.invoked);
+ assertEquals(list(runner1.event), events.subList(1, 2));
+ events.clear();
+ }
+ private static void testComposeWithRuntimeException2()
+ {
+ MyRunner2 runner1 = new MyRunner2();
+ MyRunner1 runner2 = new MyRunner1();
+ Collection<TestRunner> runners = new ArrayList<TestRunner>();
+ runners.add(runner1);
+ runners.add(runner2);
CompositeTestRunner runner = new CompositeTestRunner(runners);
+ runner.addListener(listener);
+ try
+ {
+ runner.run();
+ fail();
+ }
+ catch (RuntimeException e)
+ {
+ assertSame(runner1.exception, e);
+ }
+ assertEquals(1, events.size());
+ assertFalse(runner2.invoked);
+ events.clear();
+ }
- runner.run();
+ private static void testComposeWithRuntimeError1()
+ {
+ MyRunner1 runner1 = new MyRunner1();
+ MyRunner3 runner2 = new MyRunner3();
+ Collection<TestRunner> runners = new ArrayList<TestRunner>();
+ runners.add(runner1);
+ runners.add(runner2);
+ CompositeTestRunner runner = new CompositeTestRunner(runners);
+ runner.addListener(listener);
+ try
+ {
+ runner.run();
+ fail();
+ }
+ catch (Error e)
+ {
+ assertSame(runner2.error, e);
+ }
+ assertEquals(2, events.size());
+ assertTrue(runner1.invoked);
+ assertEquals(list(runner1.event), events.subList(1, 2));
+ events.clear();
+ }
-
-
+ private static void testComposeWithRuntimeError2()
+ {
+ MyRunner3 runner1 = new MyRunner3();
+ MyRunner1 runner2 = new MyRunner1();
+ Collection<TestRunner> runners = new ArrayList<TestRunner>();
+ runners.add(runner1);
+ runners.add(runner2);
+ CompositeTestRunner runner = new CompositeTestRunner(runners);
+ runner.addListener(listener);
+ try
+ {
+ runner.run();
+ fail();
+ }
+ catch (Error e)
+ {
+ assertSame(runner1.error, e);
+ }
+ assertEquals(1, events.size());
+ assertFalse(runner2.invoked);
+ events.clear();
}
private static class MyRunner1 extends AbstractTestRunner
@@ -101,5 +215,4 @@
private static class MyEvent extends TestRunnerEvent
{
}
-
}
16 years, 7 months
JBoss Portal SVN: r8505 - in modules/test/trunk/unit/src/main/org/jboss: test/unit/runner and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 18:01:06 -0400 (Mon, 01 Oct 2007)
New Revision: 8505
Added:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag3.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag3.java
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java
modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java
Log:
- make TestCaseDescriptor and TestParameterDescriptor interfaces
- implement and test keyword tagging of tests
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -38,6 +38,10 @@
public abstract Set<String> getTestCaseParameterNames(String testCaseName);
+ public abstract Set<String> getKeywords();
+
+ public abstract Set<String> getTestCaseKeywords(String testCaseName);
+
public abstract InvokeResult invoke(String testName, Map<String,String> parametrization);
public enum InvokeResult
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -24,6 +24,8 @@
import org.jboss.unit.api.Assert;
+import static org.jboss.unit.util.CollectionTools.*;
+
import java.util.Map;
import java.util.Collections;
import java.util.HashMap;
@@ -50,6 +52,7 @@
testClassWithoutAnnotations();
testAbstractClassAnnotatedWithTest();
testClassAnnotatedWithTest();
+ testClassAnnotatedWithTag();
//
testMethodAnnotatedWithTest();
@@ -57,6 +60,7 @@
testTestMethodAnnotatedWithConflictingAnnotations();
testMethodAnnotatedWithParameter();
testMethodAnnotatedWithCreate();
+ testMethodAnnotatedWithTag();
//
testClassHavingSamePropertyParameterAndMethodArgumentParameter();
@@ -69,6 +73,32 @@
testLifeCycleSequence();
}
+ private void testClassAnnotatedWithTag()
+ {
+ testClassAnnotatedWithTag(ClassAnnotatedWithTag1.class, set("annotation_foo"));
+ testClassAnnotatedWithTag(ClassAnnotatedWithTag2.class, set("annotation_foo", "annotation_bar"));
+ testClassAnnotatedWithTag(ClassAnnotatedWithTag3.class, new HashSet<String>());
+ }
+
+ private void testClassAnnotatedWithTag(Class clazz, Set<String> keywords)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+ Assert.assertEquals(keywords, driver.getKeywords());
+ }
+
+ private void testMethodAnnotatedWithTag()
+ {
+ testMethodAnnotatedWithTag(MethodAnnotatedWithTag1.class, "testFoo", set("annotation_foo"));
+ testMethodAnnotatedWithTag(MethodAnnotatedWithTag2.class, "testFoo", set("annotation_foo", "annotation_bar"));
+ testMethodAnnotatedWithTag(MethodAnnotatedWithTag3.class, "testFoo", new HashSet<String>());
+ }
+
+ private void testMethodAnnotatedWithTag(Class clazz, String testName, Set<String> keywords)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+ Assert.assertEquals(keywords, driver.getTestCaseKeywords(testName));
+ }
+
private void testLifeCycleSequence()
{
testLifeCycleSequence(LifeCycleSequence01.class, AbstractPOJOTest.InvokeResult.ERROR, null, false);
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag1.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Tag("annotation_foo")
+public class ClassAnnotatedWithTag1
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag2.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Tag({"annotation_foo","annotation_bar"})
+public class ClassAnnotatedWithTag2
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTag3.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassAnnotatedWithTag3
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag1.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTag1
+{
+
+ @Test
+ @Tag("annotation_foo")
+ public void testFoo()
+ {
+
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag2.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTag2
+{
+
+ @Test
+ @Tag({"annotation_foo","annotation_bar"})
+ public void testFoo()
+ {
+
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTag3.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Tag;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTag3
+{
+
+ @Test
+ public void testFoo()
+ {
+
+ }
+
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -66,11 +66,24 @@
return suiteInfo.getParameters().keySet();
}
+ public Set<String> getKeywords()
+ {
+ return suiteInfo.getKeywords();
+ }
+
public Set<String> getTestCaseNames()
{
return suiteInfo.getNames();
}
+ public Set<String> getTestCaseKeywords(String testCaseName)
+ {
+ TestInfo info = suiteInfo.getTest(testCaseName);
+ assertNotNull(info);
+ TestCaseInfo testCaseInfo = assertInstanceOf(info, TestCaseInfo.class);
+ return testCaseInfo.getKeywords();
+ }
+
public Set<String> getTestCaseParameterNames(String testCaseName)
{
TestInfo info = suiteInfo.getTest(testCaseName);
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -56,6 +56,18 @@
return handler.getTestCases().keySet();
}
+ public Set<String> getKeywords()
+ {
+ return handler.getKeywords();
+ }
+
+ public Set<String> getTestCaseKeywords(String testCaseName)
+ {
+ TestCaseDescriptor descriptor = handler.getTestCases().get(testCaseName);
+ assertNotNull(descriptor);
+ return descriptor.getKeywords();
+ }
+
public Set<String> getTestCaseParameterNames(String testCaseName)
{
TestCaseDescriptor descriptor = handler.getTestCases().get(testCaseName);
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -23,6 +23,9 @@
package org.jboss.test.unit.runner;
import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.TestRunnerEvent;
import org.jboss.unit.runner.event.EndRunnerEvent;
import org.jboss.unit.runner.event.StartRunnerEvent;
import org.jboss.unit.runner.impl.composite.CompositeTestRunner;
@@ -41,20 +44,62 @@
public static void main(String[] args)
{
- EventDrivenTestRunner srunner = new EventDrivenTestRunner(
- new StartRunnerEvent(),
- new EndRunnerEvent()
- );
+ MyRunner1 runner1 = new MyRunner1();
+ MyRunner1 runner2 = new MyRunner1();
Collection<TestRunner> runners = new ArrayList<TestRunner>();
- runners.add(srunner);
+ runners.add(runner1);
+ runners.add(runner2);
CompositeTestRunner runner = new CompositeTestRunner(runners);
runner.run();
+
+ }
+ private static class MyRunner1 extends AbstractTestRunner
+ {
+
+ /** . */
+ final TestRunnerEvent event = new MyEvent();
+
+ boolean invoked;
+
+ protected void internalRun(TestFilter filter)
+ {
+ invoked = true;
+ fireEvent(event);
+ }
}
+ private static class MyRunner2 extends AbstractTestRunner
+ {
+
+ /** . */
+ final RuntimeException exception = new RuntimeException();
+
+ protected void internalRun(TestFilter filter)
+ {
+ throw exception;
+ }
+ }
+
+ private static class MyRunner3 extends AbstractTestRunner
+ {
+
+ /** . */
+ final Error error = new Error();
+
+ protected void internalRun(TestFilter filter)
+ {
+ throw error;
+ }
+ }
+
+ private static class MyEvent extends TestRunnerEvent
+ {
+ }
+
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -30,51 +30,12 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ParameterDescriptor
+public interface ParameterDescriptor
{
- /** . */
- private String name;
+ String getName();
- /** . */
- private String description;
+ String getDescription();
- /** . */
- private List<String> defaultValues;
-
- public ParameterDescriptor(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- public List<String> getDefaultValues()
- {
- return defaultValues;
- }
-
- public void setDefaultValues(List<String> defaultValues)
- {
- this.defaultValues = defaultValues;
- }
+ List<String> getDefaultValues();
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -24,12 +24,16 @@
import java.lang.reflect.Method;
import java.util.LinkedHashMap;
+import java.util.Set;
+import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-class TestCaseDef
+class TestCaseDef implements TestCaseDescriptor
{
/** . */
@@ -45,38 +49,28 @@
final String description;
/** . */
- final LinkedHashMap<String,ArgumentTestParameter> parameters;
+ final LinkedHashMap<String,ArgumentTestParameter> arguments;
-// /** . */
-// private final TestCaseInfo info = new TestCaseInfo()
-// {
-// public String getName()
-// {
-// return name;
-// }
-// public String getDescription()
-// {
-// return description;
-// }
-// public Map<String, ? extends ParameterInfo> getParameters()
-// {
-// Map<String, ParameterInfo> merge = new HashMap<String, ParameterInfo>();
-// merge.putAll(driver.getInfo().getParameters());
-// merge.putAll(parameters);
-// return merge;
-// }
-// public Set<String> getTags()
-// {
-// return Collections.emptySet();
-// }
-// };
+ /** . */
+ final Map<String,TestParameter> parameters;
- TestCaseDef(Method method, String name, String description, LinkedHashMap<String, ArgumentTestParameter> parameters)
+ /** . */
+ final Set<String> keywords;
+
+ TestCaseDef(
+ Method method,
+ String name,
+ String description,
+ Map<String, TestParameter> parameters,
+ LinkedHashMap<String, ArgumentTestParameter> arguments,
+ Set<String> keywords)
{
this.method = method;
this.name = name;
this.description = description;
+ this.arguments = arguments;
this.parameters = parameters;
+ this.keywords = keywords;
}
public String getName()
@@ -88,4 +82,14 @@
{
return description;
}
+
+ public Map<String, ? extends ParameterDescriptor> getParameters()
+ {
+ return Collections.unmodifiableMap(parameters);
+ }
+
+ public Set<String> getKeywords()
+ {
+ return Collections.unmodifiableSet(keywords);
+ }
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -23,54 +23,20 @@
package org.jboss.unit.api.pojo;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class TestCaseDescriptor
+public interface TestCaseDescriptor
{
- /** . */
- private String name;
+ String getName();
- /** . */
- private String description;
+ String getDescription();
- /** . */
- private Map<String,ParameterDescriptor> parameters;
+ Map<String, ? extends ParameterDescriptor> getParameters();
- public TestCaseDescriptor(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- public Map<String, ParameterDescriptor> getParameters()
- {
- return parameters;
- }
-
- public void setParameters(Map<String, ParameterDescriptor> parameters)
- {
- this.parameters = parameters;
- }
+ Set<String> getKeywords();
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -26,6 +26,7 @@
import org.jboss.unit.api.pojo.TestCaseDescriptor;
import java.util.Map;
+import java.util.Set;
/**
* Allow a pojo class to take care of providing its description and perform test case life cycle management.
@@ -51,18 +52,25 @@
String getDescription();
/**
+ * Returns the keywords for the test.
+ *
+ * @return the test keywords
+ */
+ Set<String> getKeywords();
+
+ /**
* Return the test parameters.
*
* @return the test parameters
*/
- Map<String,ParameterDescriptor> getParameters();
+ Map<String,? extends ParameterDescriptor> getParameters();
/**
* Return the test case descriptions.
*
* @return the test case descriptions
*/
- Map<String, TestCaseDescriptor> getTestCases();
+ Map<String,? extends TestCaseDescriptor> getTestCases();
/**
* Instantiate life cycle operation of a test case.
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -22,13 +22,13 @@
******************************************************************************/
package org.jboss.unit.api.pojo;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.unit.api.pojo.annotations.Parameter;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
import org.jboss.unit.api.pojo.annotations.Description;
+import org.jboss.unit.api.pojo.annotations.Tag;
+import org.jboss.unit.util.CollectionTools;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -37,6 +37,9 @@
import java.util.LinkedHashMap;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
import java.lang.reflect.Modifier;
import java.lang.reflect.Constructor;
import java.lang.reflect.AnnotatedElement;
@@ -55,32 +58,29 @@
{
/** . */
- private String suiteName;
+ private final String suiteName;
/** . */
- private String suiteDescription;
+ private final String suiteDescription;
/** . */
- private Map<String, TestCaseDef> testCases;
+ private final Map<String, TestCaseDef> testCases;
/** . */
- private Method create;
+ private final Method create;
/** . */
- private Method destroy;
+ private final Method destroy;
/** . */
- private Map<String, PropertyTestParameter> parameters;
+ final Map<String, PropertyTestParameter> suiteParameters;
/** . */
- private Map<String, ParameterDescriptor> parameterDescriptors;
+ private final Constructor ctor;
/** . */
- private Map<String, TestCaseDescriptor> testCasesDescriptors;
+ private final Set<String> suiteKeywords;
- /** . */
- private Constructor ctor;
-
public TestHandlerSupport(Class testClass)
{
if (testClass == null)
@@ -95,6 +95,7 @@
}
// Check constructor
+ Constructor ctor;
try
{
ctor = testClass.getConstructor();
@@ -106,7 +107,7 @@
//
Test testAnnotation = ((AnnotatedElement)testClass).getAnnotation(Test.class);
- suiteName = testAnnotation != null ? testAnnotation.name() : "";
+ String suiteName = testAnnotation != null ? testAnnotation.name() : "";
if (suiteName.length() == 0)
{
suiteName = testClass.getName();
@@ -114,12 +115,19 @@
//
Description descriptionAnnotation = ((AnnotatedElement)testClass).getAnnotation(Description.class);
- suiteDescription = descriptionAnnotation != null ? descriptionAnnotation.description() : "";
+ String suiteDescription = descriptionAnnotation != null ? descriptionAnnotation.description() : "";
if (suiteDescription.length() == 0)
{
suiteDescription = "Test of class " + testClass.getName();
}
+ Tag tag = ((AnnotatedElement)testClass).getAnnotation(Tag.class);
+ Set<String> suiteKeywords = new HashSet<String>();
+ if (tag != null)
+ {
+ suiteKeywords.addAll(CollectionTools.set(tag.value()));
+ }
+
//
SortedMap<MethodKey, Method> methods = new TreeMap<MethodKey, Method>();
for (Method method : testClass.getMethods())
@@ -129,20 +137,20 @@
}
//
- parameters = new HashMap<String, PropertyTestParameter>();
- testCases = new HashMap<String, TestCaseDef>();
+ Map<String, PropertyTestParameter> suiteParameters = new HashMap<String, PropertyTestParameter>();
+ Map<String, TestCaseDef> testCases = new HashMap<String, TestCaseDef>();
+ Method create = null;
+ Method destroy = null;
- //
+ // First pass for parameters and life cycle annotations
for (Method method : methods.values())
{
String methodName = method.getName();
int modifiers = method.getModifiers();
-
- //
Parameter parameterMethodAnnotation = method.getAnnotation(Parameter.class);
-
- //
Test testMethodAnnotation = method.getAnnotation(Test.class);
+ Create createMethodAnnotation = method.getAnnotation(Create.class);
+ Destroy destroyMethodAnnotation = method.getAnnotation(Destroy.class);
//
if (testMethodAnnotation != null && parameterMethodAnnotation != null)
@@ -150,8 +158,6 @@
throw new IllegalArgumentException();
}
- Create createMethodAnnotation = method.getAnnotation(Create.class);
-
//
if (createMethodAnnotation != null && parameterMethodAnnotation != null)
{
@@ -162,8 +168,6 @@
throw new IllegalArgumentException();
}
- Destroy destroyMethodAnnotation = method.getAnnotation(Destroy.class);
-
//
if (destroyMethodAnnotation != null && parameterMethodAnnotation != null)
{
@@ -226,18 +230,22 @@
}
//
- PropertyTestParameter parameter = parameters.get(name);
+ PropertyTestParameter parameter = suiteParameters.get(name);
if (parameter == null)
{
parameter = new PropertyTestParameter(name, description);
- parameters.put(name, parameter);
+ suiteParameters.put(name, parameter);
}
//
parameter.addSetter(method);
}
- else if (testMethodAnnotation != null)
+ else if (createMethodAnnotation != null)
{
+ if (create != null)
+ {
+ throw new IllegalArgumentException();
+ }
if (method.getReturnType() != void.class)
{
throw new IllegalArgumentException();
@@ -254,9 +262,74 @@
{
throw new IllegalArgumentException();
}
+ if (method.getParameterTypes().length > 0)
+ {
+ throw new IllegalArgumentException();
+ }
//
- LinkedHashMap<String, ArgumentTestParameter> argumentParameters = new LinkedHashMap<String, ArgumentTestParameter>();
+ create = method;
+ }
+ else if (destroyMethodAnnotation != null)
+ {
+ if (destroy != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getParameterTypes().length > 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ destroy = method;
+ }
+ }
+
+ // Second pass for test annotations
+ for (Method method : methods.values())
+ {
+ int modifiers = method.getModifiers();
+ Test testMethodAnnotation = method.getAnnotation(Test.class);
+
+ //
+ if (testMethodAnnotation != null)
+ {
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ LinkedHashMap<String, ArgumentTestParameter> methodParameters = new LinkedHashMap<String, ArgumentTestParameter>();
for (Annotation[] parameterAnnotations : method.getParameterAnnotations())
{
Map<Class<? extends Annotation>,Annotation> parameterAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
@@ -278,7 +351,7 @@
{
throw new IllegalArgumentException();
}
- if (argumentParameters.containsKey(name))
+ if (methodParameters.containsKey(name))
{
throw new IllegalArgumentException();
}
@@ -292,7 +365,7 @@
}
//
- argumentParameters.put(name, new ArgumentTestParameter(name, description));
+ methodParameters.put(name, new ArgumentTestParameter(name, description));
}
else
{
@@ -316,106 +389,38 @@
}
//
- TestCaseDef testCaseDef = new TestCaseDef(method, name, description, argumentParameters);
-
- //
- if (testCases.put(testCaseDef.getName(), testCaseDef) != null)
+ Set<String> keywords = new HashSet<String>();
+ Tag tagMethodAnnotation = method.getAnnotation(Tag.class);
+ if (tagMethodAnnotation != null)
{
- throw new IllegalArgumentException();
+ keywords.addAll(CollectionTools.set(tagMethodAnnotation.value()));
}
- }
- else if (createMethodAnnotation != null)
- {
- if (create != null)
- {
- throw new IllegalArgumentException();
- }
- if (method.getReturnType() != void.class)
- {
- throw new IllegalArgumentException();
- }
- if (Modifier.isAbstract(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (!Modifier.isPublic(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (Modifier.isStatic(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (method.getParameterTypes().length > 0)
- {
- throw new IllegalArgumentException();
- }
+ Map<String,TestParameter> parameters = new HashMap<String, TestParameter>(suiteParameters);
+ parameters.putAll(methodParameters);
+
//
- create = method;
- }
- else if (destroyMethodAnnotation != null)
- {
- if (destroy != null)
+ TestCaseDef testCaseDef = new TestCaseDef(method, name, description, parameters, methodParameters, keywords);
+
+ //
+ if (testCases.put(testCaseDef.getName(), testCaseDef) != null)
{
throw new IllegalArgumentException();
}
- if (method.getReturnType() != void.class)
- {
- throw new IllegalArgumentException();
- }
- if (Modifier.isAbstract(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (!Modifier.isPublic(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (Modifier.isStatic(modifiers))
- {
- throw new IllegalArgumentException();
- }
- if (method.getParameterTypes().length > 0)
- {
- throw new IllegalArgumentException();
- }
-
- //
- destroy = method;
}
}
- // Init parameter descriptors
- parameterDescriptors = buildDescriptorMap(parameters);
-
//
- testCasesDescriptors = new LinkedHashMap<String, TestCaseDescriptor>();
- for (TestCaseDef testCaseDef : testCases.values())
- {
- TestCaseDescriptor testCaseDescriptor = new TestCaseDescriptor(testCaseDef.getName());
- testCaseDescriptor.setDescription(testCaseDef.name);
- Map<String, ParameterDescriptor> merge = new LinkedHashMap<String, ParameterDescriptor>();
- merge.putAll(parameterDescriptors);
- merge.putAll(buildDescriptorMap(testCaseDef.parameters));
- testCaseDescriptor.setParameters(merge);
- testCasesDescriptors.put(testCaseDescriptor.getName(), testCaseDescriptor);
- }
+ this.suiteName = suiteName;
+ this.suiteDescription = suiteDescription;
+ this.suiteKeywords = suiteKeywords;
+ this.suiteParameters = suiteParameters;
+ this.testCases = testCases;
+ this.ctor = ctor;
+ this.create = create;
+ this.destroy = destroy;
}
- private static Map<String, ParameterDescriptor> buildDescriptorMap(Map<String, ? extends TestParameter> parameters)
- {
- Map<String, ParameterDescriptor> parameterDescriptors = new LinkedHashMap<String, ParameterDescriptor>();
- for (TestParameter parameter : parameters.values())
- {
- ParameterDescriptor parameterDescriptor = new ParameterDescriptor(parameter.getName());
- parameterDescriptor.setDescription(parameter.getDescription());
- parameterDescriptor.setDefaultValues(new ArrayList<String>());
- parameterDescriptors.put(parameter.getName(), parameterDescriptor);
- }
- return parameterDescriptors;
- }
-
public String getName()
{
return suiteName;
@@ -426,16 +431,21 @@
return suiteDescription;
}
- public Map<String, ParameterDescriptor> getParameters()
+ public Set<String> getKeywords()
{
- return parameterDescriptors;
+ return suiteKeywords;
}
- public Map<String, TestCaseDescriptor> getTestCases()
+ public Map<String, ? extends ParameterDescriptor> getParameters()
{
- return testCasesDescriptors;
+ return Collections.unmodifiableMap(suiteParameters);
}
+ public Map<String, ? extends TestCaseDescriptor> getTestCases()
+ {
+ return Collections.unmodifiableMap(testCases);
+ }
+
public Object newTestCase(String name) throws TestCaseLifeCycleException
{
TestCaseDef testCaseDef = testCases.get(name);
@@ -473,7 +483,7 @@
testCase.parametrization = parametrization;
//
- for (PropertyTestParameter parameter : parameters.values())
+ for (PropertyTestParameter parameter : suiteParameters.values())
{
if (!parametrization.containsKey(parameter.getName()))
{
@@ -525,7 +535,7 @@
TestCase testCase = (TestCase)_testCase;
List<Object> argList = new ArrayList<Object>();
- for (String parameterName : testCase.def.parameters.keySet())
+ for (String parameterName : testCase.def.arguments.keySet())
{
if (!testCase.parametrization.containsKey(parameterName))
{
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-class TestParameter
+class TestParameter implements ParameterDescriptor
{
/** . */
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -28,6 +28,8 @@
import java.lang.annotation.ElementType;
/**
+ * Annotate something with keywords.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -22,64 +22,12 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.TestHandler;
-import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
-
-import java.util.Map;
-
/**
* @todo
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class JUnitTestHandler implements TestHandler
+public class JUnitTestHandler
{
-
- public String getName()
- {
- return null;
- }
-
- public String getDescription()
- {
- return null;
- }
-
- public Map<String, ParameterDescriptor> getParameters()
- {
- return null;
- }
-
- public Map<String, TestCaseDescriptor> getTestCases()
- {
- return null;
- }
-
- public Object newTestCase(String name) throws TestCaseLifeCycleException
- {
- return null;
- }
-
- public void testCaseParametrize(Object testCase, Map<String, String> parametrization) throws TestCaseLifeCycleException
- {
-
- }
-
- public void testCaseCreate(Object testCase) throws TestCaseLifeCycleException
- {
-
- }
-
- public void testCaseInvoke(Object testCase) throws TestCaseLifeCycleException
- {
-
- }
-
- public void testCaseDestroy(Object testCase)
- {
-
- }
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -57,9 +57,9 @@
Map<String,? extends ParameterInfo> getParameters();
/**
- * Returns the set of tags.
+ * Returns the set of keywords.
*
- * @return the set of tags
+ * @return the set of keywords
*/
- Set<String> getTags();
+ Set<String> getKeywords();
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -30,7 +30,9 @@
import java.util.Collection;
/**
- * A composite test runner.
+ * A composite test runner that executes a suite of test runners. If a runner throws an unchecked throwable during
+ * the execution of its <code>run</code> method then composite runner will not make an attempt to catch it
+ * and thus the execution will stop.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -59,7 +59,7 @@
return Collections.emptyMap();
}
- public Set<String> getTags()
+ public Set<String> getKeywords()
{
return Collections.emptySet();
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -37,7 +37,7 @@
public POJOTestCaseInfo(TestCaseDescriptor descriptor)
{
- super(descriptor.getParameters());
+ super(descriptor.getParameters(), descriptor.getKeywords());
//
this.descriptor = descriptor;
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -41,7 +41,10 @@
/** . */
private Map<String,POJOParameterInfo> parameters;
- public POJOTestInfo(Map<String,ParameterDescriptor> parameterDescriptors)
+ /** . */
+ private Set<String> keywords;
+
+ public POJOTestInfo(Map<String,? extends ParameterDescriptor> parameterDescriptors, Set<String> keywords)
{
Map<String, POJOParameterInfo> parameters = new HashMap<String, POJOParameterInfo>();
for (ParameterDescriptor parameterDescriptor : parameterDescriptors.values())
@@ -52,6 +55,7 @@
//
this.parameters = parameters;
+ this.keywords = keywords;
}
public Map<String, ? extends ParameterInfo> getParameters()
@@ -59,8 +63,8 @@
return parameters;
}
- public Set<String> getTags()
+ public Set<String> getKeywords()
{
- return Collections.emptySet();
+ return keywords;
}
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java 2007-10-01 16:34:06 UTC (rev 8504)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java 2007-10-01 22:01:06 UTC (rev 8505)
@@ -47,7 +47,7 @@
public POJOTestSuiteInfo(TestHandler handler)
{
- super(handler.getParameters());
+ super(handler.getParameters(), handler.getKeywords());
//
HashMap<String, POJOTestCaseInfo> testCases = new HashMap<String, POJOTestCaseInfo>();
16 years, 7 months
JBoss Portal SVN: r8504 - in modules/test/trunk/unit: src/main/org/jboss/test/unit and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 12:34:06 -0400 (Mon, 01 Oct 2007)
New Revision: 8504
Added:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTests.java
Removed:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java
Modified:
modules/test/trunk/unit/build.xml
modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
Log:
refactored the pojo tests to test the TestHandler in addition of the pojo test driver
Modified: modules/test/trunk/unit/build.xml
===================================================================
--- modules/test/trunk/unit/build.xml 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/build.xml 2007-10-01 16:34:06 UTC (rev 8504)
@@ -181,9 +181,13 @@
<target name="most" depends="_default:most"/>
<target name="help" depends="_default:help"/>
- <target name="test" depends="init">
+ <target name="test" depends="output">
<java classname="org.jboss.test.unit.AllTests" fork="true">
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
<classpath>
<path location="${build.lib}/jboss-unit-lib.jar"/>
<path location="${build.lib}/jboss-unit-test.jar"/>
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -24,7 +24,7 @@
import org.jboss.test.unit.api.AssertTests;
import org.jboss.test.unit.blah.BlahTests;
-import org.jboss.test.unit.pojo.POJOTestDriverTests;
+import org.jboss.test.unit.pojo.AbstractPOJOTests;
import org.jboss.test.unit.runner.CompositeTestRunnerTests;
import org.jboss.test.unit.runner.ParametrizationTests;
import org.jboss.test.unit.runner.event.TestRunnerEventBroadcasterSupportTests;
@@ -41,7 +41,9 @@
public static void main(String[] args) throws Exception
{
AssertTests.main(args);
- POJOTestDriverTests.main(args);
+// TestHandlerSupportTests.main(args);
+// POJOTestDriverTests.main(args);
+ AbstractPOJOTests.main(args);
CompositeTestRunnerTests.main(args);
//
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractPOJOTest
+{
+
+ public abstract Set<String> getParameterNames();
+
+ public abstract Set<String> getTestCaseNames();
+
+ public abstract Set<String> getTestCaseParameterNames(String testCaseName);
+
+ public abstract InvokeResult invoke(String testName, Map<String,String> parametrization);
+
+ public enum InvokeResult
+ {
+ PASS, FAILURE, ERROR
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractPOJOTests.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,316 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+
+import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractPOJOTests
+{
+
+ public static void main(String[] args)
+ {
+ new TestDriverPOJOTests().test();
+ new TestHandlerSupportPOJOTests().test();
+ }
+
+
+ public void test()
+ {
+ testAbstractClassWithoutAnnotations();
+ testClassWithoutAnnotations();
+ testAbstractClassAnnotatedWithTest();
+ testClassAnnotatedWithTest();
+
+ //
+ testMethodAnnotatedWithTest();
+ testTestMethodHavingArgumentsAnnotatedWithParameter();
+ testTestMethodAnnotatedWithConflictingAnnotations();
+ testMethodAnnotatedWithParameter();
+ testMethodAnnotatedWithCreate();
+
+ //
+ testClassHavingSamePropertyParameterAndMethodArgumentParameter();
+
+ //
+ testClassWithoutDefaultConstructor();
+ testClassWithFailingConstructor();
+
+ //
+ testLifeCycleSequence();
+ }
+
+ private void testLifeCycleSequence()
+ {
+ testLifeCycleSequence(LifeCycleSequence01.class, AbstractPOJOTest.InvokeResult.ERROR, null, false);
+ testLifeCycleSequence(LifeCycleSequence02.class, AbstractPOJOTest.InvokeResult.FAILURE, null, false);
+ testLifeCycleSequence(LifeCycleSequence03.class, AbstractPOJOTest.InvokeResult.ERROR, "C", false);
+ testLifeCycleSequence(LifeCycleSequence04.class, AbstractPOJOTest.InvokeResult.FAILURE, "C", false);
+ testLifeCycleSequence(LifeCycleSequence05.class, AbstractPOJOTest.InvokeResult.ERROR, "CSD", false);
+ testLifeCycleSequence(LifeCycleSequence06.class, AbstractPOJOTest.InvokeResult.FAILURE, "CSD", false);
+ testLifeCycleSequence(LifeCycleSequence07.class, AbstractPOJOTest.InvokeResult.ERROR, "CSRD", false);
+ testLifeCycleSequence(LifeCycleSequence08.class, AbstractPOJOTest.InvokeResult.FAILURE, "CSRD", false);
+ testLifeCycleSequence(LifeCycleSequence09.class, AbstractPOJOTest.InvokeResult.PASS, "CSRD", true);
+ testLifeCycleSequence(LifeCycleSequence10.class, AbstractPOJOTest.InvokeResult.PASS, "CSRD", true);
+ testLifeCycleSequence(LifeCycleSequence11.class, AbstractPOJOTest.InvokeResult.PASS, "CSRD", true);
+ }
+
+ private void testLifeCycleSequence(Class clazz, AbstractPOJOTest.InvokeResult result, String expected, boolean invoked)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", result, invoked);
+
+ //
+ Assert.assertEquals(expected, POJOAssert.buffer1);
+ }
+
+ private void testMethodAnnotatedWithCreate()
+ {
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate01.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate02.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate03.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate04.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate05.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate06.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate07.class);
+ }
+
+ private void testMethodAnnotatedWithCreate(Class clazz)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", AbstractPOJOTest.InvokeResult.PASS, true);
+ }
+
+ private void testClassHavingSamePropertyParameterAndMethodArgumentParameter()
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(ClassHavingSamePropertyParameterAndMethodArgumentParameter.class);
+
+ //
+ invoke(driver, ClassHavingSamePropertyParameterAndMethodArgumentParameter.class, "testFoo", AbstractPOJOTest.InvokeResult.PASS, true);
+ }
+
+ private void testClassWithFailingConstructor()
+ {
+ testClassWithFailingConstructor(ClassWithFailingConstructor1.class, AbstractPOJOTest.InvokeResult.ERROR, false);
+ testClassWithFailingConstructor(ClassWithFailingConstructor2.class, AbstractPOJOTest.InvokeResult.ERROR, false);
+ testClassWithFailingConstructor(ClassWithFailingConstructor3.class, AbstractPOJOTest.InvokeResult.ERROR, false);
+ testClassWithFailingConstructor(ClassWithFailingConstructor4.class, AbstractPOJOTest.InvokeResult.FAILURE, false);
+ }
+
+ private void testClassWithFailingConstructor(Class clazz, AbstractPOJOTest.InvokeResult result, boolean invoked)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", result, invoked);
+ }
+
+ private void testClassWithoutDefaultConstructor()
+ {
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor1.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor2.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor3.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor4.class);
+ }
+
+ private void testMethodAnnotatedWithParameter()
+ {
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter01.class, false, AbstractPOJOTest.InvokeResult.PASS, true, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter02.class, false, AbstractPOJOTest.InvokeResult.PASS, true, "bar");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter05.class, true, AbstractPOJOTest.InvokeResult.PASS, true, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter06.class, true, AbstractPOJOTest.InvokeResult.PASS, true, "bar");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter07.class, true, AbstractPOJOTest.InvokeResult.PASS, true, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter09.class, true, AbstractPOJOTest.InvokeResult.PASS, true, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter10.class, true, AbstractPOJOTest.InvokeResult.ERROR, false, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter11.class, true, AbstractPOJOTest.InvokeResult.ERROR, false, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter12.class, true, AbstractPOJOTest.InvokeResult.ERROR, false, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter13.class, true, AbstractPOJOTest.InvokeResult.FAILURE, false, "foo");
+ }
+
+ private void testMethodAnnotatedWithParameter(Class clazz, boolean invoke, AbstractPOJOTest.InvokeResult result, boolean invoked, String... expectedParameterNames)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ assertParametersEquals(driver.getParameterNames(), expectedParameterNames);
+
+ //
+ if (invoke)
+ {
+ Assert.assertEquals(1, driver.getTestCaseNames().size());
+ Assert.assertEquals(driver.getParameterNames(), driver.getTestCaseParameterNames("test"));
+ invoke(driver, clazz, "test", result, invoked);
+ }
+ else
+ {
+ Assert.assertEquals(0, driver.getTestCaseNames().size());
+ }
+ }
+
+ private void testTestMethodAnnotatedWithConflictingAnnotations()
+ {
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations1.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations2.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations3.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations4.class);
+ }
+
+ private void testTestMethodHavingArgumentsAnnotatedWithParameter(Class clazz, String... expectedParameterNames)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ Assert.assertEquals(Collections.singleton("testFoo"), driver.getTestCaseNames());
+
+ //
+ assertParametersEquals(driver.getTestCaseParameterNames("testFoo"), expectedParameterNames);
+
+ //
+ invoke(driver, clazz, "testFoo", AbstractPOJOTest.InvokeResult.PASS, true);
+ }
+
+ private void testTestMethodHavingArgumentsAnnotatedWithParameter()
+ {
+ testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter1.class, "paramFoo");
+ testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter2.class, "paramFoo", "paramBar");
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter3.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter4.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter5.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter6.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter7.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter8.class);
+ }
+
+ private void testMethodAnnotatedWithTest()
+ {
+ testMethodAnnotatedWithTest(MethodAnnotatedWithTest1.class, "testFoo");
+ testMethodAnnotatedWithTest(MethodAnnotatedWithTest2.class, "testBar");
+ assertCannotBuildSuite(MethodAnnotatedWithTest5.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest6.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest7.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest8.class);
+ assertCannotBuildSuite(MethodAnnotatedWithTest9.class);
+ }
+
+ private void testMethodAnnotatedWithTest(Class clazz, String testName)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+
+ //
+ Assert.assertEquals(Collections.singleton(testName), driver.getTestCaseNames());
+ Assert.assertEquals(Collections.emptySet(), driver.getTestCaseParameterNames(testName));
+
+ //
+ invoke(driver, clazz, testName, AbstractPOJOTest.InvokeResult.PASS, true);
+ }
+
+ private void testAbstractClassWithoutAnnotations()
+ {
+ assertCannotBuildSuite(AbstractClassWithoutAnnotations.class);
+ }
+
+ private void testClassWithoutAnnotations()
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(ClassWithoutAnnotations.class);
+ Assert.assertEquals(new HashSet(), driver.getParameterNames());
+ Assert.assertEquals(new HashSet(), driver.getTestCaseNames());
+ }
+
+ private void testAbstractClassAnnotatedWithTest()
+ {
+ assertCannotBuildSuite(AbstractClassAnnotatedWithTest1.class);
+ assertCannotBuildSuite(AbstractClassAnnotatedWithTest2.class);
+ }
+
+ private void testClassAnnotatedWithTest()
+ {
+ testClassAnnotatedPOJO(ClassAnnotatedWithTest1.class, ClassAnnotatedWithTest1.class.getName(), null);
+ testClassAnnotatedPOJO(ClassAnnotatedWithTest2.class, "foo", null);
+ }
+
+ private void testClassAnnotatedPOJO(Class clazz, String name, String description)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+ Assert.assertEquals(new HashSet(), driver.getParameterNames());
+ Assert.assertEquals(new HashSet(), driver.getTestCaseNames());
+ }
+
+ private void assertParametersEquals(Set<String> parametersInfo, String... expectedParameterNames)
+ {
+ Assert.assertEquals(expectedParameterNames.length, parametersInfo.size());
+ for (String expectedParameterName : expectedParameterNames)
+ {
+ Assert.assertTrue(parametersInfo.contains(expectedParameterName));
+ }
+ }
+
+ // *************************
+
+ private void invoke(AbstractPOJOTest driver, Class clazz, String testName, AbstractPOJOTest.InvokeResult expectedResult, boolean invoked)
+ {
+ Map<String, String> parametrization = new HashMap<String, String>();
+ Map<String,Object> expectedParameterValues = new HashMap<String, Object>();
+ for (String expectedParameterName : driver.getTestCaseParameterNames(testName))
+ {
+ String expectedParameterValue = expectedParameterName + "_value";
+ parametrization.put(expectedParameterName, expectedParameterValue);
+ expectedParameterValues.put(expectedParameterName, expectedParameterValue);
+ }
+
+ //
+ POJOAssert.clear();
+ AbstractPOJOTest.InvokeResult result = driver.invoke(testName, parametrization);
+ Assert.assertEquals(expectedResult, result);
+ if (invoked)
+ {
+ POJOAssert.assertWasCalled(clazz, expectedParameterValues);
+ }
+ else
+ {
+ POJOAssert.assertWasNotCalled();
+ }
+ }
+
+ private void assertClassHasNoTests(Class clazz)
+ {
+ AbstractPOJOTest driver = assertCanBuildSuite(clazz);
+ Assert.assertEquals(Collections.EMPTY_SET, driver.getTestCaseNames());
+ }
+
+ protected abstract void assertCannotBuildSuite(Class clazz);
+
+ protected abstract AbstractPOJOTest assertCanBuildSuite(Class clazz);
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -34,5 +34,6 @@
@Create
public static void foo()
{
+ POJOAssert.buffer1 = "foo";
}
}
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -34,5 +34,6 @@
@Create
public void foo(String s)
{
+ POJOAssert.buffer1 = "foo";
}
}
Deleted: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -1,406 +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.test.unit.pojo;
-
-import org.jboss.unit.Failure;
-import org.jboss.unit.FailureType;
-import org.jboss.unit.TestId;
-import static org.jboss.unit.api.Assert.*;
-import org.jboss.unit.driver.DriverResponse;
-import org.jboss.unit.driver.TestDriver;
-import org.jboss.unit.driver.command.StartTestCommand;
-import org.jboss.unit.driver.response.EndTestResponse;
-import org.jboss.unit.driver.response.FailureResponse;
-import org.jboss.unit.info.ParameterInfo;
-import org.jboss.unit.info.TestCaseInfo;
-import org.jboss.unit.info.TestInfo;
-import org.jboss.unit.info.TestSuiteInfo;
-import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class POJOTestDriverTests
-{
-
- public static void main(String[] args)
- {
- testAbstractClassWithoutAnnotations();
- testClassWithoutAnnotations();
- testAbstractClassAnnotatedWithTest();
- testClassAnnotatedWithTest();
-
- //
- testMethodAnnotatedWithTest();
- testTestMethodHavingArgumentsAnnotatedWithParameter();
- testTestMethodAnnotatedWithConflictingAnnotations();
- testMethodAnnotatedWithParameter();
- testMethodAnnotatedWithCreate();
-
- //
- testClassHavingSamePropertyParameterAndMethodArgumentParameter();
-
- //
- testClassWithoutDefaultConstructor();
- testClassWithFailingConstructor();
-
- //
- testLifeCycleSequence();
- }
-
- private static void testLifeCycleSequence()
- {
- testLifeCycleSequence(LifeCycleSequence01.class, InvokeResult.NOT_CALLED_ERROR, null);
- testLifeCycleSequence(LifeCycleSequence02.class, InvokeResult.NOT_CALLED_FAIL, null);
- testLifeCycleSequence(LifeCycleSequence03.class, InvokeResult.NOT_CALLED_ERROR, "C");
- testLifeCycleSequence(LifeCycleSequence04.class, InvokeResult.NOT_CALLED_FAIL, "C");
- testLifeCycleSequence(LifeCycleSequence05.class, InvokeResult.NOT_CALLED_ERROR, "CSD");
- testLifeCycleSequence(LifeCycleSequence06.class, InvokeResult.NOT_CALLED_FAIL, "CSD");
- testLifeCycleSequence(LifeCycleSequence07.class, InvokeResult.NOT_CALLED_ERROR, "CSRD");
- testLifeCycleSequence(LifeCycleSequence08.class, InvokeResult.NOT_CALLED_FAIL, "CSRD");
- testLifeCycleSequence(LifeCycleSequence09.class, InvokeResult.PASS, "CSRD");
- testLifeCycleSequence(LifeCycleSequence10.class, InvokeResult.PASS, "CSRD");
- testLifeCycleSequence(LifeCycleSequence11.class, InvokeResult.PASS, "CSRD");
-
-
-
-
-// testMethodAnnotatedWithFailingCreate(LifeCycleSequence02_.class, InvokeResult.NOT_CALLED_ERROR);
-// testMethodAnnotatedWithFailingCreate(LifeCycleSequence03_.class, InvokeResult.NOT_CALLED_ERROR);
-// testMethodAnnotatedWithFailingCreate(LifeCycleSequence04_.class, InvokeResult.NOT_CALLED_FAIL);
-// testMethodAnnotatedWithCreate(LifeCycleSequence05_.class);
- }
-
- private static void testLifeCycleSequence(Class clazz, InvokeResult result, String expected)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- invoke(driver, clazz, "testFoo", result);
-
- //
- assertEquals(expected, POJOAssert.buffer1);
- }
-
- private static void testMethodAnnotatedWithCreate()
- {
- testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate01.class);
- testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate02.class);
- testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate03.class);
- testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate04.class);
- assertCannotBuildSuite(MethodAnnotatedWithCreate05.class);
- assertCannotBuildSuite(MethodAnnotatedWithCreate06.class);
- assertCannotBuildSuite(MethodAnnotatedWithCreate07.class);
- }
-
- private static void testMethodAnnotatedWithCreate(Class clazz)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- invoke(driver, clazz, "testFoo", InvokeResult.PASS);
- }
-
- private static void testClassHavingSamePropertyParameterAndMethodArgumentParameter()
- {
- TestDriver driver = assertCanBuildSuite(ClassHavingSamePropertyParameterAndMethodArgumentParameter.class);
-
- //
- invoke(driver, ClassHavingSamePropertyParameterAndMethodArgumentParameter.class, "testFoo", InvokeResult.PASS);
- }
-
- private static void testClassWithFailingConstructor()
- {
- testClassWithFailingConstructor(ClassWithFailingConstructor1.class, InvokeResult.NOT_CALLED_ERROR);
- testClassWithFailingConstructor(ClassWithFailingConstructor2.class, InvokeResult.NOT_CALLED_ERROR);
- testClassWithFailingConstructor(ClassWithFailingConstructor3.class, InvokeResult.NOT_CALLED_ERROR);
- testClassWithFailingConstructor(ClassWithFailingConstructor4.class, InvokeResult.NOT_CALLED_FAIL);
- }
-
- private static void testClassWithFailingConstructor(Class clazz, InvokeResult result)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- invoke(driver, clazz, "testFoo", result);
- }
-
- private static void testClassWithoutDefaultConstructor()
- {
- assertCannotBuildSuite(ClassWithoutDefaultConstructor1.class);
- assertCannotBuildSuite(ClassWithoutDefaultConstructor2.class);
- assertCannotBuildSuite(ClassWithoutDefaultConstructor3.class);
- assertCannotBuildSuite(ClassWithoutDefaultConstructor4.class);
- }
-
- private static void testMethodAnnotatedWithParameter()
- {
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter01.class, false, InvokeResult.PASS, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter02.class, false, InvokeResult.PASS, "bar");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter05.class, true, InvokeResult.PASS, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter06.class, true, InvokeResult.PASS, "bar");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter07.class, true, InvokeResult.PASS, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter09.class, true, InvokeResult.PASS, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter10.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter11.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter12.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
- testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter13.class, true, InvokeResult.NOT_CALLED_FAIL, "foo");
- }
-
- private static void testMethodAnnotatedWithParameter(Class clazz, boolean invoke, InvokeResult result, String... expectedParameterNames)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
-
- //
- Map<String, ? extends ParameterInfo> parametersInfo = info.getParameters();
- assertParametersEquals(parametersInfo, expectedParameterNames);
-
- //
- if (invoke)
- {
- assertEquals(1, info.getNames().size());
- TestCaseInfo caseInfo = (TestCaseInfo)info.getTest("test");
- assertNotNull(caseInfo);
- assertParametersEquals(caseInfo.getParameters(), expectedParameterNames);
-
- //
- invoke(driver, clazz, "test", result);
- }
- else
- {
- assertEquals(0, info.getNames().size());
- }
- }
-
- private static void testTestMethodAnnotatedWithConflictingAnnotations()
- {
- assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations1.class);
- assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations2.class);
- assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations3.class);
- assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations4.class);
- }
-
- private static void testTestMethodHavingArgumentsAnnotatedWithParameter(Class clazz, String... expectedParameterNames)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- TestSuiteInfo suiteInfo = (TestSuiteInfo)driver.getInfo();
-
- //
- assertEquals(Collections.singleton("testFoo"), suiteInfo.getNames());
- TestInfo testFooInfo = suiteInfo.getTest("testFoo");
- assertNotNull(testFooInfo);
- assertInstanceOf(testFooInfo, TestCaseInfo.class);
-
- //
- Map<String, ? extends ParameterInfo> parametersInfo = testFooInfo.getParameters();
- assertParametersEquals(parametersInfo, expectedParameterNames);
-
- //
- invoke(driver, clazz, "testFoo", InvokeResult.PASS);
- }
-
- private static void testTestMethodHavingArgumentsAnnotatedWithParameter()
- {
- testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter1.class, "paramFoo");
- testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter2.class, "paramFoo", "paramBar");
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter3.class);
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter4.class);
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter5.class);
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter6.class);
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter7.class);
- assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter8.class);
- }
-
- private static void testMethodAnnotatedWithTest()
- {
- testMethodAnnotatedWithTest(MethodAnnotatedWithTest1.class, "testFoo");
- testMethodAnnotatedWithTest(MethodAnnotatedWithTest2.class, "testBar");
- assertCannotBuildSuite(MethodAnnotatedWithTest5.class);
- assertClassHasNoTests(MethodAnnotatedWithTest6.class);
- assertClassHasNoTests(MethodAnnotatedWithTest7.class);
- assertClassHasNoTests(MethodAnnotatedWithTest8.class);
- assertCannotBuildSuite(MethodAnnotatedWithTest9.class);
- }
-
- private static void testMethodAnnotatedWithTest(Class clazz, String testName)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
-
- //
- TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
- assertEquals(Collections.singleton(testName), info.getNames());
- TestInfo testFooInfo = info.getTest(testName);
- assertNotNull(testFooInfo);
- assertInstanceOf(testFooInfo, TestCaseInfo.class);
- assertEquals(testName, testFooInfo.getName());
- assertEquals(Collections.EMPTY_MAP, testFooInfo.getParameters());
-
- //
- POJOAssert.clear();
- DriverResponse response = driver.invoke(new TestId(testName), new StartTestCommand());
- assertInstanceOf(response, EndTestResponse.class);
- POJOAssert.assertWasCalled(clazz);
- }
-
- private static void testAbstractClassWithoutAnnotations()
- {
- assertCannotBuildSuite(AbstractClassWithoutAnnotations.class);
- }
-
- private static void testClassWithoutAnnotations()
- {
- TestDriver driver = assertCanBuildSuite(ClassWithoutAnnotations.class);
- TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
- assertEquals(new HashMap(), info.getParameters());
- assertEquals(new HashSet(), info.getNames());
- }
-
- private static void testAbstractClassAnnotatedWithTest()
- {
- assertCannotBuildSuite(AbstractClassAnnotatedWithTest1.class);
- assertCannotBuildSuite(AbstractClassAnnotatedWithTest2.class);
- }
-
- private static void testClassAnnotatedWithTest()
- {
- testClassAnnotatedPOJO(ClassAnnotatedWithTest1.class, ClassAnnotatedWithTest1.class.getName(), null);
- testClassAnnotatedPOJO(ClassAnnotatedWithTest2.class, "foo", null);
- }
-
- private static void testClassAnnotatedPOJO(Class clazz, String name, String description)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
- TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
- assertEquals(new HashMap(), info.getParameters());
- assertEquals(new HashSet(), info.getNames());
- }
-
- private static void assertParametersEquals(Map<String, ? extends ParameterInfo> parametersInfo, String... expectedParameterNames)
- {
- assertEquals(expectedParameterNames.length, parametersInfo.size());
- for (String expectedParameterName : expectedParameterNames)
- {
- ParameterInfo parameterInfo = parametersInfo.get(expectedParameterName);
- assertNotNull(parameterInfo);
- assertEquals(expectedParameterName, parameterInfo.getName());
- }
- }
-
- // *************************
-
- private enum InvokeResult
- {
- PASS, NOT_CALLED_FAIL, NOT_CALLED_ERROR
- }
-
- private static void invoke(TestDriver driver, Class clazz, String testName, InvokeResult result)
- {
- TestCaseInfo testInfo = (TestCaseInfo)((TestSuiteInfo)driver.getInfo()).getTest(testName);
- assertNotNull(testInfo);
-
- //
- Map<String, String> expectedParametrization = new HashMap<String, String>();
- Map<String,Object> expectedParameterValues = new HashMap<String, Object>();
- for (String expectedParameterName : testInfo.getParameters().keySet())
- {
- String expectedParameterValue = expectedParameterName + "_value";
- expectedParametrization.put(expectedParameterName, expectedParameterValue);
- expectedParameterValues.put(expectedParameterName, expectedParameterValue);
- }
-
- //
- POJOAssert.clear();
- DriverResponse response = driver.invoke(new TestId(testName), new StartTestCommand(expectedParametrization));
- switch(result)
- {
- case PASS:
- {
- assertInstanceOf(response, EndTestResponse.class);
- POJOAssert.assertWasCalled(clazz, expectedParameterValues);
- break;
- }
- case NOT_CALLED_FAIL:
- {
- FailureResponse failureResponse = assertInstanceOf(response, FailureResponse.class);
- Failure failure = failureResponse.getFailure();
- assertEquals(FailureType.ASSERTION, failure.getLevel());
- POJOAssert.assertWasNotCalled();
- break;
- }
- case NOT_CALLED_ERROR:
- {
- FailureResponse failureResponse = assertInstanceOf(response, FailureResponse.class);
- Failure failure = failureResponse.getFailure();
- assertEquals(FailureType.ERROR, failure.getLevel());
- POJOAssert.assertWasNotCalled();
- break;
- }
- }
- }
-
- private static void assertClassHasNoTests(Class clazz)
- {
- TestDriver driver = assertCanBuildSuite(clazz);
- TestSuiteInfo suiteInfo = (TestSuiteInfo)driver.getInfo();
- assertEquals(Collections.EMPTY_SET, suiteInfo.getNames());
- }
-
- private static void assertCannotBuildSuite(Class clazz)
- {
- try
- {
- new POJOTestSuiteDriver(clazz);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- private static TestDriver assertCanBuildSuite(Class clazz)
- {
- TestDriver driver = new POJOTestSuiteDriver(clazz);
-
- //
- assertNotNull(driver);
-
- //
- TestInfo info = driver.getInfo();
- assertNotNull(info);
- assertInstanceOf(info, TestSuiteInfo.class);
-
- //
- return driver;
- }
-}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import org.jboss.unit.info.ParameterInfo;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestCaseInfo;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.TestId;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDriverPOJOTest extends AbstractPOJOTest
+{
+
+ /** . */
+ private final TestDriver testDriver;
+
+ /** . */
+ private final TestSuiteInfo suiteInfo;
+
+ public TestDriverPOJOTest(TestDriver testDriver)
+ {
+ TestInfo info = testDriver.getInfo();
+ assertNotNull(info);
+ TestSuiteInfo suiteInfo = assertInstanceOf(info, TestSuiteInfo.class);
+
+ //
+ this.testDriver = testDriver;
+ this.suiteInfo = suiteInfo;
+ }
+
+ public Set<String> getParameterNames()
+ {
+ return suiteInfo.getParameters().keySet();
+ }
+
+ public Set<String> getTestCaseNames()
+ {
+ return suiteInfo.getNames();
+ }
+
+ public Set<String> getTestCaseParameterNames(String testCaseName)
+ {
+ TestInfo info = suiteInfo.getTest(testCaseName);
+ assertNotNull(info);
+ TestCaseInfo testCaseInfo = assertInstanceOf(info, TestCaseInfo.class);
+ Map<String, ? extends ParameterInfo> testCaseParameterInfos = testCaseInfo.getParameters();
+ assertNotNull(testCaseParameterInfos);
+ return testCaseParameterInfos.keySet();
+ }
+
+ public InvokeResult invoke(String testName, Map<String, String> parametrization)
+ {
+ DriverResponse response = testDriver.invoke(new TestId(testName), new StartTestCommand(parametrization));
+ assertNotNull(response);
+ if (response instanceof EndTestResponse)
+ {
+ return InvokeResult.PASS;
+ }
+ else if (response instanceof FailureResponse)
+ {
+ FailureResponse failureResponse = (FailureResponse)response;
+ switch (failureResponse.getFailure().getLevel())
+ {
+ case ERROR:
+ return InvokeResult.ERROR;
+ case ASSERTION:
+ return InvokeResult.FAILURE;
+ }
+ }
+ throw createFailure();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+import static org.jboss.unit.api.Assert.fail;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDriverPOJOTests extends AbstractPOJOTests
+{
+
+ protected void assertCannotBuildSuite(Class clazz)
+ {
+ try
+ {
+ new POJOTestSuiteDriver(clazz);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ protected AbstractPOJOTest assertCanBuildSuite(Class clazz)
+ {
+ TestDriver driver = new POJOTestSuiteDriver(clazz);
+
+ //
+ return new TestDriverPOJOTest(driver);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.TestHandler;
+import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+
+import static org.jboss.unit.api.Assert.*;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestHandlerSupportPOJOTest extends AbstractPOJOTest
+{
+
+ /** . */
+ private TestHandler handler;
+
+ public TestHandlerSupportPOJOTest(TestHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ public Set<String> getParameterNames()
+ {
+ return handler.getParameters().keySet();
+ }
+
+ public Set<String> getTestCaseNames()
+ {
+ return handler.getTestCases().keySet();
+ }
+
+ public Set<String> getTestCaseParameterNames(String testCaseName)
+ {
+ TestCaseDescriptor descriptor = handler.getTestCases().get(testCaseName);
+ assertNotNull(descriptor);
+ return descriptor.getParameters().keySet();
+ }
+
+ public InvokeResult invoke(String testName, Map<String, String> parametrization)
+ {
+ Object testCase = null;
+ boolean invokeDestroy = false;
+ try
+ {
+ testCase = handler.newTestCase(testName);
+ handler.testCaseParametrize(testCase, parametrization);
+ invokeDestroy = true;
+ handler.testCaseCreate(testCase);
+ handler.testCaseInvoke(testCase);
+ return InvokeResult.PASS;
+ }
+ catch (TestCaseLifeCycleException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause instanceof AssertionError)
+ {
+ return InvokeResult.FAILURE;
+ }
+ else
+ {
+ return InvokeResult.ERROR;
+ }
+ }
+ finally
+ {
+ if (invokeDestroy)
+ {
+ handler.testCaseDestroy(testCase);
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTests.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.TestHandlerSupport;
+import org.jboss.unit.api.Assert;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestHandlerSupportPOJOTests extends AbstractPOJOTests
+{
+
+
+ protected void assertCannotBuildSuite(Class clazz)
+ {
+ try
+ {
+ new TestHandlerSupport(clazz);
+ Assert.fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ protected AbstractPOJOTest assertCanBuildSuite(Class clazz)
+ {
+ return new TestHandlerSupportPOJOTest(new TestHandlerSupport(clazz));
+ }
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -251,6 +251,16 @@
throw createAssertionError(cause, msg);
}
+ public static Error createFailure()
+ {
+ return createFailure(null);
+ }
+
+ public static Error createFailure(String msg)
+ {
+ return createAssertionError(null, msg);
+ }
+
public static Error createAssertionError(Throwable cause, String msg)
{
if (msg == null)
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-10-01 10:08:06 UTC (rev 8503)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-10-01 16:34:06 UTC (rev 8504)
@@ -443,7 +443,7 @@
//
if (testCaseDef == null)
{
- throw new TestCaseLifeCycleException();
+ throw new TestCaseLifeCycleException("No such test case <" + name + ">");
}
//
16 years, 7 months
JBoss Portal SVN: r8503 - in modules/test/trunk/unit/src/main/org/jboss: unit and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 06:08:06 -0400 (Mon, 01 Oct 2007)
New Revision: 8503
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java
modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
Log:
make RunnerFailureEvent use the Failure object instead of having the FailureType + Throwable state
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java 2007-10-01 09:48:27 UTC (rev 8502)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java 2007-10-01 10:08:06 UTC (rev 8503)
@@ -54,7 +54,8 @@
}
else if (event instanceof RunnerFailureEvent)
{
- RunnerFailureEvent failure = (RunnerFailureEvent)event;
+ RunnerFailureEvent failureEvent = (RunnerFailureEvent)event;
+ Failure failure = failureEvent.getFailure();
System.out.println("Runner failure: " + failure.getLevel() + " " + failure.getMessage());
}
else if (event instanceof StartTestEvent)
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java 2007-10-01 09:48:27 UTC (rev 8502)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java 2007-10-01 10:08:06 UTC (rev 8503)
@@ -54,6 +54,13 @@
this.type = type;
}
+ public Failure(String message, Throwable cause, FailureType type)
+ {
+ this.message = message;
+ this.cause = cause;
+ this.type = type;
+ }
+
public String getMessage()
{
return message;
@@ -74,6 +81,11 @@
return new Failure(messge, FailureType.ERROR);
}
+ public static Failure createErrorFailure(String message, Throwable throwable)
+ {
+ return new Failure(message, throwable, FailureType.ERROR);
+ }
+
public static Failure createErrorFailure(Throwable throwable)
{
return new Failure(throwable, FailureType.ERROR);
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java 2007-10-01 09:48:27 UTC (rev 8502)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java 2007-10-01 10:08:06 UTC (rev 8503)
@@ -23,7 +23,7 @@
package org.jboss.unit.runner.event;
import org.jboss.unit.runner.TestRunnerEvent;
-import org.jboss.unit.FailureType;
+import org.jboss.unit.Failure;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -33,44 +33,15 @@
{
/** . */
- private String message;
+ private Failure failure;
- /** . */
- private Throwable throwable;
-
- /** . */
- private FailureType type;
-
- public RunnerFailureEvent(String message, FailureType type)
+ public RunnerFailureEvent(Failure failure)
{
- this.message = message;
- this.type = type;
+ this.failure = failure;
}
- public RunnerFailureEvent(String message, FailureType type, Throwable throwable)
+ public Failure getFailure()
{
- this.message = message;
- this.type = type;
- this.throwable = throwable;
+ return failure;
}
-
- public RunnerFailureEvent(Throwable throwable)
- {
- this.throwable = throwable;
- }
-
- public FailureType getLevel()
- {
- return type;
- }
-
- public String getMessage()
- {
- return message != null ? message : throwable.getMessage();
- }
-
- public Throwable getThrowable()
- {
- return throwable;
- }
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-10-01 09:48:27 UTC (rev 8502)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-10-01 10:08:06 UTC (rev 8503)
@@ -32,7 +32,6 @@
import org.jboss.unit.info.TestInfo;
import org.jboss.unit.TestId;
import org.jboss.unit.Failure;
-import org.jboss.unit.FailureType;
import org.jboss.unit.runner.results.TestSuccess;
import org.jboss.unit.runner.results.TestFailure;
import org.jboss.unit.runner.event.StartTestEvent;
@@ -114,7 +113,7 @@
}
else
{
- fireEvent(new RunnerFailureEvent("Cannot execute test id " + testId, FailureType.ERROR));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test id " + testId)));
}
}
}
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-01 09:48:27 UTC (rev 8502)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-01 10:08:06 UTC (rev 8503)
@@ -35,6 +35,7 @@
import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.FailureType;
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.unit.pojo.POJOTestSuiteDriver;
@@ -128,17 +129,17 @@
}
catch (Exception e)
{
- fireEvent(new RunnerFailureEvent("Cannot execute test id " + testDefId, FailureType.ERROR,e));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test id " + testDefId,e)));
}
}
else
{
- fireEvent(new RunnerFailureEvent("No test definition found for id " + testDefId, FailureType.ERROR));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test definition found for id " + testDefId)));
}
}
else
{
- fireEvent(new RunnerFailureEvent("No test definition found for id " + testDefId, FailureType.ERROR));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test definition found for id " + testDefId)));
}
}
}
16 years, 7 months
JBoss Portal SVN: r8502 - in modules/test/trunk/unit/src/main/org/jboss/unit/runner: results and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 05:48:27 -0400 (Mon, 01 Oct 2007)
New Revision: 8502
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java
Log:
add support for TestResult parametrization
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java 2007-10-01 09:10:06 UTC (rev 8501)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java 2007-10-01 09:48:27 UTC (rev 8502)
@@ -23,6 +23,7 @@
package org.jboss.unit.runner;
import java.util.Map;
+import java.util.HashMap;
/**
* Base class for test results.
@@ -39,11 +40,17 @@
/** . */
private Map<String,String> parametrization;
- public TestResult(long durationMillis)
+ protected TestResult(Map<String, String> parametrization, long durationMillis)
{
+ this.parametrization = parametrization;
this.durationMillis = durationMillis;
}
+ public TestResult(long durationMillis)
+ {
+ this(new HashMap<String, String>(), durationMillis);
+ }
+
public long getDurationMillis()
{
return durationMillis;
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java 2007-10-01 09:10:06 UTC (rev 8501)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java 2007-10-01 09:48:27 UTC (rev 8502)
@@ -25,6 +25,8 @@
import org.jboss.unit.Failure;
import org.jboss.unit.runner.TestResult;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -35,6 +37,22 @@
/** . */
private final Failure failure;
+ public TestFailure(Failure failure, Map<String, String> parametrization, long durationMillis)
+ {
+ super(parametrization, durationMillis);
+
+ //
+ this.failure = failure;
+ }
+
+ public TestFailure(long durationMillis, Failure failure)
+ {
+ super(durationMillis);
+
+ //
+ this.failure = failure;
+ }
+
public TestFailure(Failure failure, long durationMillis)
{
super(durationMillis);
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java 2007-10-01 09:10:06 UTC (rev 8501)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java 2007-10-01 09:48:27 UTC (rev 8502)
@@ -24,12 +24,20 @@
import org.jboss.unit.runner.TestResult;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class TestSuccess extends TestResult
{
+
+ public TestSuccess(Map<String, String> parametrization, long durationMillis)
+ {
+ super(parametrization, durationMillis);
+ }
+
public TestSuccess(long durationMillis)
{
super(durationMillis);
16 years, 7 months
JBoss Portal SVN: r8501 - modules/test/trunk/unit/src/main/org/jboss/unit/api.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-01 05:10:06 -0400 (Mon, 01 Oct 2007)
New Revision: 8501
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
Log:
make Assert class final
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-09-30 22:38:06 UTC (rev 8500)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-10-01 09:10:06 UTC (rev 8501)
@@ -30,7 +30,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class Assert
+public final class Assert
{
public static <T> T assertInstanceOf(Object o, Class<T> c)
16 years, 7 months