0 Replies Latest reply on Jun 24, 2010 10:41 AM by Thomas Diesler

    Adding testClass abstraction

    Thomas Diesler Master

      Related to https://jira.jboss.org/browse/ARQ-193

       

      I propose adding a TestClass abstraction like this

       

      /**
       * Wraps a class to be run, providing method validation and annotation searching.
       * 
       * @author thomas.diesler@jboss.com
       * @version $Revision: $
       */
      public class TestClass
      {
         private Class<?> testClass;
      
         public TestClass(Class<?> testClass)
         {
            if (testClass == null)
               throw new IllegalArgumentException("Null testClass");
      
      
            this.testClass = testClass;
         }
      
         public Class<?> getJavaClass()
         {
            return testClass;
         }
      
         public String getName()
         {
            return testClass.getName();
         }
      
         public boolean isAnnotationPresent(Class<? extends Annotation> annotation)
         {
            return testClass.isAnnotationPresent(annotation);
         }
         
         public <A extends Annotation> A getAnnotation(Class<A> annotation)
         {
            return testClass.getAnnotation(annotation);
         }
         
         public Method findDeploymentMethod() 
         {
            Method[] methods = testClass.getMethods();
            for(Method method: methods)
            {
               if(method.isAnnotationPresent(Deployment.class)) 
               {
                  return method;
               }
            }
            return null;
         }
      }
      

       

      This allows the test class to be attached to the context and generally provides better encapsulation of the test class notion.

       

      The commit is on the arq193 branch

       

      http://github.com/jbosgi/arquillian/commit/d41efbafe5c11e44c738b46c59798b49f1cce59a