[jboss-cvs] JBossAS SVN: r62537 - in branches/JBoss_4_0_0_CP/testsuite: imports and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 25 07:07:22 EDT 2007


Author: jaroslaw.kijanowski
Date: 2007-04-25 07:07:22 -0400 (Wed, 25 Apr 2007)
New Revision: 62537

Added:
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/matrix/
   branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java
Modified:
   branches/JBoss_4_0_0_CP/testsuite/build.xml
   branches/JBoss_4_0_0_CP/testsuite/imports/server-config.xml
Log:
fix compatibility matrix

Modified: branches/JBoss_4_0_0_CP/testsuite/build.xml
===================================================================
--- branches/JBoss_4_0_0_CP/testsuite/build.xml	2007-04-25 10:14:35 UTC (rev 62536)
+++ branches/JBoss_4_0_0_CP/testsuite/build.xml	2007-04-25 11:07:22 UTC (rev 62537)
@@ -1385,6 +1385,11 @@
     </java>
   </target>
 
+   <!-- Import the jboss server run targets -->
+   <dirname property="project.root" file="${basedir}"/>
+   <import file="imports/server-config.xml"/>
+
+
   <!-- ================================================================== -->
   <!-- Archives                                                           -->
   <!-- ================================================================== -->
@@ -5744,6 +5749,37 @@
   <!-- Tests                                                              -->
   <!-- ================================================================== -->
 
+   <macrodef name="wait-on-host">
+      <attribute name="seconds" default="60"/>
+      <attribute name="host" default="localhost"/>
+      <sequential>
+         <echo message="Waiting for @{host} to start..."/>
+         <waitfor maxwait="@{seconds}" maxwaitunit="second"
+            checkevery="5" checkeveryunit="second" timeoutproperty="startup.timeout">
+            <http url="http://@{host}:8080/"/>
+         </waitfor>
+         <fail message="Timeout waiting for nodes to start" if="startup.timeout"/>
+      </sequential>
+   </macrodef>
+   <macrodef name="wait-on-shutdown">
+      <attribute name="seconds" default="60"/>
+      <attribute name="conf"/>
+      <sequential>
+         <echo message="Waiting for '@{conf}' server to stop..."/>
+         <waitfor maxwait="@{seconds}" maxwaitunit="second"
+            checkevery="5" checkeveryunit="second" timeoutproperty="shutdown.timeout">
+            <available file="server.log">
+               <filepath>
+               <fileset dir="${jboss.dist}/server/@{conf}/log/" includes="server.log">
+                     <contains text="[org.jboss.system.server.Server] Shutdown complete"/>
+                  </fileset>
+               </filepath>
+            </available>
+         </waitfor>
+         <fail message="Timeout waiting for '@{conf}' server to shutdown." if="shutdown.timeout"/>
+      </sequential>
+   </macrodef>
+
   <!--
      | Run all tests.
    -->
@@ -7561,5 +7597,114 @@
          </filterset>
       </copy>
   </target>
+    <target name="tests-matrix"
+      description="Executes only the version check compatibility suite. Use -Dmatrix-versions=[version container] for this task" depends="maybejars, _buildmagic:init" if="matrix-versions">
+      <!--start-jboss-os conf="all" jvmargs="-Xmx128m"/-->
+        <start-jboss-os conf="all" />
+      <wait-on-host/>
+      <antcall target="tests-standard-unit-matrix"/>
+      <stop-jboss-os/>
+      <wait-on-shutdown conf="all"/>
+    </target>
 
