diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/RunInSeparateThreadRule.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/RunInSeparateThreadRule.java deleted file mode 100644 index ddb190ca25a..00000000000 --- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/RunInSeparateThreadRule.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Vector Informatik GmbH 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 - * - *******************************************************************************/ -package org.eclipse.ant.tests.ui; - -import java.util.concurrent.CompletableFuture; - -import org.eclipse.swt.widgets.Display; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * Runs the test in a separate thread and spins readAndDisplay in the UI thread. - * Terminates with the exception of the separate thread in case one occurred. - */ -class RunInSeparateThreadRule implements TestRule { - - @Override - public Statement apply(final Statement base, final Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - final Display display = Display.getCurrent(); - CompletableFuture future = evaluateAsync(base); - future.thenRun(display::wake); - while (!future.isDone()) { - doReadAndDispatch(display); - } - Throwable thrownException = future.get().throwable; - if (thrownException != null) { - throw thrownException; - } - } - }; - } - - private static CompletableFuture evaluateAsync(final Statement statement) { - return CompletableFuture.supplyAsync(() -> { - try { - statement.evaluate(); - return new Result(null); - } catch (Throwable exception) { - return new Result(exception); - } - }); - } - - private static void doReadAndDispatch(final Display display) { - try { - if (!display.readAndDispatch()) { - display.sleep(); - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - private record Result(Throwable throwable) { - } - -} diff --git a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF index 49b864dac24..4c6fda9cf94 100644 --- a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF @@ -22,7 +22,6 @@ Require-Bundle: org.eclipse.ui.ide;resolution:=optional, org.eclipse.ui.workbench.texteditor;resolution:=optional, org.eclipse.ui.editors;resolution:=optional, org.apache.ant;bundle-version="1.9.2", - org.junit, org.eclipse.core.resources, org.eclipse.jdt.core, org.eclipse.jdt.launching, diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/TestAgainExceptionRule.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/TestAgainExceptionRule.java deleted file mode 100644 index 6059299ed7f..00000000000 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/TestAgainExceptionRule.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Vector Informatik GmbH 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 - * - *******************************************************************************/ -package org.eclipse.ant.tests.ui.testplugin; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * Executes the test again for a defined number of retries after in case an - * {@link TestAgainException} is thrown. - */ -class TestAgainExceptionRule implements TestRule { - - private final int retryCount; - - public TestAgainExceptionRule(int retryCount) { - this.retryCount = retryCount; - } - - @Override - public Statement apply(final Statement base, final Description description) { - return new Statement() { - - @Override - public void evaluate() throws Throwable { - for (int attempt = 0; attempt < retryCount; attempt++) { - try { - base.evaluate(); - return; - } catch (TestAgainException e) { - String errorMessage = String.format("%s failed attempt %s. Re-testing.", //$NON-NLS-1$ - description.getDisplayName(), attempt); - System.out.println(errorMessage); - e.printStackTrace(); - } - } - } - }; - } - -}