[webbeans-commits] Webbeans SVN: r861 - in tck/trunk: api/src/main/java/org/jboss/webbeans/tck/api and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Jan 9 11:13:20 EST 2009


Author: pete.muir at jboss.org
Date: 2009-01-09 11:13:20 -0500 (Fri, 09 Jan 2009)
New Revision: 861

Added:
   tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java
   tck/trunk/impl/src/main/resources/unit-tests.xml
Removed:
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/testng.xml
Modified:
   tck/trunk/api/pom.xml
   tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/WebBeansTCK.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java
Log:
TCK run infrastructure

Modified: tck/trunk/api/pom.xml
===================================================================
--- tck/trunk/api/pom.xml	2009-01-09 14:41:48 UTC (rev 860)
+++ tck/trunk/api/pom.xml	2009-01-09 16:13:20 UTC (rev 861)
@@ -43,5 +43,23 @@
 
    </dependencies>
 
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-jar-plugin</artifactId>
+            <version>2.2</version>
+            <configuration>
+               <archive>
+                  <manifest>
+                     <mainClass>org.jboss.webbeans.tck.api.WebBeansTCK</mainClass>
+                  </manifest>
+               </archive>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
 
+
+
 </project>

Added: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java	                        (rev 0)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java	2009-01-09 16:13:20 UTC (rev 861)
@@ -0,0 +1,35 @@
+package org.jboss.webbeans.tck.api;
+
+public class TCKConfiguration
+{
+   
+   private Beans beans;
+   
+   private Contexts<?> contexts;
+   
+   private Managers managers;
+
+   public TCKConfiguration(Beans beans, Contexts<?> contexts, Managers managers)
+   {
+      super();
+      this.beans = beans;
+      this.contexts = contexts;
+      this.managers = managers;
+   }
+
+   public Beans getBeans()
+   {
+      return beans;
+   }
+
+   public Contexts<?> getContexts()
+   {
+      return contexts;
+   }
+
+   public Managers getManagers()
+   {
+      return managers;
+   }
+   
+}


Property changes on: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/WebBeansTCK.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/WebBeansTCK.java	2009-01-09 14:41:48 UTC (rev 860)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/WebBeansTCK.java	2009-01-09 16:13:20 UTC (rev 861)
@@ -1,10 +1,25 @@
 package org.jboss.webbeans.tck.api;
 
 
+/**
+ * TCK runner
+ * 
+ * @author Pete Muir
+ *
+ */
 public abstract class WebBeansTCK
 {
    
-   public static final void run()
+   /**
+    * Obtain an instance of the TCK
+    * 
+    * @param configuration
+    *           the TCK configuration; if null, the TCK should try to load
+    *           configuration from system properties and
+    *           web-beans-tck.properties
+    * @return
+    */
+   public static final WebBeansTCK newInstance(TCKConfiguration configuration)
    {
       WebBeansTCK webBeansTCK;
       try
@@ -13,30 +28,47 @@
       }
       catch (InstantiationException e)
       {
-         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath");
+         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath", e);
       }
       catch (IllegalAccessException e)
       {
-         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath");
+         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath", e);
       }
       catch (ClassNotFoundException e)
       {
-         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath");
+         throw new IllegalStateException("WebBeansTCK cannot be run unless webbeans-tck-impl.jar is on the classpath", e);
       }
-      
-      // Run the TCK testsuite
-      webBeansTCK.runUnitTests();
+      webBeansTCK.configure(configuration);      
+      return webBeansTCK;
    }
    
+   /**
+    * Run the whole TCK
+    */
+   public final void run()
+   {            
+      // Load Configuration and run
+      runUnitTests();
+   }
+   
    public static void main(String[] args)
    {
-      run();
+      newInstance(null).run();
    }
    
    protected WebBeansTCK()
    {
    }
    
-   public abstract void runUnitTests();
+   protected abstract void runUnitTests();
    
+   /**
+    * Configure the TCK
+    * 
+    * @param configuration if null, the TCK should try to load
+    *           configuration from system properties and
+    *           web-beans-tck.properties
+    */
+   protected abstract void configure(TCKConfiguration configuration);
+   
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java	2009-01-09 14:41:48 UTC (rev 860)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java	2009-01-09 16:13:20 UTC (rev 861)
@@ -1,14 +1,24 @@
 package org.jboss.webbeans.tck.impl;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.webbeans.tck.api.TCKConfiguration;
 import org.jboss.webbeans.tck.api.WebBeansTCK;
 import org.testng.TestNG;