+   <target name="define-matrix-task">
+       <taskdef name="matrixtask" classname="org.jboss.ant.taskdefs.AntCallOnDirectoryList">
+           <classpath>
+             <pathelement location="${build.classes}"/>
+           </classpath>
+       </taskdef>
+   </target>
+
+    <target name="tests-standard-unit-matrix" depends="define-matrix-task" if="matrix-versions">
+        <matrixtask targetToExecute="tests-standard-unit-matrix-version" directoryProperty="current-version-dir" versionNameProperty="matrix-configuration">
+            <dirset dir="${matrix-versions}"/>
+        </matrixtask>
+    </target>
+
+
+    <macrodef name="execute-matrix-unit">
+        <attribute name="test-name"/>
+        <attribute name="parameter-filter"/>
+        <attribute name="parameter-exclude-filter" default=""/> 
+        <sequential>
+            <!-- this requires antcall as a property can't be redefined -->
+            <antcall target="execute-matrix-unit-target">
+                <param name="test-name" value="@{test-name}"/>
+                <param name="parameter-filter" value="@{parameter-filter}"/>
+                <param name="parameter-exclude-filter" value="@{parameter-exclude-filter}"/>
+            </antcall>
+        </sequential>
+    </macrodef>
+
+    <target name="execute-matrix-unit-target">
+            <echo message=">>>>>> Executing test=${test-name} filter=${parameter-filter}"/>
+            <mkdir dir="${build.reports}"/>
+            <pathconvert pathSep="," dirSep="/" property="jbosstest.hometest">
+                <path location="${build.classes}"/>
+            </pathconvert>
+
+            <pathconvert pathSep="," dirSep="/" property="jbosstest.executionlist">
+                <path >
+                    <fileset dir="${build.classes}">
+                        <include name="${parameter-filter}"/>
+                        <exclude name="${parameter-exclude-filter}"/>
+                   </fileset>
+                </path>
+            </pathconvert>
+
+            <junit dir="${module.output}"
+              printsummary="${junit.printsummary}"
+              haltonerror="${junit.haltonerror}"
+              haltonfailure="${junit.haltonfailure}"
+              fork="true"
+              timeout="${junit.timeout}"
+              jvm="${junit.jvm}">
+
+              <jvmarg value="${junit.jvm.options}"/>
+              <!-- Used for JGroups -->
+              <jvmarg value="-Dbind.address=${node0}"/>
+              <sysproperty key="jbosstest.deploy.dir" file="${build.lib}"/>
+              <sysproperty key="build.testlog" value="${build.testlog}"/>
+              <sysproperty key="log4j.configuration" value="file:${build.resources}/log4j.xml"/>
+              <sysproperty key="jboss-junit-configuration" value="${test-name}_${matrix-configuration}"/>
+              <!-- Pass along any jbosstest.* system properties -->
+              <syspropertyset>
+                <propertyref prefix="jbosstest."/>
+              </syspropertyset>
+              <classpath>
+                <pathelement location="${build.classes}"/>
+                <pathelement location="${build.resources}"/>
+                <fileset dir="${current-version-dir}" includes="*.jar"/>
+                <path refid="library.classpath" />
+                <path refid="thirdparty.classpath" />
+                <pathelement path="${jboss.jmx.lib}/jboss-jmx.jar"/>
+              </classpath>
+                <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+                  usefile="${junit.formatter.usefile}"
+                  extension="-${test-name}_${matrix-configuration}.xml"/>
+
+              <batchtest todir="${build.reports}"
+                haltonerror="${junit.batchtest.haltonerror}"
+                haltonfailure="${junit.batchtest.haltonfailure}"
+                fork="${junit.batchtest.fork}">
+
+                <fileset dir="${build.classes}">
+                  <include name="org/jboss/test/compatibility/test/matrix/MatrixTestContainer.class"/>
+                </fileset>
+              </batchtest>
+            </junit>
+
+    </target>
+
+    <target name="tests-standard-unit-matrix-version">
+        <execute-matrix-unit test-name="client" parameter-filter="org/jboss/test/client/**/*TestCase.class"/>
+        <execute-matrix-unit test-name="WebService" parameter-filter="org/jboss/test/webservice/**/*TestCase.class" parameter-exclude-filter="org/jboss/test/webservice/marshalltest/MarshallRpc*"/>
+        <execute-matrix-unit test-name="WebService2" parameter-filter="org/jboss/test/webservice/marshalltest/MarshallRpcEncodedTestCase.class"/>
+        <execute-matrix-unit test-name="WebService3" parameter-filter="org/jboss/test/webservice/marshalltest/MarshallRpcLiteralTestCase.class"/>
+        <execute-matrix-unit test-name="BMP" parameter-filter="org/jboss/test/bmp/**/*TestCase.class"/>
+        <execute-matrix-unit test-name="CMP" parameter-filter="org/jboss/test/cmp2/**/*TestCase.class"/>
+        <execute-matrix-unit test-name="JBossMX" parameter-filter="org/jboss/test/jbossmx/**/*TestCase.class"/>
+        <execute-matrix-unit test-name="JMS" parameter-filter="org/objectweb/jtests/jms/**/*Test.class"/>
+    </target>
+
 </project>

Modified: branches/JBoss_4_0_0_CP/testsuite/imports/server-config.xml
===================================================================
--- branches/JBoss_4_0_0_CP/testsuite/imports/server-config.xml	2007-04-25 10:14:35 UTC (rev 62536)
+++ branches/JBoss_4_0_0_CP/testsuite/imports/server-config.xml	2007-04-25 11:07:22 UTC (rev 62537)
@@ -4,7 +4,8 @@
 -->
 <project name="server-config" default="help">
 
-   <property name="version" value="${version.major}.${version.minor}.${version.revision}${version.tag}"/>
+   <!--property name="version" value="${version.major}.${version.minor}.${version.revision}${version.tag}"/-->
+   <property name="version" value="4.0.0.GA_CP01"/>
    <property name="jboss.dist"
       value="${project.root}/build/output/jboss-${version}"/>
    <!-- Override for non-Sun compatible JDK layouts -->

