aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2012-01-27 09:07:18 (EST)
committerDani Megert2012-01-27 09:07:18 (EST)
commit83eac8e066f499629737a7c7e93dc765db3640eb (patch)
tree365a9db3eb8bc5442e1c97dab97902e839a24b8b
parent0ce0072bc554b6e150a2aa78d6152bfb5f31e83d (diff)
downloadeclipse.platform.releng-83eac8e066f499629737a7c7e93dc765db3640eb.zip
eclipse.platform.releng-83eac8e066f499629737a7c7e93dc765db3640eb.tar.gz
eclipse.platform.releng-83eac8e066f499629737a7c7e93dc765db3640eb.tar.bz2
Fixed bug 369818: Add OrderedTestSuite to org.eclipse.test.performancev20120127-1407
-rw-r--r--bundles/org.eclipse.test.performance/.project6
-rw-r--r--bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java82
3 files changed, 91 insertions, 2 deletions
diff --git a/bundles/org.eclipse.test.performance/.project b/bundles/org.eclipse.test.performance/.project
index fa31398..1f09a58 100644
--- a/bundles/org.eclipse.test.performance/.project
+++ b/bundles/org.eclipse.test.performance/.project
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
diff --git a/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF b/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF
index e8f03a3..b015473 100644
--- a/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.test.performance/META-INF/MANIFEST.MF
@@ -2,11 +2,12 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.test.performance
-Bundle-Version: 3.7.0.qualifier
+Bundle-Version: 3.8.0.qualifier
Bundle-Activator: org.eclipse.test.internal.performance.PerformanceTestPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.perfmsr.core,
+ org.eclipse.test,
org.eclipse.test.internal.performance,
org.eclipse.test.internal.performance.data,
org.eclipse.test.internal.performance.db,
@@ -18,6 +19,6 @@ Require-Bundle: org.eclipse.core.runtime,
Cloudscape;resolution:=optional,
org.apache.derby;resolution:=optional,
org.eclipse.test.performance.derby;bundle-version="10.4.2";resolution:=optional
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java b/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java
new file mode 100644
index 0000000..93c0e82
--- /dev/null
+++ b/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.test;
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Test suite with user-specified test order. Fails if not all test methods are
+ * listed.
+ *
+ * <p>
+ * <b>Background:</b> {@link java.lang.Class#getDeclaredMethods()} does not
+ * specify the order of the methods. Up to JavaSE 6, the methods were usually
+ * sorted in declaration order, but in JavaSE 7, the order is random. This class
+ * guarantees reliable test execution order.
+ * </p>
+ *
+ * @since 3.8
+ */
+public class OrderedTestSuite extends TestSuite {
+
+ /**
+ * Creates a new ordered test suite that runs tests in the specified execution order.
+ *
+ * @param testClass the JUnit-3-style test class
+ * @param testMethods the names of all test methods in the expected execution order
+ */
+ public OrderedTestSuite(final Class testClass, String[] testMethods) {
+ super(testClass.getName());
+
+ Set existingMethods= new HashSet();
+ Method[] methods= testClass.getMethods(); // just public member methods
+ for (int i= 0; i < methods.length; i++) {
+ Method method= methods[i];
+ existingMethods.add(method.getName());
+ }
+
+ for (int i= 0; i < testMethods.length; i++) {
+ final String testMethod= testMethods[i];
+ if (existingMethods.remove(testMethod)) {
+ addTest(createTest(testClass, testMethod));
+ } else {
+ addTest(error(testClass, testMethod, new IllegalArgumentException(
+ "Class '" + testClass.getName() + " misses test method '" + testMethod + "'."))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ for (Iterator iter= existingMethods.iterator(); iter.hasNext();) {
+ String existingMethod= (String) iter.next();
+ if (existingMethod.startsWith("test")) { //$NON-NLS-1$
+ addTest(error(testClass, existingMethod, new IllegalArgumentException(
+ "Test method '" + existingMethod + "' not listed in OrderedTestSuite of class '" + testClass.getName() + "'."))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ }
+
+ private static Test error(Class testClass, String testMethod, Exception exception) {
+ final Throwable e2= exception.fillInStackTrace();
+ return new TestCase(testMethod + "(" + testClass.getName() + ")") { //$NON-NLS-1$ //$NON-NLS-2$
+ protected void runTest() throws Throwable {
+ throw e2;
+ }
+ };
+ }
+}