[jboss-cvs] JBossAS SVN: r80347 - in trunk/testsuite: src/main/org/jboss/test/compatibility/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 2 09:13:58 EST 2008


Author: rrajesh
Date: 2008-11-02 09:13:57 -0500 (Sun, 02 Nov 2008)
New Revision: 80347

Added:
   trunk/testsuite/src/main/org/jboss/test/compatibility/test/matrix/
   trunk/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java
Modified:
   trunk/testsuite/build.xml
Log:
JBAS-5873 Adding compatibility matrix to the testsuite build

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2008-11-02 12:28:01 UTC (rev 80346)
+++ trunk/testsuite/build.xml	2008-11-02 14:13:57 UTC (rev 80347)
@@ -622,7 +622,7 @@
             <available file="server.log">
                <filepath>
                   <fileset dir="${jboss.dist}/server/@{conf}/log/" includes="server.log">
-                     <contains text="[org.jboss.system.server.Server] Shutdown complete"/>
+                     <contains text="[org.jboss.bootstrap.microcontainer.ServerImpl] (JBoss Shutdown Hook) Shutdown complete"/>
                   </fileset>
                </filepath>
             </available>
@@ -3514,7 +3514,7 @@
  
      <fail message="Use -Dmatrix-versions=[version container] for this task" unless="matrix-versions"/>
      <fail message="Set -Djdk15= to a JDK1.5 installation" unless="HAVE_JDK_1.5"/>
-     <fail message="Set -Djdk15= to a JDK1.6 installation" unless="HAVE_JDK_1.6"/>
+    <!-- <fail message="Set -Djdk16= to a JDK1.6 installation" unless="HAVE_JDK_1.6"/>-->
      
      <!-- testing interoperating with clients using the unified invokers over jboss remoting -->
      <test-compatibility client-version="4_2_x" label="15c-15s" client-jdk="${jdk15}" server-jdk="${jdk15}" client-serialization-flag="-Dnone" serialization-flag="-Dnone"/>
@@ -3555,7 +3555,6 @@
     <attribute name="server-jdk"/>
     <attribute name="client-serialization-flag"/>    
     <attribute name="serialization-flag"/>
-    <attribute name="server-config"/>
     <sequential>
       <start-jboss conf="default" jvmargs="-Xmx128m @{serialization-flag}" java.exec="@{server-jdk}/bin/java"/>
       <wait-on-host/>
@@ -3566,7 +3565,7 @@
         <param name="client-serialization-flag" value="@{client-serialization-flag}"/>
       </antcall>
       <stop-jboss jvmargs="@{serialization-flag}" java.exec="@{server-jdk}/bin/java"/>
-      <wait-on-shutdown conf="@{server-config}"/>
+      <wait-on-shutdown conf="default"/>
     </sequential>
   </macrodef>
  

