[jboss-cvs] JBossAS SVN: r62511 - in branches/JBoss_3_2_6_CP/testsuite: src/main/org/jboss and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 24 09:10:15 EDT 2007
Author: jaroslaw.kijanowski
Date: 2007-04-24 09:10:15 -0400 (Tue, 24 Apr 2007)
New Revision: 62511
Added:
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/matrix/
branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/matrix/MatrixTestContainer.java
Modified:
branches/JBoss_3_2_6_CP/testsuite/build.xml
branches/JBoss_3_2_6_CP/testsuite/mqstress.xml
Log:
backport compatibility matrix
Modified: branches/JBoss_3_2_6_CP/testsuite/build.xml
===================================================================
--- branches/JBoss_3_2_6_CP/testsuite/build.xml 2007-04-24 11:13:13 UTC (rev 62510)
+++ branches/JBoss_3_2_6_CP/testsuite/build.xml 2007-04-24 13:10:15 UTC (rev 62511)
@@ -6291,4 +6291,106 @@
manually updated when the version info of the server changes
-->
&mqstress;
+ <target name="tests-matrix"
+ description="Executes only the version check compatibility suite. Use -Dmatrix-versions=[version container] for this task" depends="maybejars" if="matrix-versions">
+ <antcall target="tests-standard-unit-matrix"/>
+ <start-jboss conf="all" jvmargs="-Xmx128m"/>
+ <wait-on-host/>
+ <antcall target="tests-standard-unit-matrix"/>
+ <stop-jboss/>
+ <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"/>
+ <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}"/>
+ </antcall>
+ </sequential>
+ </macrodef>
+
+ <target name="execute-matrix-unit-target">
+ <echo message=">>>>>> Executing test=${test-name} filter=${parameter-filter}"/>
+ <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}"/>
+ </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}"/>
+ <pathelement path="${jboss.server.lib}/jboss.jar"/>
+ <pathelement path="${jboss.jmx.lib}/jboss-jmx.jar"/>
+ <fileset dir="${current-version-dir}" includes="*.jar"/>
+ <path refid="thirdparty.classpath" />
+ </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="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_3_2_6_CP/testsuite/mqstress.xml
===================================================================
--- branches/JBoss_3_2_6_CP/testsuite/mqstress.xml 2007-04-24 11:13:13 UTC (rev 62510)
+++ branches/JBoss_3_2_6_CP/testsuite/mqstress.xml 2007-04-24 13:10:15 UTC (rev 62511)
@@ -40,9 +40,9 @@
<!-- Must be syncronized with build/build.xml -->
<property name="version.major" value="3"/>
- <property name="version.minor" value="0"/>
- <property name="version.revision" value="0"/>
- <property name="version.tag" value="beta2"/>
+ <property name="version.minor" value="2"/>
+ <property name="version.revision" value="6"/>
+ <property name="version.tag" value=".GA_CP01"/>
<property name="version.name" value="HEAD"/>
<!-- Module name(s) & version -->
@@ -570,4 +570,4 @@
haltonfailure="${junit.batchtest.haltonfailure}"
fork="${junit.batchtest.fork}"/>
</junit>
- </target>
\ No newline at end of file
+ </target>
Added: branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java
===================================================================
--- branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java (rev 0)
+++ branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/AntCallOnDirectoryList.java 2007-04-24 13:10:15 UTC (rev 62511)
@@ -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_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
===================================================================
--- branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java (rev 0)
+++ branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java 2007-04-24 13:10:15 UTC (rev 62511)
@@ -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_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/matrix/MatrixTestContainer.java
===================================================================
--- branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/matrix/MatrixTestContainer.java (rev 0)
+++ branches/JBoss_3_2_6_CP/testsuite/src/main/org/jboss/test/compatibility/matrix/MatrixTestContainer.java 2007-04-24 13:10:15 UTC (rev 62511)
@@ -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