+import org.testng.xml.Parser;
+import org.testng.xml.XmlSuite;
+import org.xml.sax.SAXException;
 
 public class WebBeansTCKImpl extends WebBeansTCK
 {
    
+   private TCKConfiguration configuration;
+   
    public WebBeansTCKImpl()
    {
       super();
@@ -18,10 +28,50 @@
    public void runUnitTests()
    {
       TestNG testNG = new TestNG();
-      List<String> suites = new ArrayList<String>();
-      suites.add("testng.xml");
-      testNG.setTestSuites(suites);
+      setXmlSuitePath(testNG);
       testNG.run();
    }
    
+   private static void setXmlSuitePath(TestNG testNG)
+   {
+      InputStream is = WebBeansTCKImpl.class.getResourceAsStream("/unit-tests.xml");
+      if (is == null)
+      {
+         throw new IllegalStateException("Unable to load testng.xml");
+      }
+      List<XmlSuite> suites = new ArrayList<XmlSuite>();
+      try
+      {
+         suites.addAll(new Parser(is).parse());
+         
+      }
+      catch (ParserConfigurationException e)
+      {
+         throw new IllegalStateException("Unable to load testng.xml", e);
+      }
+      catch (SAXException e)
+      {
+         throw new IllegalStateException("Unable to load testng.xml", e);
+      }
+      catch (IOException e)
+      {
+         throw new IllegalStateException("Unable to load testng.xml", e);
+      }
+      testNG.setXmlSuites(suites);
+   }
+
+   @Override
+   protected void configure(TCKConfiguration configuration)
+   {
+      if (configuration == null)
+      {
+         // TODO load configuration from properties
+      }
+      else
+      {
+         this.configuration = configuration;
+      }
+   }
+
+   
 }

Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/testng.xml
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/testng.xml	2009-01-09 14:41:48 UTC (rev 860)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/testng.xml	2009-01-09 16:13:20 UTC (rev 861)
@@ -1,40 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="WebBeans TCK" verbose="1"  >
-
-   <test name="Web Beans TCK">
-      <groups>
-         <run>
-<!--          
-            <exclude name="specialization" />
-            <exclude name="deployment" />
-            <exclude name="disposalMethod" />
-            
-            <exclude name="observerMethod" />
-            <exclude name="deferredEvent" />
-            <exclude name="ejb3" />
-            <exclude name="webservice" />
-            <exclude name="annotationDefinition" />
-            <exclude name="webbeansxml" />
-            <exclude name="el" />
-            <exclude name="jms" />
-            <exclude name="interceptors" />
-            <exclude name="decorators" />
-            <exclude name="servlet" />
-            
-            <exclude name="passivation" />
-            <exclude name="singletons" />
-            <exclude name="ejbjarxml" />
-            <exclude name="beanDestruction" />
-            <exclude name="commonAnnotations" />
--->
-            <exclude name="stub" />
-            <exclude name="broken" />
-         </run>
-      </groups>
-      <packages>
-         <package name="org.jboss.webbeans.tck.impl" />
-      </packages>
-   </test>
-   
-</suite>
\ No newline at end of file

Copied: tck/trunk/impl/src/main/resources/unit-tests.xml (from rev 860, tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/testng.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/unit-tests.xml	                        (rev 0)
+++ tck/trunk/impl/src/main/resources/unit-tests.xml	2009-01-09 16:13:20 UTC (rev 861)
@@ -0,0 +1,40 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="WebBeans TCK" verbose="3"  >
+
+   <test name="Web Beans TCK" >
+      <groups >
+         <run>
+<!--          
+            <exclude name="specialization" />
+            <exclude name="deployment" />
+            <exclude name="disposalMethod" />
+            
+            <exclude name="observerMethod" />
+            <exclude name="deferredEvent" />
+            <exclude name="ejb3" />
+            <exclude name="webservice" />
+            <exclude name="annotationDefinition" />
+            <exclude name="webbeansxml" />
+            <exclude name="el" />
+            <exclude name="jms" />
+            <exclude name="interceptors" />
+            <exclude name="decorators" />
+            <exclude name="servlet" />
+            
+            <exclude name="passivation" />
+            <exclude name="singletons" />
+            <exclude name="ejbjarxml" />
+            <exclude name="beanDestruction" />
+            <exclude name="commonAnnotations" />
+-->
+            <exclude name="stub" />
+            <exclude name="broken" />
+         </run>
+      </groups>
+      <packages >
+         <package name="org.jboss.webbeans.tck.impl" />
+      </packages>
+   </test>
+   
+</suite>
\ No newline at end of file




More information about the weld-commits mailing list