Author: julien(a)jboss.com
Date: 2007-10-04 18:40:54 -0400 (Thu, 04 Oct 2007)
New Revision: 8536
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/spi/
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ArgumentTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/MethodKey.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ParameterDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/PropertyTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCase.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseImpl.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseLifeCycleException.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandler.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandlerSupport.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestLifeCycle.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestSuiteDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/annotations/
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/annotations/Provider.java
Removed:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.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/PropertyTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.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/TestCaseImpl.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.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/TestLifeCycle.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/TestSuiteDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Provider.java
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/TestHandlerSupportPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitLifeCycle.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitProvider.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethod.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethodLifeCycle.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/TestCase.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.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/POJOTestSuiteDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java
Log:
moved integration code from api package to new spi package
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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTest.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,10 +22,10 @@
******************************************************************************/
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 org.jboss.unit.api.pojo.TestCase;
+import org.jboss.unit.spi.pojo.TestHandler;
+import org.jboss.unit.spi.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
+import org.jboss.unit.spi.pojo.TestCase;
import static org.jboss.unit.api.Assert.*;
Modified:
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 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestHandlerSupportPOJOTests.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.test.unit.pojo;
-import org.jboss.unit.api.pojo.TestHandlerSupport;
+import org.jboss.unit.spi.pojo.TestHandlerSupport;
import org.jboss.unit.api.Assert;
/**
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,35 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class ArgumentTestParameter extends TestParameter
-{
- public ArgumentTestParameter(String name, String description)
- {
- super(name, description);
- }
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java 2007-10-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,101 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.lang.reflect.Method;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class MethodKey implements Comparable
-{
-
- /** . */
- private String name;
-
- /** . */
- private List<String> types;
-
- MethodKey(Method method)
- {
- List<String> types = new ArrayList<String>();
- for (Class type : method.getParameterTypes())
- {
- types.add(type.getName());
- }
-
- this.name = method.getName();
- this.types = types;
- }
-
- public int hashCode()
- {
- return name.hashCode() + types.hashCode();
- }
-
- public boolean equals(Object object)
- {
- if (object == this)
- {
- return true;
- }
- if (object instanceof MethodKey)
- {
- MethodKey that = (MethodKey)object;
- return that.name.equals(this.name) && that.types.equals(this.types);
- }
- return false;
- }
-
- public int compareTo(Object o)
- {
- MethodKey that = (MethodKey)o;
-
- //
- int sign = name.compareTo(that.name);
- if (sign != 0)
- {
- return sign;
- }
-
- //
- for (int index = 0;index < this.types.size() && index <
that.types.size();index++)
- {
- String thisName = this.types.get(index);
- String thatName = that.types.get(index);
-
- //
- int order = thisName.compareTo(thatName);
- if (order != 0)
- {
- return order;
- }
- }
-
- //
- return that.types.size() - this.types.size();
- }
-}
Deleted:
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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,41 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.List;
-
-/**
- * An object describing a parameter.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ParameterDescriptor
-{
-
- String getName();
-
- String getDescription();
-
- List<String> getDefaultValues();
-}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,48 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class PropertyTestParameter extends TestParameter
-{
-
- /** . */
- final List<Method> setters = new ArrayList<Method>();
-
- public PropertyTestParameter(String name, String description)
- {
- super(name, description);
- }
-
- void addSetter(Method setter)
- {
- setters.add(setter);
- }
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java 2007-10-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,32 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface TestCase
-{
- Object getPOJO();
-}
Deleted: 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-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,95 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-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 implements TestCaseDescriptor
-{
-
- /** . */
- TestHandlerSupport driver;
-
- /** . */
- final Method method;
-
- /** . */
- final String name;
-
- /** . */
- final String description;
-
- /** . */
- final LinkedHashMap<String,ArgumentTestParameter> arguments;
-
- /** . */
- final Map<String,TestParameter> 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()
- {
- return name;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public Map<String, ? extends ParameterDescriptor> getParameters()
- {
- return Collections.unmodifiableMap(parameters);
- }
-
- public Set<String> getKeywords()
- {
- return Collections.unmodifiableSet(keywords);
- }
-}
Deleted: 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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.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 interface TestCaseDescriptor
-{
-
- String getName();
-
- String getDescription();
-
- Map<String, ? extends ParameterDescriptor> getParameters();
-
- Set<String> getKeywords();
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseImpl.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseImpl.java 2007-10-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseImpl.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,52 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class TestCaseImpl implements TestCase
-{
-
- final TestCaseDef def;
-
- /** . */
- final Object pojo;
-
- /** . */
- Map<String,String> parametrization;
-
- public TestCaseImpl(TestCaseDef def, Object pojo)
- {
- this.def = def;
- this.pojo = pojo;
- }
-
- public Object getPOJO()
- {
- return pojo;
- }
-}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,49 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestCaseLifeCycleException extends Exception
-{
- public TestCaseLifeCycleException()
- {
- }
-
- public TestCaseLifeCycleException(String string)
- {
- super(string);
- }
-
- public TestCaseLifeCycleException(String string, Throwable throwable)
- {
- super(string, throwable);
- }
-
- public TestCaseLifeCycleException(Throwable throwable)
- {
- super(throwable);
- }
-}
Deleted: 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-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,38 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-/**
- * Allow a pojo class to take care of providing its description and perform test case
life cycle management.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface TestHandler
-{
-
- TestSuiteDescriptor getDescriptor();
-
- TestLifeCycle getLifeCycle();
-
-}
Deleted: 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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,597 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-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;
-import java.util.Map;
-import java.util.HashMap;
-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;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.annotation.Annotation;
-import java.beans.Introspector;
-
-/**
- * Provide a default implementation that relies on the annotation defined in the
<code>annotations</code> package.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestHandlerSupport implements TestHandler, TestLifeCycle,
TestSuiteDescriptor
-{
-
- /** . */
- private final String suiteName;
-
- /** . */
- private final String suiteDescription;
-
- /** . */
- private final Map<String, TestCaseDef> testCases;
-
- /** . */
- private final Method create;
-
- /** . */
- private final Method destroy;
-
- /** . */
- final Map<String, PropertyTestParameter> suiteParameters;
-
- /** . */
- private final Constructor ctor;
-
- /** . */
- private final Set<String> suiteKeywords;
-
- public TestHandlerSupport(Class testClass)
- {
- if (testClass == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (Modifier.isAbstract(testClass.getModifiers()))
- {
- throw new IllegalArgumentException("Test class is abstract");
- }
-
- // Check constructor
- Constructor ctor;
- try
- {
- ctor = testClass.getConstructor();
- }
- catch (NoSuchMethodException e)
- {
- throw new IllegalArgumentException(e);
- }
-
- //
- Test testAnnotation = ((AnnotatedElement)testClass).getAnnotation(Test.class);
- String suiteName = testAnnotation != null ? testAnnotation.name() : "";
- if (suiteName.length() == 0)
- {
- suiteName = testClass.getName();
- }
-
- //
- Description descriptionAnnotation =
((AnnotatedElement)testClass).getAnnotation(Description.class);
- 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())
- {
- MethodKey key = new MethodKey(method);
- methods.put(key, method);
- }
-
- //
- 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)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (createMethodAnnotation != null && parameterMethodAnnotation !=
null)
- {
- throw new IllegalArgumentException();
- }
- if (createMethodAnnotation != null && testMethodAnnotation != null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (destroyMethodAnnotation != null && parameterMethodAnnotation !=
null)
- {
- throw new IllegalArgumentException();
- }
- if (destroyMethodAnnotation != null && testMethodAnnotation != null)
- {
- throw new IllegalArgumentException();
- }
- if (destroyMethodAnnotation != null && createMethodAnnotation != null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (parameterMethodAnnotation != null)
- {
- if (!methodName.startsWith("set"))
- {
- throw new IllegalArgumentException();
- }
- if (methodName.length() < 4)
- {
- throw new IllegalArgumentException();
- }
- if (method.getParameterTypes().length != 1)
- {
- 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();
- }
-
- //
- String name = parameterMethodAnnotation.name();
- if (name.length() == 0)
- {
- name = Introspector.decapitalize(method.getName().substring(3));
- }
-
- //
- Description descriptionMethodAnnotation =
method.getAnnotation(Description.class);
- String description = descriptionMethodAnnotation != null ?
descriptionMethodAnnotation.description() : "";
- if (description.length() == 0)
- {
- description = "Parameter " + name;
- }
-
- //
- PropertyTestParameter parameter = suiteParameters.get(name);
- if (parameter == null)
- {
- parameter = new PropertyTestParameter(name, description);
- suiteParameters.put(name, parameter);
- }
-
- //
- parameter.addSetter(method);
- }
- 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();
- }
-
- //
- 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>();
- for (Annotation parameterAnnotation : parameterAnnotations)
- {
- Class<? extends Annotation> blah =
parameterAnnotation.annotationType();
- parameterAnnotationMap.put(blah, parameterAnnotation);
- }
-
- //
- Parameter argumentParameterAnnotation =
(Parameter)parameterAnnotationMap.get(Parameter.class);
-
- //
- if (argumentParameterAnnotation != null)
- {
- //
- String name = argumentParameterAnnotation.name();
- if (name.length() == 0)
- {
- throw new IllegalArgumentException();
- }
- if (methodParameters.containsKey(name))
- {
- throw new IllegalArgumentException();
- }
-
- //
- Description descriptionArgumentParameterAnnotation =
(Description)parameterAnnotationMap.get(Description.class);
- String description = descriptionArgumentParameterAnnotation != null ?
descriptionArgumentParameterAnnotation.description() : "";
- if (description.length() == 0)
- {
- description = "Method parameter " + name;
- }
-
- //
- methodParameters.put(name, new ArgumentTestParameter(name,
description));
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
-
- //
- String name = testMethodAnnotation.name();
- if (testMethodAnnotation.name().length() == 0)
- {
- name = method.getName();
- }
-
- //
- Description descriptionMethodAnnotation =
method.getAnnotation(Description.class);
- String description = descriptionMethodAnnotation != null ?
descriptionMethodAnnotation.description() : "";
- if (description.length() == 0)
- {
- description = "Test of method " + method.getName();
- }
-
- //
- Set<String> keywords = new HashSet<String>();
- Tag tagMethodAnnotation = method.getAnnotation(Tag.class);
- if (tagMethodAnnotation != null)
- {
- keywords.addAll(CollectionTools.set(tagMethodAnnotation.value()));
- }
-
- Map<String,TestParameter> parameters = new HashMap<String,
TestParameter>(suiteParameters);
- parameters.putAll(methodParameters);
-
- //
- TestCaseDef testCaseDef = new TestCaseDef(method, name, description,
parameters, methodParameters, keywords);
-
- //
- if (testCases.put(testCaseDef.getName(), testCaseDef) != null)
- {
- throw new IllegalArgumentException();
- }
- }
- }
-
- //
- this.suiteName = suiteName;
- this.suiteDescription = suiteDescription;
- this.suiteKeywords = suiteKeywords;
- this.suiteParameters = suiteParameters;
- this.testCases = testCases;
- this.ctor = ctor;
- this.create = create;
- this.destroy = destroy;
- }
-
- public TestSuiteDescriptor getDescriptor()
- {
- return this;
- }
-
- public TestLifeCycle getLifeCycle()
- {
- return this;
- }
-
- public String getName()
- {
- return suiteName;
- }
-
- public String getDescription()
- {
- return suiteDescription;
- }
-
- public Set<String> getKeywords()
- {
- return suiteKeywords;
- }
-
- public Map<String, ? extends ParameterDescriptor> getParameters()
- {
- return Collections.unmodifiableMap(suiteParameters);
- }
-
- public Map<String, ? extends TestCaseDescriptor> getTestCases()
- {
- return Collections.unmodifiableMap(testCases);
- }
-
- public TestCase newTestCase(String name) throws TestCaseLifeCycleException
- {
- TestCaseDef testCaseDef = testCases.get(name);
-
- //
- if (testCaseDef == null)
- {
- throw new TestCaseLifeCycleException("No such test case <" + name +
">");
- }
-
- //
- Object instance;
- try
- {
- instance = ctor.newInstance();
- }
- catch (InvocationTargetException e)
- {
- throw new TestCaseLifeCycleException("Cannot create test case " +
name, e.getCause());
- }
- catch (Exception e)
- {
- throw new TestCaseLifeCycleException("Cannot configure parameter " +
name, e);
- }
-
- //
- return new TestCaseImpl(testCaseDef, instance);
- }
-
- public void testCaseParametrize(TestCase _testCase, Map<String,String>
parametrization) throws TestCaseLifeCycleException
- {
- TestCaseImpl testCase = (TestCaseImpl)_testCase;
-
- // Save parametrization
- testCase.parametrization = parametrization;
-
- //
- for (PropertyTestParameter parameter : suiteParameters.values())
- {
- if (!parametrization.containsKey(parameter.getName()))
- {
- throw new TestCaseLifeCycleException("Missing parameter " +
parameter.getName());
- }
- String parameterValue = parametrization.get(parameter.getName());
- for (Method setter : parameter.setters)
- {
- try
- {
- setter.invoke(testCase.pojo, parameterValue);
- }
- catch (InvocationTargetException e)
- {
- throw new TestCaseLifeCycleException("Cannot configure parameter
" + parameter.getName(), e.getCause());
- }
- catch (Exception e)
- {
- throw new TestCaseLifeCycleException("Cannot configure parameter
" + parameter.getName(), e);
- }
- }
- }
- }
-
- public void testCaseCreate(TestCase _testCase) throws TestCaseLifeCycleException
- {
- TestCaseImpl testCase = (TestCaseImpl)_testCase;
-
- //
- if (create != null)
- {
- try
- {
- create.invoke(testCase.getPOJO());
- }
- catch (InvocationTargetException e)
- {
- throw new TestCaseLifeCycleException("Cannot create test case",
e.getCause());
- }
- catch (Exception e)
- {
- throw new TestCaseLifeCycleException("Cannot create test case",
e);
- }
- }
- }
-
- public void testCaseInvoke(TestCase _testCase) throws TestCaseLifeCycleException
- {
- TestCaseImpl testCase = (TestCaseImpl)_testCase;
-
- List<Object> argList = new ArrayList<Object>();
- for (String parameterName : testCase.def.arguments.keySet())
- {
- if (!testCase.parametrization.containsKey(parameterName))
- {
- throw new TestCaseLifeCycleException("Missing parameter " +
parameterName);
- }
- String parameterValue = testCase.parametrization.get(parameterName);
- if (parameterValue == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- argList.add(parameterValue);
- }
- Object[] args = argList.toArray();
-
- try
- {
- testCase.def.method.invoke(testCase.pojo, args);
- }
- catch (InvocationTargetException e)
- {
- throw new TestCaseLifeCycleException("Cannot invoke test case",
e.getCause());
- }
- catch (Exception e)
- {
- throw new TestCaseLifeCycleException("Cannot invoke test case", e);
- }
- }
-
- public void testCaseDestroy(TestCase _testCase)
- {
- TestCaseImpl testCase = (TestCaseImpl)_testCase;
-
- //
- if (destroy != null)
- {
- try
- {
- destroy.invoke(testCase.getPOJO());
- }
- catch (Throwable t)
- {
- // Log this as a warn
- // t.printStackTrace();
- }
- }
- }
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestLifeCycle.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestLifeCycle.java 2007-10-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestLifeCycle.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,75 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface TestLifeCycle
-{
-
- /**
- * Instantiate life cycle operation of a test case.
- *
- * @param name the test case name
- * @return the test case object
- * @throws TestCaseLifeCycleException
- */
- TestCase newTestCase(String name) throws TestCaseLifeCycleException;
-
- /**
- * Parametrize life cycle operation of a test case.
- *
- * @param testCase the test case
- * @param parametrization the parametrization
- * @throws TestCaseLifeCycleException
- */
- void testCaseParametrize(TestCase testCase, Map<String,String> parametrization)
throws TestCaseLifeCycleException;
-
- /**
- * Create life cycle operation of a test case.
- *
- * @param testCase the test case
- * @throws TestCaseLifeCycleException
- */
- void testCaseCreate(TestCase testCase) throws TestCaseLifeCycleException;
-
- /**
- * Invocation life cycle operation of a test case.
- *
- * @param testCase the test case
- * @throws TestCaseLifeCycleException
- */
- void testCaseInvoke(TestCase testCase) throws TestCaseLifeCycleException;
-
- /**
- * Destroy life cycle operation of a test case.
- *
- * @param testCase the test case
- */
- void testCaseDestroy(TestCase testCase);
-
-}
Deleted: 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-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,61 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.List;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class TestParameter implements ParameterDescriptor
-{
-
- /** . */
- private final String name;
-
- /** . */
- private final String description;
-
- public TestParameter(String name, String description)
- {
- this.name = name;
- this.description = description;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public List<String> getDefaultValues()
- {
- return Collections.emptyList();
- }
-}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestSuiteDescriptor.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestSuiteDescriptor.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestSuiteDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,70 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo;
-
-import java.util.Set;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface TestSuiteDescriptor
-{
-
- /**
- * Return the test name.
- *
- * @return the test name
- */
- String getName();
-
- /**
- * Return the test description.
- *
- * @return the test description
- */
- 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,? extends ParameterDescriptor> getParameters();
-
- /**
- * Return the test case descriptions.
- *
- * @return the test case descriptions
- */
- Map<String,? extends TestCaseDescriptor> getTestCases();
-
-}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Provider.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Provider.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Provider.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.api.pojo.annotations;
-
-import org.jboss.unit.api.pojo.TestHandler;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-@Inherited
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.ANNOTATION_TYPE,ElementType.TYPE})
-public @interface Provider
-{
- Class<? extends TestHandler> value();
-}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitDescriptor.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitDescriptor.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,14 +22,13 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.TestSuiteDescriptor;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
+import org.jboss.unit.spi.pojo.TestSuiteDescriptor;
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
-import java.util.Iterator;
import java.util.HashMap;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitLifeCycle.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitLifeCycle.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitLifeCycle.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.TestLifeCycle;
-import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.spi.pojo.TestLifeCycle;
+import org.jboss.unit.spi.pojo.TestCaseLifeCycleException;
import java.util.Map;
import java.lang.reflect.InvocationTargetException;
@@ -43,7 +43,7 @@
this.provider = testCase;
}
- public org.jboss.unit.api.pojo.TestCase newTestCase(String name) throws
TestCaseLifeCycleException
+ public org.jboss.unit.spi.pojo.TestCase newTestCase(String name) throws
TestCaseLifeCycleException
{
JUnitTestMethod method = provider.descriptor.testMap.get(name);
if (method == null)
@@ -66,12 +66,12 @@
}
}
- public void testCaseParametrize(org.jboss.unit.api.pojo.TestCase testCase,
Map<String, String> parametrization) throws TestCaseLifeCycleException
+ public void testCaseParametrize(org.jboss.unit.spi.pojo.TestCase testCase,
Map<String, String> parametrization) throws TestCaseLifeCycleException
{
// No op
}
- public void testCaseCreate(org.jboss.unit.api.pojo.TestCase testCase) throws
TestCaseLifeCycleException
+ public void testCaseCreate(org.jboss.unit.spi.pojo.TestCase testCase) throws
TestCaseLifeCycleException
{
try
{
@@ -84,7 +84,7 @@
}
}
- public void testCaseInvoke(org.jboss.unit.api.pojo.TestCase testCase) throws
TestCaseLifeCycleException
+ public void testCaseInvoke(org.jboss.unit.spi.pojo.TestCase testCase) throws
TestCaseLifeCycleException
{
JUnitTestMethodLifeCycle lifeCycle = (JUnitTestMethodLifeCycle)testCase;
@@ -118,7 +118,7 @@
return new TestCaseLifeCycleException(throwable);
}
- public void testCaseDestroy(org.jboss.unit.api.pojo.TestCase testCase)
+ public void testCaseDestroy(org.jboss.unit.spi.pojo.TestCase testCase)
{
try
{
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitProvider.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitProvider.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitProvider.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,10 +22,9 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.annotations.Provider;
-import org.jboss.unit.api.pojo.TestHandler;
-import org.jboss.unit.api.pojo.TestSuiteDescriptor;
-import org.jboss.unit.api.pojo.TestLifeCycle;
+import org.jboss.unit.spi.pojo.TestHandler;
+import org.jboss.unit.spi.pojo.TestSuiteDescriptor;
+import org.jboss.unit.spi.pojo.TestLifeCycle;
/**
* @todo
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethod.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethod.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethod.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
import java.util.Map;
import java.util.Set;
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethodLifeCycle.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethodLifeCycle.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestMethodLifeCycle.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-class JUnitTestMethodLifeCycle implements org.jboss.unit.api.pojo.TestCase
+class JUnitTestMethodLifeCycle implements org.jboss.unit.spi.pojo.TestCase
{
/** . */
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/TestCase.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/TestCase.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/TestCase.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.unit.api.pojo.junit;
-import org.jboss.unit.api.pojo.annotations.Provider;
+import org.jboss.unit.spi.pojo.annotations.Provider;
/**
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ArgumentTestParameter.java (from
rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ArgumentTestParameter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ArgumentTestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class ArgumentTestParameter extends TestParameter
+{
+ public ArgumentTestParameter(String name, String description)
+ {
+ super(name, description);
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/MethodKey.java (from rev
8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/MethodKey.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/MethodKey.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class MethodKey implements Comparable
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private List<String> types;
+
+ MethodKey(Method method)
+ {
+ List<String> types = new ArrayList<String>();
+ for (Class type : method.getParameterTypes())
+ {
+ types.add(type.getName());
+ }
+
+ this.name = method.getName();
+ this.types = types;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode() + types.hashCode();
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == this)
+ {
+ return true;
+ }
+ if (object instanceof MethodKey)
+ {
+ MethodKey that = (MethodKey)object;
+ return that.name.equals(this.name) && that.types.equals(this.types);
+ }
+ return false;
+ }
+
+ public int compareTo(Object o)
+ {
+ MethodKey that = (MethodKey)o;
+
+ //
+ int sign = name.compareTo(that.name);
+ if (sign != 0)
+ {
+ return sign;
+ }
+
+ //
+ for (int index = 0;index < this.types.size() && index <
that.types.size();index++)
+ {
+ String thisName = this.types.get(index);
+ String thatName = that.types.get(index);
+
+ //
+ int order = thisName.compareTo(thatName);
+ if (order != 0)
+ {
+ return order;
+ }
+ }
+
+ //
+ return that.types.size() - this.types.size();
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ParameterDescriptor.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ParameterDescriptor.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/ParameterDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -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.unit.spi.pojo;
+
+import java.util.List;
+
+/**
+ * An object describing a parameter.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ParameterDescriptor
+{
+
+ String getName();
+
+ String getDescription();
+
+ List<String> getDefaultValues();
+}
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/PropertyTestParameter.java (from
rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/PropertyTestParameter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/PropertyTestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class PropertyTestParameter extends TestParameter
+{
+
+ /** . */
+ final List<Method> setters = new ArrayList<Method>();
+
+ public PropertyTestParameter(String name, String description)
+ {
+ super(name, description);
+ }
+
+ void addSetter(Method setter)
+ {
+ setters.add(setter);
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCase.java (from rev
8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCase.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCase.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestCase
+{
+ Object getPOJO();
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDef.java (from
rev 8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDef.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDef.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.lang.reflect.Method;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestCaseDef implements TestCaseDescriptor
+{
+
+ /** . */
+ TestHandlerSupport driver;
+
+ /** . */
+ final Method method;
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String description;
+
+ /** . */
+ final LinkedHashMap<String,ArgumentTestParameter> arguments;
+
+ /** . */
+ final Map<String,TestParameter> 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()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public Map<String, ? extends ParameterDescriptor> getParameters()
+ {
+ return Collections.unmodifiableMap(parameters);
+ }
+
+ public Set<String> getKeywords()
+ {
+ return Collections.unmodifiableSet(keywords);
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDescriptor.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDescriptor.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -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.unit.spi.pojo;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestCaseDescriptor
+{
+
+ String getName();
+
+ String getDescription();
+
+ Map<String, ? extends ParameterDescriptor> getParameters();
+
+ Set<String> getKeywords();
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseImpl.java (from
rev 8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseImpl.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseImpl.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseImpl.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -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.unit.spi.pojo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestCaseImpl implements TestCase
+{
+
+ final TestCaseDef def;
+
+ /** . */
+ final Object pojo;
+
+ /** . */
+ Map<String,String> parametrization;
+
+ public TestCaseImpl(TestCaseDef def, Object pojo)
+ {
+ this.def = def;
+ this.pojo = pojo;
+ }
+
+ public Object getPOJO()
+ {
+ return pojo;
+ }
+}
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseLifeCycleException.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java)
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseLifeCycleException.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestCaseLifeCycleException.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestCaseLifeCycleException extends Exception
+{
+ public TestCaseLifeCycleException()
+ {
+ }
+
+ public TestCaseLifeCycleException(String string)
+ {
+ super(string);
+ }
+
+ public TestCaseLifeCycleException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public TestCaseLifeCycleException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandler.java (from
rev 8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandler.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandler.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+/**
+ * Allow a pojo class to take care of providing its description and perform test case
life cycle management.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestHandler
+{
+
+ TestSuiteDescriptor getDescriptor();
+
+ TestLifeCycle getLifeCycle();
+
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandlerSupport.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandlerSupport.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestHandlerSupport.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,597 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+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;
+import java.util.Map;
+import java.util.HashMap;
+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;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.annotation.Annotation;
+import java.beans.Introspector;
+
+/**
+ * Provide a default implementation that relies on the annotation defined in the
<code>annotations</code> package.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestHandlerSupport implements TestHandler, TestLifeCycle,
TestSuiteDescriptor
+{
+
+ /** . */
+ private final String suiteName;
+
+ /** . */
+ private final String suiteDescription;
+
+ /** . */
+ private final Map<String, TestCaseDef> testCases;
+
+ /** . */
+ private final Method create;
+
+ /** . */
+ private final Method destroy;
+
+ /** . */
+ final Map<String, PropertyTestParameter> suiteParameters;
+
+ /** . */
+ private final Constructor ctor;
+
+ /** . */
+ private final Set<String> suiteKeywords;
+
+ public TestHandlerSupport(Class testClass)
+ {
+ if (testClass == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (Modifier.isAbstract(testClass.getModifiers()))
+ {
+ throw new IllegalArgumentException("Test class is abstract");
+ }
+
+ // Check constructor
+ Constructor ctor;
+ try
+ {
+ ctor = testClass.getConstructor();
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+
+ //
+ Test testAnnotation = ((AnnotatedElement)testClass).getAnnotation(Test.class);
+ String suiteName = testAnnotation != null ? testAnnotation.name() : "";
+ if (suiteName.length() == 0)
+ {
+ suiteName = testClass.getName();
+ }
+
+ //
+ Description descriptionAnnotation =
((AnnotatedElement)testClass).getAnnotation(Description.class);
+ 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())
+ {
+ MethodKey key = new MethodKey(method);
+ methods.put(key, method);
+ }
+
+ //
+ 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)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (createMethodAnnotation != null && parameterMethodAnnotation !=
null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (createMethodAnnotation != null && testMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (destroyMethodAnnotation != null && parameterMethodAnnotation !=
null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (destroyMethodAnnotation != null && testMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (destroyMethodAnnotation != null && createMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (parameterMethodAnnotation != null)
+ {
+ if (!methodName.startsWith("set"))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (methodName.length() < 4)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getParameterTypes().length != 1)
+ {
+ 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();
+ }
+
+ //
+ String name = parameterMethodAnnotation.name();
+ if (name.length() == 0)
+ {
+ name = Introspector.decapitalize(method.getName().substring(3));
+ }
+
+ //
+ Description descriptionMethodAnnotation =
method.getAnnotation(Description.class);
+ String description = descriptionMethodAnnotation != null ?
descriptionMethodAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Parameter " + name;
+ }
+
+ //
+ PropertyTestParameter parameter = suiteParameters.get(name);
+ if (parameter == null)
+ {
+ parameter = new PropertyTestParameter(name, description);
+ suiteParameters.put(name, parameter);
+ }
+
+ //
+ parameter.addSetter(method);
+ }
+ 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();
+ }
+
+ //
+ 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>();
+ for (Annotation parameterAnnotation : parameterAnnotations)
+ {
+ Class<? extends Annotation> blah =
parameterAnnotation.annotationType();
+ parameterAnnotationMap.put(blah, parameterAnnotation);
+ }
+
+ //
+ Parameter argumentParameterAnnotation =
(Parameter)parameterAnnotationMap.get(Parameter.class);
+
+ //
+ if (argumentParameterAnnotation != null)
+ {
+ //
+ String name = argumentParameterAnnotation.name();
+ if (name.length() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (methodParameters.containsKey(name))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Description descriptionArgumentParameterAnnotation =
(Description)parameterAnnotationMap.get(Description.class);
+ String description = descriptionArgumentParameterAnnotation != null ?
descriptionArgumentParameterAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Method parameter " + name;
+ }
+
+ //
+ methodParameters.put(name, new ArgumentTestParameter(name,
description));
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ //
+ String name = testMethodAnnotation.name();
+ if (testMethodAnnotation.name().length() == 0)
+ {
+ name = method.getName();
+ }
+
+ //
+ Description descriptionMethodAnnotation =
method.getAnnotation(Description.class);
+ String description = descriptionMethodAnnotation != null ?
descriptionMethodAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Test of method " + method.getName();
+ }
+
+ //
+ Set<String> keywords = new HashSet<String>();
+ Tag tagMethodAnnotation = method.getAnnotation(Tag.class);
+ if (tagMethodAnnotation != null)
+ {
+ keywords.addAll(CollectionTools.set(tagMethodAnnotation.value()));
+ }
+
+ Map<String,TestParameter> parameters = new HashMap<String,
TestParameter>(suiteParameters);
+ parameters.putAll(methodParameters);
+
+ //
+ TestCaseDef testCaseDef = new TestCaseDef(method, name, description,
parameters, methodParameters, keywords);
+
+ //
+ if (testCases.put(testCaseDef.getName(), testCaseDef) != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ //
+ this.suiteName = suiteName;
+ this.suiteDescription = suiteDescription;
+ this.suiteKeywords = suiteKeywords;
+ this.suiteParameters = suiteParameters;
+ this.testCases = testCases;
+ this.ctor = ctor;
+ this.create = create;
+ this.destroy = destroy;
+ }
+
+ public TestSuiteDescriptor getDescriptor()
+ {
+ return this;
+ }
+
+ public TestLifeCycle getLifeCycle()
+ {
+ return this;
+ }
+
+ public String getName()
+ {
+ return suiteName;
+ }
+
+ public String getDescription()
+ {
+ return suiteDescription;
+ }
+
+ public Set<String> getKeywords()
+ {
+ return suiteKeywords;
+ }
+
+ public Map<String, ? extends ParameterDescriptor> getParameters()
+ {
+ return Collections.unmodifiableMap(suiteParameters);
+ }
+
+ public Map<String, ? extends TestCaseDescriptor> getTestCases()
+ {
+ return Collections.unmodifiableMap(testCases);
+ }
+
+ public TestCase newTestCase(String name) throws TestCaseLifeCycleException
+ {
+ TestCaseDef testCaseDef = testCases.get(name);
+
+ //
+ if (testCaseDef == null)
+ {
+ throw new TestCaseLifeCycleException("No such test case <" + name +
">");
+ }
+
+ //
+ Object instance;
+ try
+ {
+ instance = ctor.newInstance();
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case " +
name, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter " +
name, e);
+ }
+
+ //
+ return new TestCaseImpl(testCaseDef, instance);
+ }
+
+ public void testCaseParametrize(TestCase _testCase, Map<String,String>
parametrization) throws TestCaseLifeCycleException
+ {
+ TestCaseImpl testCase = (TestCaseImpl)_testCase;
+
+ // Save parametrization
+ testCase.parametrization = parametrization;
+
+ //
+ for (PropertyTestParameter parameter : suiteParameters.values())
+ {
+ if (!parametrization.containsKey(parameter.getName()))
+ {
+ throw new TestCaseLifeCycleException("Missing parameter " +
parameter.getName());
+ }
+ String parameterValue = parametrization.get(parameter.getName());
+ for (Method setter : parameter.setters)
+ {
+ try
+ {
+ setter.invoke(testCase.pojo, parameterValue);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter
" + parameter.getName(), e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter
" + parameter.getName(), e);
+ }
+ }
+ }
+ }
+
+ public void testCaseCreate(TestCase _testCase) throws TestCaseLifeCycleException
+ {
+ TestCaseImpl testCase = (TestCaseImpl)_testCase;
+
+ //
+ if (create != null)
+ {
+ try
+ {
+ create.invoke(testCase.getPOJO());
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case",
e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case",
e);
+ }
+ }
+ }
+
+ public void testCaseInvoke(TestCase _testCase) throws TestCaseLifeCycleException
+ {
+ TestCaseImpl testCase = (TestCaseImpl)_testCase;
+
+ List<Object> argList = new ArrayList<Object>();
+ for (String parameterName : testCase.def.arguments.keySet())
+ {
+ if (!testCase.parametrization.containsKey(parameterName))
+ {
+ throw new TestCaseLifeCycleException("Missing parameter " +
parameterName);
+ }
+ String parameterValue = testCase.parametrization.get(parameterName);
+ if (parameterValue == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ argList.add(parameterValue);
+ }
+ Object[] args = argList.toArray();
+
+ try
+ {
+ testCase.def.method.invoke(testCase.pojo, args);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot invoke test case",
e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot invoke test case", e);
+ }
+ }
+
+ public void testCaseDestroy(TestCase _testCase)
+ {
+ TestCaseImpl testCase = (TestCaseImpl)_testCase;
+
+ //
+ if (destroy != null)
+ {
+ try
+ {
+ destroy.invoke(testCase.getPOJO());
+ }
+ catch (Throwable t)
+ {
+ // Log this as a warn
+ // t.printStackTrace();
+ }
+ }
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestLifeCycle.java (from
rev 8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestLifeCycle.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestLifeCycle.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestLifeCycle.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestLifeCycle
+{
+
+ /**
+ * Instantiate life cycle operation of a test case.
+ *
+ * @param name the test case name
+ * @return the test case object
+ * @throws TestCaseLifeCycleException
+ */
+ TestCase newTestCase(String name) throws TestCaseLifeCycleException;
+
+ /**
+ * Parametrize life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @param parametrization the parametrization
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseParametrize(TestCase testCase, Map<String,String> parametrization)
throws TestCaseLifeCycleException;
+
+ /**
+ * Create life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseCreate(TestCase testCase) throws TestCaseLifeCycleException;
+
+ /**
+ * Invocation life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseInvoke(TestCase testCase) throws TestCaseLifeCycleException;
+
+ /**
+ * Destroy life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ */
+ void testCaseDestroy(TestCase testCase);
+
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestParameter.java (from
rev 8535, modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestParameter.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestParameter.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestParameter implements ParameterDescriptor
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String description;
+
+ public TestParameter(String name, String description)
+ {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public List<String> getDefaultValues()
+ {
+ return Collections.emptyList();
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestSuiteDescriptor.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestSuiteDescriptor.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestSuiteDescriptor.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestSuiteDescriptor.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestSuiteDescriptor
+{
+
+ /**
+ * Return the test name.
+ *
+ * @return the test name
+ */
+ String getName();
+
+ /**
+ * Return the test description.
+ *
+ * @return the test description
+ */
+ 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,? extends ParameterDescriptor> getParameters();
+
+ /**
+ * Return the test case descriptions.
+ *
+ * @return the test case descriptions
+ */
+ Map<String,? extends TestCaseDescriptor> getTestCases();
+
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/annotations/Provider.java
(from rev 8535,
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Provider.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/annotations/Provider.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/annotations/Provider.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.spi.pojo.annotations;
+
+import org.jboss.unit.spi.pojo.TestHandler;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Inherited
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.ANNOTATION_TYPE,ElementType.TYPE})
+public @interface Provider
+{
+ Class<? extends TestHandler> value();
+}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.unit.unit.pojo;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
import org.jboss.unit.info.ParameterInfo;
import java.util.List;
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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.unit.unit.pojo;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
import org.jboss.unit.info.TestCaseInfo;
/**
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-04
22:24:45 UTC (rev 8535)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -24,11 +24,10 @@
import org.jboss.unit.info.ParameterInfo;
import org.jboss.unit.info.TestInfo;
-import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
import java.util.Map;
import java.util.Set;
-import java.util.Collections;
import java.util.HashMap;
/**
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java 2007-10-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,12 +22,12 @@
******************************************************************************/
package org.jboss.unit.unit.pojo;
-import org.jboss.unit.api.pojo.TestHandler;
-import org.jboss.unit.api.pojo.TestHandlerSupport;
-import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
-import org.jboss.unit.api.pojo.TestLifeCycle;
-import org.jboss.unit.api.pojo.TestCase;
-import org.jboss.unit.api.pojo.annotations.Provider;
+import org.jboss.unit.spi.pojo.TestHandler;
+import org.jboss.unit.spi.pojo.TestHandlerSupport;
+import org.jboss.unit.spi.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.spi.pojo.TestLifeCycle;
+import org.jboss.unit.spi.pojo.TestCase;
+import org.jboss.unit.spi.pojo.annotations.Provider;
import org.jboss.unit.driver.TestDriver;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
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-04
22:24:45 UTC (rev 8535)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java 2007-10-04
22:40:54 UTC (rev 8536)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.unit.unit.pojo;
-import org.jboss.unit.api.pojo.TestCaseDescriptor;
-import org.jboss.unit.api.pojo.TestSuiteDescriptor;
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
+import org.jboss.unit.spi.pojo.TestSuiteDescriptor;
import org.jboss.unit.info.TestSuiteInfo;
import org.jboss.unit.info.TestInfo;
import org.jboss.unit.TestId;