diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java deleted file mode 100644 index 411bc357acb..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.tests.session; - -import junit.framework.AssertionFailedError; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestResult; -import org.eclipse.core.tests.session.SetupManager.SetupException; - -/** - * Runs perfomance test cases multiple times (if they don't fail), - * enabling assertions for the first run. - */ -public class PerformanceSessionTestSuite extends SessionTestSuite { - - /** - * This custom test result allows multiple test runs to show up as a - * single run. - */ - private static class ConsolidatedTestResult extends TestResult { - private boolean failed; - private int runs = 0; - private boolean started = false; - private final TestResult target; - private final int timesToRun; - - public ConsolidatedTestResult(TestResult target, int timesToRun) { - this.target = target; - this.timesToRun = timesToRun; - } - - @Override - public synchronized void addError(Test test, Throwable t) { - failed = true; - target.addError(test, t); - } - - @Override - public synchronized void addFailure(Test test, AssertionFailedError t) { - failed = true; - target.addFailure(test, t); - } - - @Override - public void endTest(Test test) { - runs++; - if (!failed && runs < timesToRun) { - return; - } - target.endTest(test); - } - - @Override - public synchronized boolean shouldStop() { - if (failed) { - return true; - } - return target.shouldStop(); - } - - @Override - public void startTest(Test test) { - // should not try to start again ater failing once - if (failed) { - throw new IllegalStateException(); - } - if (started) { - return; - } - started = true; - target.startTest(test); - } - } - - public static final String PROP_PERFORMANCE = "perf_ctrl"; - - private final int timesToRun; - - public PerformanceSessionTestSuite(String pluginId, int timesToRun) { - super(pluginId); - this.timesToRun = timesToRun; - } - - public PerformanceSessionTestSuite(String pluginId, int timesToRun, Class theClass) { - super(pluginId, theClass); - this.timesToRun = timesToRun; - } - - public PerformanceSessionTestSuite(String pluginId, int timesToRun, Class theClass, - String name) { - super(pluginId, theClass, name); - this.timesToRun = timesToRun; - } - - public PerformanceSessionTestSuite(String pluginId, int timesToRun, String name) { - super(pluginId, name); - this.timesToRun = timesToRun; - } - - @Override - protected void runSessionTest(TestDescriptor descriptor, TestResult result) { - try { - fillTestDescriptor(descriptor); - } catch (SetupException e) { - Throwable cause = e.getCause() == null ? e : e.getCause(); - result.addError(descriptor.getTest(), cause); - return; - } - descriptor.getSetup().setSystemProperty("eclipse.perf.dbloc", System.getProperty("eclipse.perf.dbloc")); - descriptor.getSetup().setSystemProperty("eclipse.perf.config", System.getProperty("eclipse.perf.config")); - // run test cases n-1 times - ConsolidatedTestResult consolidated = new ConsolidatedTestResult(result, timesToRun); - for (int i = 0; !consolidated.shouldStop() && i < timesToRun - 1; i++) { - descriptor.run(consolidated); - } - if (consolidated.shouldStop()) { - return; - } - // for the n-th run, enable assertions - descriptor.getSetup().setSystemProperty("eclipse.perf.assertAgainst", System.getProperty("eclipse.perf.assertAgainst")); - descriptor.run(consolidated); - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/UIPerformanceSessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/UIPerformanceSessionTestSuite.java deleted file mode 100644 index 78cdfb39dc9..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/UIPerformanceSessionTestSuite.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.tests.session; - -import junit.framework.TestCase; -import org.eclipse.core.tests.session.SetupManager.SetupException; - -/** - * TODO It should live in the UI tests instead. - */ -public class UIPerformanceSessionTestSuite extends PerformanceSessionTestSuite { - - public UIPerformanceSessionTestSuite(String pluginId, int timesToRun) { - super(pluginId, timesToRun); - setApplicationId(SessionTestSuite.UI_TEST_APPLICATION); - } - - public UIPerformanceSessionTestSuite(String pluginId, int timesToRun, Class theClass) { - super(pluginId, timesToRun, theClass); - setApplicationId(SessionTestSuite.UI_TEST_APPLICATION); - } - - public UIPerformanceSessionTestSuite(String pluginId, int timesToRun, Class theClass, - String name) { - super(pluginId, timesToRun, theClass, name); - setApplicationId(SessionTestSuite.UI_TEST_APPLICATION); - } - - public UIPerformanceSessionTestSuite(String pluginId, int timesToRun, String name) { - super(pluginId, timesToRun, name); - setApplicationId(SessionTestSuite.UI_TEST_APPLICATION); - } - - /** - * Ensures setup uses this suite's instance location. - */ - @Override - protected Setup newSetup() throws SetupException { - Setup base = super.newSetup(); - base.setSystemProperty("org.eclipse.ui.testsWaitForEarlyStartup", "false"); - return base; - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest.java deleted file mode 100644 index 4dd144b9460..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.tests.session.samples; - -import static org.eclipse.core.tests.harness.TestHarnessPlugin.PI_HARNESS; - -import junit.framework.TestCase; -import junit.framework.TestResult; -import org.eclipse.core.tests.session.SessionTestRunner; -import org.eclipse.core.tests.session.SessionTestSuite; -import org.eclipse.core.tests.session.SetupManager; -import org.eclipse.core.tests.session.TestDescriptor; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; - -public class MultipleRunsTest extends TestCase { - public void testMultipleRuns() throws SetupManager.SetupException { - // the test case to run multiple times - TestDescriptor test = new TestDescriptor(SampleSessionTest.class.getName(), "testApplicationStartup"); - test.setApplicationId(SessionTestSuite.CORE_TEST_APPLICATION); - test.setPluginId(PI_HARNESS); - test.setTestRunner(new SessionTestRunner()); - // setup the command line to be passed to the multiple runs so it has the right system properties - test.setSetup(SetupManager.getInstance().getDefaultSetup()); - test.getSetup().setSystemProperty("eclipse.perf.dbloc", System.getProperty("eclipse.perf.dbloc")); - test.getSetup().setSystemProperty("eclipse.perf.config", System.getProperty("eclipse.perf.config")); - // runs the test case several times - only to collect data, won't do any assertions - TestResult result = new TestResult(); - for (int i = 0; i < 5; i++) { - test.run(result); - if (result.failureCount() > 0) { - result.failures().nextElement().thrownException().printStackTrace(); - return; - } - if (result.errorCount() > 0) { - result.errors().nextElement().thrownException().printStackTrace(); - return; - } - } - // create a performance meter whose scenario id matches the one used in the test case run - // our convention: scenario IDs are + '.' + - PerformanceMeter meter = Performance.getDefault().createPerformanceMeter(test.getTestClass() + '.' + test.getTestMethod()); - // finally do the assertion - Performance.getDefault().assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -50, 5); - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest2.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest2.java deleted file mode 100644 index 0b13f7ed632..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/MultipleRunsTest2.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.tests.session.samples; - -import static org.eclipse.core.tests.harness.TestHarnessPlugin.PI_HARNESS; - -import junit.framework.Test; -import junit.framework.TestCase; -import org.eclipse.core.tests.session.PerformanceSessionTestSuite; -import org.eclipse.core.tests.session.TestDescriptor; - -public class MultipleRunsTest2 extends TestCase { - public static Test suite() { - PerformanceSessionTestSuite suite = new PerformanceSessionTestSuite(PI_HARNESS, 10); - suite.addTest(new TestDescriptor(SampleSessionTest.class.getName(), "testApplicationStartup")); - return suite; - } -}