Author: julien(a)jboss.com
Date: 2007-10-05 15:39:43 -0400 (Fri, 05 Oct 2007)
New Revision: 8549
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOParameterInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteInfo.java
Removed:
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
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/junit/JUnitPOJOTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
Log:
renamed org.jboss.unit.unit.pojo -> org.jboss.unit.driver.impl.pojo
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java 2007-10-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestDriverPOJOTests.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -23,7 +23,7 @@
package org.jboss.test.unit.pojo;
import org.jboss.unit.driver.TestDriver;
-import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
import static org.jboss.unit.api.Assert.*;
/**
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/junit/JUnitPOJOTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/junit/JUnitPOJOTests.java 2007-10-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/junit/JUnitPOJOTests.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.test.unit.pojo.junit;
-import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
import static org.jboss.unit.util.CollectionTools.*;
import static org.jboss.unit.api.Assert.*;
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOParameterInfo.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOParameterInfo.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOParameterInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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.driver.impl.pojo;
+
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
+import org.jboss.unit.info.ParameterInfo;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOParameterInfo implements ParameterInfo
+{
+
+ /** . */
+ private final ParameterDescriptor descriptor;
+
+ public POJOParameterInfo(ParameterDescriptor descriptor)
+ {
+ this.descriptor = descriptor;
+ }
+
+ public String getName()
+ {
+ return descriptor.getName();
+ }
+
+ public String getDescription()
+ {
+ return descriptor.getDescription();
+ }
+
+ public List<String> getDefaultValues()
+ {
+ return descriptor.getDefaultValues();
+ }
+}
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestCaseInfo.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestCaseInfo.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestCaseInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.driver.impl.pojo;
+
+import org.jboss.unit.spi.pojo.TestCaseDescriptor;
+import org.jboss.unit.info.TestCaseInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestCaseInfo extends POJOTestInfo implements TestCaseInfo
+{
+
+ /** . */
+ private TestCaseDescriptor descriptor;
+
+ public POJOTestCaseInfo(TestCaseDescriptor descriptor)
+ {
+ super(descriptor.getParameters(), descriptor.getKeywords());
+
+ //
+ this.descriptor = descriptor;
+ }
+
+ public String getName()
+ {
+ return descriptor.getName();
+ }
+
+ public String getDescription()
+ {
+ return descriptor.getDescription();
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestInfo.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.driver.impl.pojo;
+
+import org.jboss.unit.info.ParameterInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.spi.pojo.ParameterDescriptor;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class POJOTestInfo implements TestInfo
+{
+
+ /** . */
+ private Map<String,POJOParameterInfo> parameters;
+
+ /** . */
+ private Set<String> keywords;
+
+ public POJOTestInfo(Map<String,? extends ParameterDescriptor>
parameterDescriptors, Set<String> keywords)
+ {
+ Map<String, POJOParameterInfo> parameters = new HashMap<String,
POJOParameterInfo>();
+ for (ParameterDescriptor parameterDescriptor : parameterDescriptors.values())
+ {
+ POJOParameterInfo parameterInfo = new POJOParameterInfo(parameterDescriptor);
+ parameters.put(parameterInfo.getName(), parameterInfo);
+ }
+
+ //
+ this.parameters = parameters;
+ this.keywords = keywords;
+ }
+
+ public Map<String, ? extends ParameterInfo> getParameters()
+ {
+ return parameters;
+ }
+
+ public Set<String> getKeywords()
+ {
+ return keywords;
+ }
+}
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * 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.driver.impl.pojo;
+
+import org.jboss.unit.spi.pojo.TestProvider;
+import org.jboss.unit.spi.pojo.TestProviderSupport;
+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;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.TestId;
+import org.jboss.unit.Failure;
+
+import java.util.Map;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.annotation.Annotation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestSuiteDriver implements TestDriver
+{
+
+ /** . */
+ private TestProvider provider;
+
+ /** . */
+ private TestSuiteInfo info;
+
+ public POJOTestSuiteDriver(Class testClass) throws InstantiationException,
IllegalAccessException
+ {
+ // Get provider annotation
+ Provider provider = ((AnnotatedElement)testClass).getAnnotation(Provider.class);
+
+ // Scan meta annotations
+ if (provider == null)
+ {
+ for (Annotation annotation : testClass.getAnnotations())
+ {
+ Class blah = annotation.annotationType();
+ provider = ((AnnotatedElement)blah).getAnnotation(Provider.class);
+ if (provider != null)
+ {
+ break;
+ }
+ }
+ }
+
+ if (provider != null)
+ {
+ try
+ {
+ Class<? extends TestProvider> providerClass = provider.value();
+ Constructor<? extends TestProvider> providerCtor =
providerClass.getConstructor(Class.class);
+ this.provider = providerCtor.newInstance(testClass);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+// else if (TestHandler.class.isAssignableFrom(testClass))
+// {
+// handler = (TestHandler)testClass.newInstance();
+// }
+ else
+ {
+ this.provider = new TestProviderSupport(testClass);
+ }
+
+ //
+ info = new POJOTestSuiteInfo(this.provider.getDescriptor());
+ }
+
+ public TestInfo getInfo()
+ {
+ return info;
+ }
+
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ if (command instanceof StartTestCommand)
+ {
+ StartTestCommand start = (StartTestCommand)command;
+
+ //
+ if (id.getLength() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ TestLifeCycle lifeCycle = provider.getLifeCycle();
+
+ //
+ String name = id.getName(0);
+
+ //
+ TestCase testCase;
+ try
+ {
+ testCase = lifeCycle.newTestCase(name);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+
+ //
+ Map<String,String> parametrization = start.getParametrization();
+
+ //
+ try
+ {
+ lifeCycle.testCaseParametrize(testCase, parametrization);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+
+ //
+ try
+ {
+ lifeCycle.testCaseCreate(testCase);
+
+ //
+ lifeCycle.testCaseInvoke(testCase);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+ finally
+ {
+ lifeCycle.testCaseDestroy(testCase);
+ }
+
+ //
+ return new EndTestResponse();
+ }
+ else
+ {
+ throw new IllegalArgumentException(); // convert to response style
+ }
+ }
+
+ private DriverResponse createResponse(Throwable t)
+ {
+ if (t instanceof TestCaseLifeCycleException)
+ {
+ if (t.getCause() != null)
+ {
+ t = t.getCause();
+ }
+ }
+
+ //
+ if (t instanceof AssertionError)
+ {
+ return new FailureResponse(Failure.createAssertionFailure((AssertionError)t));
+ }
+ else
+ {
+ return new FailureResponse(Failure.createErrorFailure(t));
+ }
+ }
+}
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteInfo.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteInfo.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.driver.impl.pojo;
+
+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;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestSuiteInfo extends POJOTestInfo implements TestSuiteInfo
+{
+
+ /** . */
+ private TestSuiteDescriptor descriptor;
+
+ /** . */
+ private Map<String,POJOTestCaseInfo> testCases;
+
+ public POJOTestSuiteInfo(TestSuiteDescriptor descriptor)
+ {
+ super(descriptor.getParameters(), descriptor.getKeywords());
+
+ //
+ HashMap<String, POJOTestCaseInfo> testCases = new HashMap<String,
POJOTestCaseInfo>();
+ for (TestCaseDescriptor testCaseDescriptor : descriptor.getTestCases().values())
+ {
+ POJOTestCaseInfo testCase = new POJOTestCaseInfo(testCaseDescriptor);
+ testCases.put(testCase.getName(), testCase);
+ }
+
+ //
+ this.descriptor = descriptor;
+ this.testCases = testCases;
+ }
+
+ public String getName()
+ {
+ return descriptor.getName();
+ }
+
+ public String getDescription()
+ {
+ return descriptor.getDescription();
+ }
+
+ public TestInfo getTest(String name)
+ {
+ return testCases.get(name);
+ }
+
+ public Set<String> getNames()
+ {
+ return testCases.keySet();
+ }
+
+ public TestInfo findTest(TestId id)
+ {
+ switch(id.getLength())
+ {
+ case 0:
+ return this;
+ case 1:
+ return getTest(id.getName(0));
+ default:
+ return null;
+ }
+ }
+}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -33,18 +33,16 @@
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
import org.jboss.unit.runner.model.TestDef;
-import org.jboss.unit.FailureType;
import org.jboss.unit.TestId;
import org.jboss.unit.Failure;
import org.jboss.unit.info.TestSuiteInfo;
import org.jboss.unit.info.TestCaseInfo;
-import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
import org.jboss.unit.driver.TestDriver;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
-import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Deleted: 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-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -1,59 +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.unit.pojo;
-
-import org.jboss.unit.spi.pojo.ParameterDescriptor;
-import org.jboss.unit.info.ParameterInfo;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class POJOParameterInfo implements ParameterInfo
-{
-
- /** . */
- private final ParameterDescriptor descriptor;
-
- public POJOParameterInfo(ParameterDescriptor descriptor)
- {
- this.descriptor = descriptor;
- }
-
- public String getName()
- {
- return descriptor.getName();
- }
-
- public String getDescription()
- {
- return descriptor.getDescription();
- }
-
- public List<String> getDefaultValues()
- {
- return descriptor.getDefaultValues();
- }
-}
Deleted: 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-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -1,56 +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.unit.pojo;
-
-import org.jboss.unit.spi.pojo.TestCaseDescriptor;
-import org.jboss.unit.info.TestCaseInfo;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class POJOTestCaseInfo extends POJOTestInfo implements TestCaseInfo
-{
-
- /** . */
- private TestCaseDescriptor descriptor;
-
- public POJOTestCaseInfo(TestCaseDescriptor descriptor)
- {
- super(descriptor.getParameters(), descriptor.getKeywords());
-
- //
- this.descriptor = descriptor;
- }
-
- public String getName()
- {
- return descriptor.getName();
- }
-
- public String getDescription()
- {
- return descriptor.getDescription();
- }
-
-}
Deleted: 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-05
16:38:43 UTC (rev 8548)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -1,69 +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.unit.pojo;
-
-import org.jboss.unit.info.ParameterInfo;
-import org.jboss.unit.info.TestInfo;
-import org.jboss.unit.spi.pojo.ParameterDescriptor;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class POJOTestInfo implements TestInfo
-{
-
- /** . */
- private Map<String,POJOParameterInfo> parameters;
-
- /** . */
- private Set<String> keywords;
-
- public POJOTestInfo(Map<String,? extends ParameterDescriptor>
parameterDescriptors, Set<String> keywords)
- {
- Map<String, POJOParameterInfo> parameters = new HashMap<String,
POJOParameterInfo>();
- for (ParameterDescriptor parameterDescriptor : parameterDescriptors.values())
- {
- POJOParameterInfo parameterInfo = new POJOParameterInfo(parameterDescriptor);
- parameters.put(parameterInfo.getName(), parameterInfo);
- }
-
- //
- this.parameters = parameters;
- this.keywords = keywords;
- }
-
- public Map<String, ? extends ParameterInfo> getParameters()
- {
- return parameters;
- }
-
- public Set<String> getKeywords()
- {
- return keywords;
- }
-}
Deleted:
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-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -1,203 +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.unit.pojo;
-
-import org.jboss.unit.spi.pojo.TestProvider;
-import org.jboss.unit.spi.pojo.TestProviderSupport;
-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;
-import org.jboss.unit.driver.response.EndTestResponse;
-import org.jboss.unit.driver.response.FailureResponse;
-import org.jboss.unit.driver.command.StartTestCommand;
-import org.jboss.unit.info.TestInfo;
-import org.jboss.unit.info.TestSuiteInfo;
-import org.jboss.unit.TestId;
-import org.jboss.unit.Failure;
-
-import java.util.Map;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.annotation.Annotation;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class POJOTestSuiteDriver implements TestDriver
-{
-
- /** . */
- private TestProvider provider;
-
- /** . */
- private TestSuiteInfo info;
-
- public POJOTestSuiteDriver(Class testClass) throws InstantiationException,
IllegalAccessException
- {
- // Get provider annotation
- Provider provider = ((AnnotatedElement)testClass).getAnnotation(Provider.class);
-
- // Scan meta annotations
- if (provider == null)
- {
- for (Annotation annotation : testClass.getAnnotations())
- {
- Class blah = annotation.annotationType();
- provider = ((AnnotatedElement)blah).getAnnotation(Provider.class);
- if (provider != null)
- {
- break;
- }
- }
- }
-
- if (provider != null)
- {
- try
- {
- Class<? extends TestProvider> providerClass = provider.value();
- Constructor<? extends TestProvider> providerCtor =
providerClass.getConstructor(Class.class);
- this.provider = providerCtor.newInstance(testClass);
- }
- catch (NoSuchMethodException e)
- {
- throw new IllegalArgumentException(e);
- }
- catch (InvocationTargetException e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-// else if (TestHandler.class.isAssignableFrom(testClass))
-// {
-// handler = (TestHandler)testClass.newInstance();
-// }
- else
- {
- this.provider = new TestProviderSupport(testClass);
- }
-
- //
- info = new POJOTestSuiteInfo(this.provider.getDescriptor());
- }
-
- public TestInfo getInfo()
- {
- return info;
- }
-
- public DriverResponse invoke(TestId id, DriverCommand command)
- {
- if (command instanceof StartTestCommand)
- {
- StartTestCommand start = (StartTestCommand)command;
-
- //
- if (id.getLength() == 0)
- {
- throw new IllegalArgumentException();
- }
-
- //
- TestLifeCycle lifeCycle = provider.getLifeCycle();
-
- //
- String name = id.getName(0);
-
- //
- TestCase testCase;
- try
- {
- testCase = lifeCycle.newTestCase(name);
- }
- catch (Exception e)
- {
- return createResponse(e);
- }
-
- //
- Map<String,String> parametrization = start.getParametrization();
-
- //
- try
- {
- lifeCycle.testCaseParametrize(testCase, parametrization);
- }
- catch (Exception e)
- {
- return createResponse(e);
- }
-
- //
- try
- {
- lifeCycle.testCaseCreate(testCase);
-
- //
- lifeCycle.testCaseInvoke(testCase);
- }
- catch (Exception e)
- {
- return createResponse(e);
- }
- finally
- {
- lifeCycle.testCaseDestroy(testCase);
- }
-
- //
- return new EndTestResponse();
- }
- else
- {
- throw new IllegalArgumentException(); // convert to response style
- }
- }
-
- private DriverResponse createResponse(Throwable t)
- {
- if (t instanceof TestCaseLifeCycleException)
- {
- if (t.getCause() != null)
- {
- t = t.getCause();
- }
- }
-
- //
- if (t instanceof AssertionError)
- {
- return new FailureResponse(Failure.createAssertionFailure((AssertionError)t));
- }
- else
- {
- return new FailureResponse(Failure.createErrorFailure(t));
- }
- }
-}
Deleted: 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-05
16:38:43 UTC (rev 8548)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java 2007-10-05
19:39:43 UTC (rev 8549)
@@ -1,97 +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.unit.pojo;
-
-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;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class POJOTestSuiteInfo extends POJOTestInfo implements TestSuiteInfo
-{
-
- /** . */
- private TestSuiteDescriptor descriptor;
-
- /** . */
- private Map<String,POJOTestCaseInfo> testCases;
-
- public POJOTestSuiteInfo(TestSuiteDescriptor descriptor)
- {
- super(descriptor.getParameters(), descriptor.getKeywords());
-
- //
- HashMap<String, POJOTestCaseInfo> testCases = new HashMap<String,
POJOTestCaseInfo>();
- for (TestCaseDescriptor testCaseDescriptor : descriptor.getTestCases().values())
- {
- POJOTestCaseInfo testCase = new POJOTestCaseInfo(testCaseDescriptor);
- testCases.put(testCase.getName(), testCase);
- }
-
- //
- this.descriptor = descriptor;
- this.testCases = testCases;
- }
-
- public String getName()
- {
- return descriptor.getName();
- }
-
- public String getDescription()
- {
- return descriptor.getDescription();
- }
-
- public TestInfo getTest(String name)
- {
- return testCases.get(name);
- }
-
- public Set<String> getNames()
- {
- return testCases.keySet();
- }
-
- public TestInfo findTest(TestId id)
- {
- switch(id.getLength())
- {
- case 0:
- return this;
- case 1:
- return getTest(id.getName(0));
- default:
- return null;
- }
- }
-}