[jboss-svn-commits] JBL Code SVN: r10782 - in labs/jbossrules/trunk/drools-eclipse: drools-eclipse-test and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Apr 5 00:56:49 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-04-05 00:56:49 -0400 (Thu, 05 Apr 2007)
New Revision: 10782
Added:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/test.xml
Modified:
labs/jbossrules/trunk/drools-eclipse/allElements.xml
labs/jbossrules/trunk/drools-eclipse/build.properties
labs/jbossrules/trunk/drools-eclipse/customTargets.xml
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test-feature/feature.xml
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/build.properties
Log:
JBRULES-761 Automate the Eclipse build
-still tyring to automate the tests.
Modified: labs/jbossrules/trunk/drools-eclipse/allElements.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/allElements.xml 2007-04-05 04:01:34 UTC (rev 10781)
+++ labs/jbossrules/trunk/drools-eclipse/allElements.xml 2007-04-05 04:56:49 UTC (rev 10782)
@@ -33,7 +33,7 @@
</target>
<target name="assemble.org.drools.eclipse.test-feature">
- <property name="archiveName" value="${zipFile}"/>
+ <property name="archiveName" value="${testZipFile}"/>
<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
</target>
</project>
Modified: labs/jbossrules/trunk/drools-eclipse/build.properties
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/build.properties 2007-04-05 04:01:34 UTC (rev 10781)
+++ labs/jbossrules/trunk/drools-eclipse/build.properties 2007-04-05 04:56:49 UTC (rev 10782)
@@ -24,6 +24,7 @@
##sets the zip name
zipFile=jbossrules-eclipse-3.1.0-M1.zip
+testZipFile=jbossrules-eclipse-test-3.1.0-M1.zip
#Set the name of the archive that will result from the product build.
#archiveNamePrefix=
@@ -97,7 +98,7 @@
# The directory into which the build elements are fetched and where
# the build takes place.
-buildDirectory=${builder}/eclipse.build
+buildDirectory=${builder}/target/eclipse.build
# Type of build. Used in naming the build output. Typically this value is
# one of I, N, M, S, ...
@@ -127,7 +128,7 @@
# in most RCP app or a plug-in, the baseLocation should be the location of a previously
# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
-base=c:/java
+base=${builder}/target
baseLocation=${base}/eclipse
#Os/Ws/Arch/nl of the eclipse specified by baseLocation
baseos=win32
@@ -141,10 +142,11 @@
#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
#pluginPath=
-skipBase=true
-eclipseURL=<url for eclipse download site>
-eclipseBuildId=<Id of Eclipse build to get>
-eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
+#skipBase=true
+eclipseGefURL=http://download.eclipse.org//tools/gef/downloads/drops/R-3.2.2-200702081315
+eclipseURL=http://download.eclipse.org/eclipse/downloads/drops/R-3.2.2-200702121330
+eclipseBuildId=3.2.2
+#eclipseBaseURL=${eclipseURL}/eclipse-${eclipseBuildId}-win32.zip
############# MAP FILE CONTROL ################
Modified: labs/jbossrules/trunk/drools-eclipse/customTargets.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/customTargets.xml 2007-04-05 04:01:34 UTC (rev 10781)
+++ labs/jbossrules/trunk/drools-eclipse/customTargets.xml 2007-04-05 04:56:49 UTC (rev 10782)
@@ -13,12 +13,22 @@
<!-- ===================================================================== -->
<!-- ===================================================================== -->
<target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
- <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" />
- <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" />
- </target>
+ <get src="${eclipseURL}/eclipse-SDK-${eclipseBuildId}-win32.zip" dest="${buildDirectory}/../eclipse-SDK-${eclipseBuildId}-win32.zip" />
+ <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../eclipse-SDK-${eclipseBuildId}-win32.zip" />
+
+ <get src="${eclipseGefURL}/GEF-runtime-${eclipseBuildId}.zip" dest="${buildDirectory}/../GEF-runtime-${eclipseBuildId}.zip" />
+ <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../GEF-runtime-${eclipseBuildId}.zip" />
+
+ <get src="${eclipseURL}/eclipse-test-framework-${eclipseBuildId}.zip"
+ dest="${buildDirectory}/../eclipse-test-framework-${eclipseBuildId}.zip"/>
+
+ <unzip dest="${base}" overwrite="true"
+ src="${buildDirectory}/../eclipse-test-framework-${eclipseBuildId}.zip" />
+
+ </target>
<target name="checkLocalBase">
- <available file="${base}" property="skipBase" />
+ <available file="${baseLocation}" property="skipBase" />
</target>
<!-- ===================================================================== -->
@@ -169,8 +179,16 @@
<!-- ===================================================================== -->
<!-- Steps to do to test the build results -->
<!-- ===================================================================== -->
- <target name="test">
- </target>
+ <target name="test" if="runTests">
+ <unzip src="${buildDirectory}/${buildLabel}/com.ibm.eclipse.shootout-${buildId}.zip"
+ dest="${base}"/>
+ <unzip src="${buildDirectory}/${buildLabel}/com.ibm.eclipse.shootout.tests-${buildId}.zip" dest="${base}"/>
+ <ant antfile="${base}/eclipse/plugins/org.drools.eclipse.tests_1.0.0/test.xml">
+ <property name="os" value="${baseos}" />
+ <property name="ws" value="${basews}" />
+ <property name="arch" value="${basearch}" />
+ </ant>
+ </target>
<!-- ===================================================================== -->
<!-- Steps to do to publish the build results -->
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/build.properties
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/build.properties 2007-04-05 04:01:34 UTC (rev 10781)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/build.properties 2007-04-05 04:56:49 UTC (rev 10782)
@@ -1,5 +1,6 @@
bin.includes = META-INF/,\
- .
+ .,\
+ test.xml
jars.compile.order = .
source.. = src/test/java/,\
src/test/resources/
@@ -9,4 +10,5 @@
.settings/,\
META-INF/,\
build.properties,\
- src/
+ src/,\
+ test.xml
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java 2007-04-05 04:56:49 UTC (rev 10782)
@@ -0,0 +1,9 @@
+package org.drools.eclipse;
+import junit.framework.Test;
+
+
+public class AllTests {
+ public static Test suite() {
+ return AllTestsUtil.suite();
+ }
+}
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java 2007-04-05 04:56:49 UTC (rev 10782)
@@ -0,0 +1,161 @@
+package org.drools.eclipse;
+
+//Copyright (c) 2006 Alex Blewitt
+//All rights reserved. This program and the accompanying materials
+//are made available under the terms of the Eclipse Public License v1.0
+//which accompanies this distribution, and is available at
+//http://www.eclipse.org/legal/epl-v10.html
+//
+//Contributors:
+//Alex Blewitt - Initial API and implementation
+//
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Vector;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.runner.ClassPathTestCollector;
+import junit.runner.TestCollector;
+import org.eclipse.core.runtime.Platform;
+/**
+* Run all the tests in this project, either computed from the classpath or from
+* the bundlepath. To use this as-is, drop it into a non-default package that
+* has the same name as the plugin. For example, if the plugin is called
+* <code>org.example.foo</code>, this should be placed in a package
+* <code>org.example.foo</code>, and all tests should live under the
+* <code>org.example.foo</code> package structure (either directly, or in any
+* subpackage). By default this will include all non-abstract classes named
+* <code>XxxTest</code>, excluding <code>XxxPlatformTest</code> if running
+* outside of the platform.
+*/
+
+public class AllTestsUtil {
+ /**
+ * Detects classes from the bundle PLUGIN_NAME's entries. Uses
+ * <code>bundle.findEntries</code> to obtain a list of classes that live
+ * in the specified PACKAGE_NAME, and adds those to the test path, providing
+ * that they are {@link AllTests#isValidTest(String, boolean) valid}.
+ */
+ private static class BundleTestDetector implements TestCollector {
+ /*
+ * @see junit.runner.TestCollector#collectTests()
+ */
+ public Enumeration collectTests() {
+ final Vector tests = new Vector();
+ try {
+ Enumeration entries = Platform.getBundle(PLUGIN_NAME).findEntries("/", "*" + SUFFIX + ".class", true);
+ while (entries.hasMoreElements()) {
+ URL entry = (URL) entries.nextElement();
+ // Change the URLs to have Java class names
+ String path = entry.getPath().replace('/', '.');
+ int start = path.indexOf(PACKAGE_NAME);
+ String name = path.substring(start, path.length()
+ - ".class".length());
+ if (isValidTest(name, true)) {
+ tests.add(name);
+ }
+ }
+ } catch (Exception e) {
+ // If we get here, the Platform isn't installed and so we fail
+ // quietly. This isn't a problem; we might be outside of the
+ // Platform framework and just running tests locally. It's not
+ // even worth printing anything out to the error log as it would
+ // just confuse people investigating stack traces etc.
+ }
+ return tests.elements();
+ }
+ }
+ /**
+ * Searches the current classpath for tests, which are those ending with
+ * SUFFIX, excluding those which end in IN_CONTAINER_SUFFIX, providing that
+ * they are {@link AllTests#isValidTest(String, boolean) valid}.
+ */
+ private static class ClassFileDetector extends ClassPathTestCollector {
+ /*
+ * @see junit.runner.ClassPathTestCollector#isTestClass(java.lang.String)
+ */
+ protected boolean isTestClass(String classFileName) {
+ return classFileName.endsWith(SUFFIX + ".class")
+ && isValidTest(classNameFromFile(classFileName), false);
+ }
+ }
+ /**
+ * All tests should end in XxxTest
+ */
+ public static final String SUFFIX = "Test";
+ /**
+ * All in-container tests should end in XxxPlatformTest
+ */
+ public static final String IN_CONTAINER_SUFFIX = "Platform" + SUFFIX;
+ /**
+ * The base package name of the tests to run. This defaults to the name of
+ * the package that the AllTests class is in for ease of management but may
+ * be trivially changed if required. Note that at least some identifiable
+ * part must be provided here (so default package names are not allowed)
+ * since the URL that comes up in the bundle entries have a prefix that is
+ * not detectable automatically. Even if this is "org" or "com" that should
+ * be enough.
+ */
+ public static final String PACKAGE_NAME = AllTests.class.getPackage()
+ .getName();
+ /**
+ * The name of the plugin to search if the platform is loaded. This defaults
+ * to the name of the package that the AllTests class is in for ease of
+ * management but may be trivially changed if required.
+ */
+ public static final String PLUGIN_NAME = AllTests.class.getPackage()
+ .getName();
+ /**
+ * Add the tests reported by collector to the list of tests to run
+ * @param collector the test collector to run
+ * @param suite the suite to add the tests to
+ */
+ private static void addTestsToSuite(TestCollector collector, TestSuite suite) {
+ Enumeration e = collector.collectTests();
+ while (e.hasMoreElements()) {
+ String name = (String) e.nextElement();
+ try {
+ suite.addTestSuite(Class.forName(name));
+ } catch (ClassNotFoundException e1) {
+ System.err.println("Cannot load test: " + e1);
+ }
+ }
+ }
+ /**
+ * Is the test a valid test?
+ * @param name the name of the test
+ * @param inContainer true if we want to include the inContainer tests
+ * @return true if the name is a valid class (can be loaded), that it is not
+ * abstract, and that it ends with SUFFIX, and that either
+ * inContainer tests are to be included or the name does not end
+ * with IN_CONTAINER_SUFFIX
+ */
+ private static boolean isValidTest(String name, boolean inContainer) {
+ try {
+ return name.endsWith(SUFFIX)
+ && (inContainer || !name.endsWith(IN_CONTAINER_SUFFIX))
+ && ((Class.forName(name).getModifiers() & Modifier.ABSTRACT) == 0);
+ } catch (ClassNotFoundException e) {
+ System.err.println(e.toString());
+ return false;
+ }
+ }
+ /**
+ * Return all the tests. If we're in a platform, return everything. If not,
+ * we return those tests that end in SUFFIX but excluding those ending in
+ * IN_CONTAINER_SUFFIX.
+ * @return a suite of tests for JUnit to run
+ * @throws Error if there are no tests to run.
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ addTestsToSuite(new ClassFileDetector(), suite);
+ addTestsToSuite(new BundleTestDetector(), suite);
+ if (suite.countTestCases() == 0) {
+ throw new Error("There are no test cases to run");
+ } else {
+ return suite;
+ }
+ }
+}
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/test.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/test.xml (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test/test.xml 2007-04-05 04:56:49 UTC (rev 10782)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script,
+ set a meaningful default value for when it is not. -->
+ <property name="baseLocation" location="${eclipse.home}"/>
+ <property name="eclipse-home" location="${baseLocation}"/>
+
+ <!-- sets the properties eclipse-home, and library-file -->
+ <property name="plugin-name" value="org.drools.eclipse.test"/>
+ <property name="library-file" location="${eclipse-home}/plugins/org.eclipse.test_3.1.0/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for
+ all tests that are to be run. Initialization for individual tests
+ should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="test-workspace" location="${eclipse-home}/test-workspace"/>
+
+ <delete dir="${test-workspace}" quiet="true"/>
+
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${test-workspace}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.drools.eclipse.AllTests"/>
+ </ant>
+
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after
+ after all of the tests have been run. We can use this target to
+ delete temporary files that have been created. -->
+ <target name="cleanup">
+
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen
+ after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="com*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+</project>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test-feature/feature.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test-feature/feature.xml 2007-04-05 04:01:34 UTC (rev 10781)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-test-feature/feature.xml 2007-04-05 04:56:49 UTC (rev 10782)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="org.drools.eclipse.test.feature"
+ id="org.drools.eclipse.test-feature"
label="JBossRules Feature"
version="3.1.0.M1"
provider-name="JBoss, Inc.">
@@ -18,7 +18,7 @@
</license>
<plugin
- id="org.drools.test.eclipse"
+ id="org.drools.eclipse.test"
download-size="0"
install-size="0"
version="3.1.0.M1"/>
More information about the jboss-svn-commits
mailing list