From fa509209a0e8cd6203bab480226bca4a093fd593 Mon Sep 17 00:00:00 2001 From: "Klare, Heiko" Date: Tue, 30 Dec 2025 11:57:04 +0100 Subject: [PATCH] Remove obsolete SessionTestSuite #903 All consumers of SessionTestSuite have been replaced with an adoption of the JUnit 5 SessionTestExtension. This change removes the obsolete JUnit 3 session test suite and related classes and examples. It also removes the package export of the package that used to contain those classes as the remaining ones are for internal use only. Contributes to https://github.com/eclipse-platform/eclipse.platform/issues/903 --- .../META-INF/MANIFEST.MF | 3 +- .../core/tests/session/SessionTestRunner.java | 315 ------------------ .../core/tests/session/SessionTestSuite.java | 163 --------- .../core/tests/session/TestDescriptor.java | 122 ------- .../session/samples/SameSessionTest.java | 52 --- .../session/samples/SampleCrashTest.java | 51 --- .../session/samples/SampleSessionTest.java | 57 ---- .../tests/session/samples/SampleTests.java | 40 --- .../session/samples/UISampleSessionTest.java | 65 ---- 9 files changed, 1 insertion(+), 867 deletions(-) delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SameSessionTest.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleCrashTest.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleSessionTest.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleTests.java delete mode 100644 runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/UISampleSessionTest.java diff --git a/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF index ed67d89930b..63dba3b3e19 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF @@ -5,8 +5,7 @@ Bundle-SymbolicName: org.eclipse.core.tests.harness;singleton:=true Bundle-Version: 3.17.500.qualifier Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tests.harness;version="2.0", - org.eclipse.core.tests.harness.session, - org.eclipse.core.tests.session;version="2.0" + org.eclipse.core.tests.harness.session Require-Bundle: org.junit, org.eclipse.test.performance, org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java deleted file mode 100644 index 59d0e46ae69..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java +++ /dev/null @@ -1,315 +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 static org.eclipse.core.tests.harness.TestHarnessPlugin.PI_HARNESS; -import static org.eclipse.core.tests.harness.TestHarnessPlugin.log; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.ServerSocket; -import java.net.Socket; -import java.nio.charset.StandardCharsets; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import junit.framework.Test; -import junit.framework.TestResult; -import junit.framework.TestSuite; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; - -/** - * This class is responsible for launching JUnit tests on a separate Eclipse session and collect - * the tests results sent back through a socket . - */ -public class SessionTestRunner { - - static class Result { - final static int ERROR = 2; - final static int FAILURE = 1; - final static int SUCCESS = 0; - - String message; - - String stackTrace; - Test test; - int type; - - public Result(Test test) { - this.test = test; - } - } - - /** - * Collectors can be used a single time only. - */ - class ResultCollector implements Runnable { - private boolean finished; - private Result newResult; - private final Map results = new HashMap<>(); - ServerSocket serverSocket; - private boolean shouldRun = true; - private StringBuilder stack; - private final TestResult testResult; - // tests completed during this session - private int testsRun; - - ResultCollector(Test test, TestResult testResult) throws IOException { - serverSocket = new ServerSocket(0); - this.testResult = testResult; - initResults(test); - } - - public int getPort() { - return serverSocket.getLocalPort(); - } - - public int getTestsRun() { - return testsRun; - } - - private void initResults(Test test) { - if (test instanceof TestSuite) { - for (Enumeration e = ((TestSuite) test).tests(); e.hasMoreElements();) { - initResults(e.nextElement()); - } - return; - } - results.put(test.toString(), new Result(test)); - } - - public synchronized boolean isFinished() { - return finished; - } - - private synchronized void markAsFinished() { - finished = true; - notifyAll(); - } - - private String parseTestId(String message) { - if (message.isEmpty() || message.charAt(0) != '%') { - return null; - } - int firstComma = message.indexOf(','); - if (firstComma == -1) { - return null; - } - int secondComma = message.indexOf(',', firstComma + 1); - if (secondComma == -1) { - secondComma = message.length(); - } - return message.substring(firstComma + 1, secondComma); - } - - private void processAvailableMessages(BufferedReader messageReader) throws IOException { - while (messageReader.ready()) { - String message = messageReader.readLine(); - processMessage(message); - } - } - - private void processMessage(String message) { - if (message.startsWith("%TESTS")) { - String testId = parseTestId(message); - if (!results.containsKey(testId)) { - throw new IllegalStateException("Unknown test id: " + testId); - } - newResult = results.get(testId); - testResult.startTest(newResult.test); - return; - } - if (message.startsWith("%TESTE")) { - if (newResult.type == Result.FAILURE) { - testResult.addFailure(newResult.test, new RemoteAssertionFailedError(newResult.message, newResult.stackTrace)); - } else if (newResult.type == Result.ERROR) { - testResult.addError(newResult.test, new RemoteTestException(newResult.message, newResult.stackTrace)); - } - testResult.endTest(newResult.test); - testsRun++; - newResult = null; - return; - } - if (message.startsWith("%ERROR")) { - newResult.type = Result.ERROR; - newResult.message = ""; - return; - } - if (message.startsWith("%FAILED")) { - newResult.type = Result.FAILURE; - newResult.message = ""; - return; - } - if (message.startsWith("%TRACES")) { - // just create the string buffer that will hold all the frames of the stack trace - stack = new StringBuilder(); - return; - } - if (message.startsWith("%TRACEE")) { - // stack trace fully read - fill the slot in the result object and reset the string buffer - newResult.stackTrace = stack.toString(); - stack = null; - return; - } - if (message.startsWith("%")) { - // ignore any other messages - return; - } - if (stack != null) { - // build the stack trace line by line - stack.append(message); - stack.append(System.lineSeparator()); - return; - } - } - - @Override - public void run() { - // someone asked us to stop before we could do anything - if (!shouldRun()) { - return; - } - try (Socket s = serverSocket.accept(); - BufferedReader messageReader = new BufferedReader( - new InputStreamReader(s.getInputStream(), StandardCharsets.UTF_8))) { - // main loop - while (true) { - synchronized (this) { - processAvailableMessages(messageReader); - if (!shouldRun()) { - return; - } - this.wait(150); - } - } - } catch (InterruptedException e) { - // not expected - } catch (IOException e) { - if (!shouldRun()) { - // we have been finished without ever getting any connections - // no need to throw exception - return; - } - log(new Status(IStatus.WARNING, PI_HARNESS, IStatus.ERROR, "Error", e)); - } finally { - // remember we are already finished - markAsFinished(); - } - } - - private synchronized boolean shouldRun() { - return shouldRun; - } - - /* - * Politely asks the collector thread to stop and wait until it is finished. - */ - public void shutdown() { - // ask the collector to stop - synchronized (this) { - if (isFinished()) { - return; - } - shouldRun = false; - try { - serverSocket.close(); - } catch (IOException e) { - log(new Status(IStatus.ERROR, PI_HARNESS, IStatus.ERROR, "Error", e)); - } - notifyAll(); - } - // wait until the collector is done - synchronized (this) { - while (!isFinished()) { - try { - wait(100); - } catch (InterruptedException e) { - // we don't care - } - } - } - } - - } - - /** - * Runs the setup. Returns a status object indicating the outcome of the operation. - * - * @return a status object indicating the outcome - */ - private IStatus launch(Setup setup) { - Assert.isNotNull(setup.getEclipseArgument(Setup.APPLICATION), "test application is not defined"); - Assert.isNotNull(setup.getEclipseArgument("testpluginname"), "test plug-in id not defined"); - Assert.isTrue(setup.getEclipseArgument("classname") != null ^ setup.getEclipseArgument("test") != null, "either a test suite or a test case must be provided"); - // to prevent changes in the protocol from breaking us, - // force the version we know we can work with - setup.setEclipseArgument("version", "3"); - IStatus outcome = Status.OK_STATUS; - try { - int returnCode = setup.run(); - if (returnCode == 23) { - // asked to restart; for now just do this once. - // Note that 23 is our magic return code indicating that a restart is required. - // This can happen for tests that update framework extensions which requires a restart. - returnCode = setup.run(); - } - if (returnCode != 0) { - outcome = new Status(IStatus.WARNING, Platform.PI_RUNTIME, returnCode, "Process returned non-zero code: " + returnCode + "\n\tCommand: " + setup, null); - } - } catch (Exception e) { - outcome = new Status(IStatus.ERROR, Platform.PI_RUNTIME, -1, "Error running process\n\tCommand: " + setup, e); - } - return outcome; - } - - /** - * Runs the test described in a separate session. - */ - public final void run(Test test, TestResult result, Setup setup, boolean crashTest) { - ResultCollector collector = null; - try { - collector = new ResultCollector(test, result); - } catch (IOException e) { - result.addError(test, e); - return; - } - setup.setEclipseArgument("port", Integer.toString(collector.getPort())); - new Thread(collector, "Test result collector").start(); - IStatus status = launch(setup); - collector.shutdown(); - // ensure the session ran without any errors - if (!status.isOK()) { - log(status); - if (status.getSeverity() == IStatus.ERROR) { - result.addError(test, new CoreException(status)); - return; - } - } - if (collector.getTestsRun() == 0) { - if (crashTest) { - // explicitly end test since process crashed before test could finish - result.endTest(test); - } else { - result.addError(test, new Exception("Test did not run: " + test)); - } - } else if (crashTest) { - result.addError(test, new Exception("Should have caused crash")); - } - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java deleted file mode 100644 index 1ad465d077e..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2018 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 java.util.Arrays; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestResult; -import junit.framework.TestSuite; -import org.eclipse.core.tests.session.SetupManager.SetupException; - -public class SessionTestSuite extends TestSuite { - public static final String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$ - public static final String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$ - protected String applicationId = CORE_TEST_APPLICATION; - private final Set crashTests = new HashSet<>(); - // the id for the plug-in whose classloader ought to be used to load the test case class - protected String pluginId; - private Setup setup; - protected SessionTestRunner testRunner; - - public SessionTestSuite(String pluginId) { - super(); - this.pluginId = pluginId; - } - - public SessionTestSuite(String pluginId, Class theClass) { - super(theClass); - this.pluginId = pluginId; - } - - public SessionTestSuite(String pluginId, Class theClass, String name) { - super(theClass, name); - this.pluginId = pluginId; - } - - public SessionTestSuite(String pluginId, String name) { - super(name); - this.pluginId = pluginId; - } - - /** - * Crash tests are not expected to complete (they fail if they do). - */ - public void addCrashTest(TestCase test) { - crashTests.add(test); - super.addTest(test); - } - - protected void fillTestDescriptor(TestDescriptor test) throws SetupException { - if (test.getApplicationId() == null) { - test.setApplicationId(applicationId); - } - if (test.getPluginId() == null) { - test.setPluginId(pluginId); - } - if (test.getSetup() == null) { - test.setSetup(getSetup()); - } - if (!test.isCrashTest() && crashTests.contains(test.getTest())) { - test.setCrashTest(true); - } - test.setTestRunner(getTestRunner()); - } - - public String getApplicationId() { - return applicationId; - } - - public Setup getSetup() throws SetupException { - if (setup == null) { - setup = newSetup(); - } - return setup; - } - - protected SessionTestRunner getTestRunner() { - if (testRunner == null) { - testRunner = new SessionTestRunner(); - } - return testRunner; - } - - protected Test[] getTests(boolean sort) { - Test[] allTests = new Test[testCount()]; - Enumeration e = tests(); - for (int i = 0; i < allTests.length; i++) { - allTests[i] = e.nextElement(); - } - if (sort) { - Arrays.sort(allTests, (o1, o2) -> ((TestCase) o1).getName().compareTo(((TestCase) o2).getName())); - } - return allTests; - } - - protected Setup newSetup() throws SetupException { - Setup base = SetupManager.getInstance().getDefaultSetup(); - base.setSystemProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - return base; - } - - protected void runSessionTest(TestDescriptor test, TestResult result) { - try { - fillTestDescriptor(test); - test.run(result); - } catch (SetupException e) { - Throwable cause = e.getCause(); - result.addError(test.getTest(), cause != null ? cause : e); - } - } - - @Override - public final void runTest(Test test, TestResult result) { - if (test instanceof TestDescriptor) { - runSessionTest((TestDescriptor) test, result); - } else if (test instanceof TestCase) { - runSessionTest(new TestDescriptor((TestCase) test), result); - } else if (test instanceof TestSuite) { - // find and run the test cases that make up the suite - runTestSuite((TestSuite) test, result); - } else { - // we don't support session tests for things that are not TestCases - // or TestSuites (e.g. TestDecorators) - test.run(result); - } - } - - /* - * Traverses the test suite to find individual test cases to be run with the SessionTestRunner. - */ - protected void runTestSuite(TestSuite suite, TestResult result) { - for (Enumeration e = suite.tests(); e.hasMoreElements();) { - if (result.shouldStop()) { - break; - } - Test test = e.nextElement(); - runTest(test, result); - } - } - - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; - } - - void setSetup(Setup setup) { - this.setup = setup; - } - -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java deleted file mode 100644 index 351f54bae2b..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java +++ /dev/null @@ -1,122 +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.Test; -import junit.framework.TestCase; -import junit.framework.TestResult; - -/** - * A test descriptor represents a test case. It is used by the session - * test framework to run tests remotely. Using test descriptors, one - * can run any test case provided by any plug-in by just providing the - * plug-in id, the test class and the test case name. - */ -public class TestDescriptor extends TestCase { - private String applicationId; - private boolean crashTest; - private final String method; - private String pluginId; - private Setup setup; - private Test test; - private final String testClass; - private SessionTestRunner testRunner; - - public TestDescriptor(String testClass, String method) { - this.testClass = testClass; - this.method = method; - } - - public TestDescriptor(TestCase test) { - this.testClass = test.getClass().getName(); - this.method = test.getName(); - this.test = test; - } - - @Override - public int countTestCases() { - return 1; - } - - public String getApplicationId() { - return applicationId; - } - - @Override - public String getName() { - return getTestMethod(); - } - - public String getPluginId() { - return pluginId; - } - - public Setup getSetup() { - return setup; - } - - public Test getTest() { - return test == null ? this : test; - } - - public String getTestClass() { - return testClass; - } - - public String getTestMethod() { - return method; - } - - public SessionTestRunner getTestRunner() { - return testRunner; - } - - public boolean isCrashTest() { - return crashTest; - } - - @Override - public void run(TestResult result) { - Setup localSetup = (Setup) setup.clone(); - localSetup.setEclipseArgument(Setup.APPLICATION, applicationId); - localSetup.setEclipseArgument("testpluginname", pluginId); - localSetup.setEclipseArgument("test", testClass + ':' + method); - getTestRunner().run(getTest(), result, localSetup, crashTest); - } - - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; - } - - public void setCrashTest(boolean crashTest) { - this.crashTest = crashTest; - } - - public void setPluginId(String pluginId) { - this.pluginId = pluginId; - } - - public void setSetup(Setup setup) { - this.setup = setup == null ? null : (Setup) setup.clone(); - } - - public void setTestRunner(SessionTestRunner testRunner) { - this.testRunner = testRunner; - } - - @Override - public String toString() { - return getName() + "(" + getTestClass() + ")"; - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SameSessionTest.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SameSessionTest.java deleted file mode 100644 index 461e25dc61a..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SameSessionTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 junit.framework.*; - -public class SameSessionTest extends TestCase { - - static String lastTestCase; - - public SameSessionTest(String name) { - super(name); - } - - public void test1() { - lastTestCase = getName(); - } - - public void test2() { - assertEquals("test1", lastTestCase); - lastTestCase = getName(); - } - - public void test3() { - assertEquals("test2", lastTestCase); - } - - public static Test suite() { - TestSuite root = new TestSuite("root"); - TestSuite node1 = new TestSuite("node1"); - node1.addTest(new SameSessionTest("test1")); - root.addTest(node1); - TestSuite node2 = new TestSuite("node2"); - root.addTest(node2); - TestSuite node21 = new TestSuite("node21"); - node2.addTest(node21); - node21.addTest(new SameSessionTest("test2")); - node2.addTest(new SameSessionTest("test3")); - return root; - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleCrashTest.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleCrashTest.java deleted file mode 100644 index 161eefefcfb..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleCrashTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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.SessionTestSuite; - -public class SampleCrashTest extends TestCase { - public SampleCrashTest(String methodName) { - super(methodName); - } - - public void test1() { - // Everything is fine... - System.out.println(getName()); - } - - public void test2() { - // crash - System.out.println(getName()); - System.exit(2); - } - - public void test3() { - // Everything is again... - System.out.println(getName()); - } - - public static Test suite() { - SessionTestSuite sameSession = new SessionTestSuite(PI_HARNESS); - sameSession.addTest(new SampleCrashTest("test1")); - sameSession.addCrashTest(new SampleCrashTest("test2")); - sameSession.addTest(new SampleCrashTest("test3")); - return sameSession; - } - -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleSessionTest.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleSessionTest.java deleted file mode 100644 index 6b718761b8c..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleSessionTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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.SessionTestSuite; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; - -public class SampleSessionTest extends TestCase { - public SampleSessionTest(String methodName) { - super(methodName); - } - - public void testBasic1() { - // Everything is fine... - } - - public void testBasic2() { - fail("Breaking the test " + System.currentTimeMillis()); - } - - public void testBasic3() { - throw new RuntimeException("Will break the test as well " + System.currentTimeMillis()); - } - - public void testApplicationStartup() { - PerformanceMeter meter = Performance.getDefault().createPerformanceMeter(getClass().getName() + ".testPerformance"); - try { - meter.stop(); - meter.commit(); - Performance.getDefault().assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -50, 5); - } finally { - meter.dispose(); - } - } - - public static Test suite() { - return new SessionTestSuite(PI_HARNESS, SampleSessionTest.class); - } - -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleTests.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleTests.java deleted file mode 100644 index fd5abb8ff26..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/SampleTests.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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.TestSuite; -import org.eclipse.core.tests.session.SessionTestSuite; - -public class SampleTests extends TestSuite { - public SampleTests() { - addTest(SampleSessionTest.suite()); - addTest(UISampleSessionTest.suite()); - TestSuite another = new SessionTestSuite(PI_HARNESS); - another.addTestSuite(SampleSessionTest.class); - addTest(another); - // these tests should run in the same session (don't add to a non-shared session test suite) - SessionTestSuite shared = new SessionTestSuite(PI_HARNESS); - shared.addTestSuite(SameSessionTest.class); - addTest(shared); - // play with a crash test - addTest(SampleCrashTest.suite()); - } - - public static Test suite() { - return new SampleTests(); - } -} diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/UISampleSessionTest.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/UISampleSessionTest.java deleted file mode 100644 index 1ce0d8024ff..00000000000 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/samples/UISampleSessionTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 java.util.Date; -import junit.framework.Test; -import junit.framework.TestCase; -import org.eclipse.core.tests.session.SessionTestSuite; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceMeter; - -public class UISampleSessionTest extends TestCase { - public UISampleSessionTest(String methodName) { - super(methodName); - } - - /** - * Print a debug message to the console. - * Pre-pend the message with the current date and the name of the current thread. - */ - public static void message(String message) { - StringBuilder buffer = new StringBuilder(); - buffer.append(new Date(System.currentTimeMillis())); - buffer.append(" - ["); //$NON-NLS-1$ - buffer.append(Thread.currentThread().getName()); - buffer.append("] "); //$NON-NLS-1$ - buffer.append(message); - System.out.println(buffer.toString()); - } - - public void testApplicationStartup() { - message("Running " + getName()); - PerformanceMeter meter = Performance.getDefault().createPerformanceMeter(getClass().getName() + ".UIStartup"); - try { - meter.stop(); - meter.commit(); - Performance.getDefault().assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -50, 5); - } finally { - meter.dispose(); - } - } - - public static Test suite() { - SessionTestSuite suite = new SessionTestSuite(PI_HARNESS); - suite.setApplicationId(SessionTestSuite.UI_TEST_APPLICATION); - for (int i = 0; i < 3; i++) - suite.addTest(new UISampleSessionTest("testApplicationStartup")); - return suite; - } - -}