Added: branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java
===================================================================
--- branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java	                        (rev 0)
+++ branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java	2007-04-25 11:07:22 UTC (rev 62537)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, the OpenSource webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ant.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.taskdefs.Ant;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.tools.ant.util.SourceFileScanner;
+import org.apache.tools.ant.util.FlatFileNameMapper;
+import org.apache.tools.ant.types.DirSet;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.File;
+
+
+/**
+ * This class will call a specified ant class for each existent file into fileSet or dirSet
+ *
+ * @author Clebert.suconic at jboss.com
+ */
+public class AntCallOnDirectoryList extends Task
+{
+    ArrayList list = new ArrayList();
+
+    String targetToExecute;
+
+    String directoryProperty;
+    String versionNameProperty;
+
+    Ant ant = null;
+
+    public String getVersionNameProperty()
+    {
+        return versionNameProperty;
+    }
+
+    public void setVersionNameProperty(String versionNameProperty)
+    {
+        this.versionNameProperty = versionNameProperty;
+    }
+
+    public String getTargetToExecute()
+    {
+        return targetToExecute;
+    }
+
+    public void setTargetToExecute(String targetToExecute)
+    {
+        this.targetToExecute = targetToExecute;
+    }
+
+    public String getDirectoryProperty()
+    {
+        return directoryProperty;
+    }
+
+    public void setDirectoryProperty(String directoryProperty)
+    {
+        this.directoryProperty = directoryProperty;
+    }
+
+
+    public void init()
+    {
+        super.init();
+        ant = (Ant) this.getProject().createTask("ant");
+        ant.setAntfile(this.getProject().getProperty("ant.file"));
+        ant.setOwningTarget(getOwningTarget());
+        ant.setTaskName(getTaskName());
+        ant.setLocation(getLocation());
+        ant.init();
+    }
+
+
+    public void addDirSet(DirSet dirSet)
+    {
+        list.add(dirSet);
+    }
+
+    public void execute() throws BuildException
+    {
+        init();
+        ant.setTarget(getTargetToExecute());
+        Property parameterDirectory = ant.createProperty();
+        parameterDirectory.setName(this.getDirectoryProperty());
+
+        Property parameterName = ant.createProperty();
+        parameterName.setName(this.getVersionNameProperty());
+
+
+        Iterator iter = list.iterator();
+        while (iter.hasNext())
+        {
+            DirSet dirSet = (DirSet) iter.next();
+            File currentDir = dirSet.getDir(this.getProject());
+            DirectoryScanner scanner = dirSet.getDirectoryScanner(this.getProject());
+
+            SourceFileScanner sourceScanner = new SourceFileScanner(this);
+            String[] strfiles = scanner.getIncludedDirectories();
+            ArrayList files = new ArrayList();
+            for (int i = 0; i < strfiles.length; i++)
+            {
+                File currentFile = new File(currentDir, strfiles[i]);
+                if (currentFile.getParentFile().getAbsolutePath().equals(currentDir.getAbsolutePath()))
+                {
+                    files.add(currentFile);
+                    parameterDirectory.setValue(currentFile.getAbsolutePath());
+                    parameterName.setValue(currentFile.getName());
+                    ant.execute();
+                }
+            }
+
+        }
+    }
+}

Added: branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
===================================================================
--- branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java	                        (rev 0)
+++ branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java	2007-04-25 11:07:22 UTC (rev 62537)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ant.taskdefs;
+
+
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+
+/**
+ * This class only serves the proposite of keep multiple JUnit runnings between different configurations.
+ * For example, if you run a testcase as cluster, and the same testcase as singlenode, we want to keep both results in the JUnitReport.
+ * This is a simple implementation that uses a variable defined jboss-configuration and put that as part of the name.
+ * @author Clebert Suconic
+ */
+public class XMLJUnitMultipleResultFormatter extends XMLJUnitResultFormatter 
+{
+	
+    public void startTestSuite(JUnitTest test) 
+    { 
+        String configuration = (String)System.getProperties().get("jboss-junit-configuration");
+    	
+    	if (configuration!=null && !configuration.trim().equals("")) 
+        {
+                test.setName(test.getName() + "(" + configuration + ")");
+        }
+
+        super.startTestSuite(test);    	
+    }
+
+}

Added: branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java
===================================================================
--- branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java	                        (rev 0)
+++ branches/JBoss_4_0_0_CP/testsuite/src/main/org/jboss/test/compatibility/test/matrix/MatrixTestContainer.java	2007-04-25 11:07:22 UTC (rev 62537)
@@ -0,0 +1,249 @@
+/*
+ *
+ * JBoss, the OpenSource webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.compatibility.test.matrix;
+
+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.logging.Logger;
+import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This class is a container for other tests used for the MatrixTest.
+ * For each version used by the Matrix verification we are containing a bunch of other tests.
+ *
+ * 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.warning("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));
+    }
+
+    public static Test suite()
+    {
+        try
+        {
+            String homedir = (String) System.getProperties().get("jbosstest.hometest");
+
+            String executionList = (String) System.getProperties().get("jbosstest.executionlist");
+
+            String[] tests = executionList.split(",");
+
+            ArrayList loadFailures = new ArrayList();
+
+            TestSuite suite = new TestSuiteProxy(loadFailures);
+
+            for (int classesCount = 0; classesCount < tests.length; classesCount++)
+            {
+                String testName = null;
+                try
+                {
+                    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.warning(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