Added: trunk/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java	2008-11-02 14:13:57 UTC (rev 80347)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.compatibility.test.matrix;
+
+import org.apache.log4j.Logger;
+
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestListener;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This class is a Test container for the MatrixTest.
+ * For each instance running it will include a bunch of other tests passed by parameter.
+ *
+ * This class uses list of variables defined by the testSuite and they have to be in the System.getProperties()
+ * jbosstest.hometest = Contains where we are loading the testcases
+ * jbosstest.executionlist = A comma based list of .class files. Each file has to begin with ${jbosstest.hometest}
+ * jbosstest.versionname = The name of the version being tested
+ *
+ * @author clebert.suconic at jboss.com
+ */
+public class MatrixTestContainer extends TestCase
+{
+    static Logger log = Logger.getLogger("MatrixTestContainer");
+
+    /** Used to similuate tests while renaming its names. */
+    private static class DummyTestCase extends TestCase
+    {
+        DummyTestCase(String name)
+        {
+            super (name);
+        }
+    }
+
+    /** We need this proxy just to inform failures*/
+    private static class TestSuiteProxy extends TestSuite
+    {
+        ArrayList loadFailures;
+        public TestSuiteProxy(ArrayList loadFailures)
+        {
+            this.loadFailures=loadFailures;
+        }
+
+        public void run(TestResult testResult)
+        {
+            Iterator iter = loadFailures.iterator();
+            while (iter.hasNext())
+            {
+                LoadFailure load = (LoadFailure)iter.next();
+                TestCase test = new DummyTestCase(load.className);
+                testResult.startTest(test);
+                testResult.addError(test,load.exception);
+            }
+
+            loadFailures.clear();
+
+            super.run(testResult);
+        }
+
+
+    }
+
+    private static class LoadFailure
+    {
+        String className;
+        Throwable exception;
+
+        public LoadFailure(String className, Throwable exception)
+        {
+            this.className=className;
+            this.exception=exception;
+        }
+    }
+
+    /**
+     * One of the goals of this class also is to keep original classNames into testNames. So, you will realize several proxies existent here to
+     * keep these class names while executing method names.
+     */
+    static class TestProxy extends TestCase
+    {
+        Hashtable hashTests = new Hashtable();
+
+
+
+        public TestProxy(Test testcase, String name)
+        {
+            super(name);
+            this.testcase = testcase;
+        }
+
+        public int countTestCases()
+        {
+            return testcase.countTestCases();
+        }
+
+        /**
+         * Create a dummy test renaming its content
+         * @param test
+         * @return
+         */
+        private Test createDummyTest(Test test)
+        {
+            Test dummyTest = (Test)hashTests.get(test);
+            if (dummyTest==null)
+            {
+                if (test instanceof TestCase)
+                {
+                    dummyTest = new DummyTestCase(this.getName() + ":"+ ((TestCase)test).getName());
+                } else
+                if (test instanceof TestSuite)
+                {
+                    dummyTest = new DummyTestCase(this.getName() + ":"+ ((TestCase)test).getName());
+                }
+                else
+                {
+                    // if can't recover the name, don't create a proxy
+                    log.warn("Couldn't find a name for " + test.toString() + ", class=" + test.getClass().getName());
+
+                    dummyTest = new DummyTestCase(test.getClass().getName());
+                }
+
+                hashTests.put(test,dummyTest);
+            }
+
+            return dummyTest;
+        }
+
+        public void run(final TestResult result)
+        {
+            TestResult subResult = new TestResult();
+            subResult.addListener(new TestListener()
+            {
+                public void addError(Test subtest, Throwable throwable)
+                {
+                    Test dummyTest = createDummyTest(subtest);
+                    result.addError(dummyTest, throwable);
+                }
+
+                public void addFailure(Test subtest, AssertionFailedError assertionFailedError)
+                {
+                    Test dummyTest = createDummyTest(subtest);
+                    result.addFailure(dummyTest, assertionFailedError);
+                }
+
+                public void endTest(Test subtest)
+                {
+                    Test dummyTest = createDummyTest(subtest);
+                    result.endTest(dummyTest);
+                }
+
+                public void startTest(Test subtest)
+                {
+                    Test dummyTest = createDummyTest(subtest);
+                    result.startTest(dummyTest);
+                }
+            });
+            testcase.run(subResult);
+        }
+
+        Test testcase;
+    }
+
+    private static Test createSuite(Class clazz) throws Exception
+    {
+        Method method = null;
+        try
+        {
+            method = clazz.getMethod("suite", null);
+        }
+        catch (Exception e)
+        {
+        }
+
+        if (method != null)
+        {
+            return (Test) method.invoke(null, null);
+        } else
+        {
+            TestSuite suiteTmp = new TestSuite();
+            suiteTmp.addTestSuite(clazz);
+            return suiteTmp;
+        }
+    }
+
+    private static void copySuite(Test source, TestSuite destination, String baseName)
+    {
+        destination.addTest(new TestProxy(source,baseName));
+    }
+
+    /** As jdk1.3 doesn't have .slipt as a method on string, I've created this method */
+    public static String[] split(String arguments)
+    {
+
+        ArrayList list = new ArrayList();
+        while (arguments!=null && !arguments.equals(""))
+        {
+            int position = arguments.indexOf(',');
+
+            if (position>=0)
+            {
+                 String currentString = arguments.substring(0,position);
+                 list.add(currentString);
+                 arguments = arguments.substring(position+1);
+            }
+            else
+            {
+                list.add(arguments);
+                arguments = null;
+            }
+        }
+        return (String[]) list.toArray(new String[list.size()]);
+    }
+
+
+    public static Test suite()
+    {
+        try
+        {
+            String homedir = (String) System.getProperties().get("jbosstest.hometest");
+
+            String executionList = (String) System.getProperties().get("jbosstest.executionlist");
+            System.out.println("ExecutionList = " + executionList);
+
+            String[] tests = split(executionList);
+
+            ArrayList loadFailures = new ArrayList();
+
+            TestSuite suite = new TestSuiteProxy(loadFailures);
+
+            for (int classesCount = 0; classesCount < tests.length; classesCount++)
+            {
+                String testName = null;
+                try
+                {
+                    if (tests[classesCount].trim().equals("")) continue;
+                    testName = tests[classesCount].substring(homedir.length() + 1);
+                    testName = testName.replace('/', '.');
+                    testName = testName.substring(0, testName.length() - 6); // - ".class".length()
+
+                    Class clazz = Class.forName(testName);
+                    Test suiteTmp = createSuite(clazz);
+                    copySuite(suiteTmp, suite, testName + ":");
+                } catch (Throwable e)
+                {
+                    loadFailures.add(new LoadFailure(testName,e));
+                    log.info("Error Loading " + testName);
+                    e.printStackTrace();
+                    log.warn(e.getMessage());
+                }
+            }
+
+            log.info("All classes loaded, executing tests");
+
+            return suite;
+        } catch (Exception e)
+        {
+            e.printStackTrace();
+            return null;
+        }
+
+
+    }
+
+}




More information about the jboss-cvs-commits mailing list