Skip to content

Commit a563cbe

Browse files
committed
Prune useless parts of o.e.ui.tests
A lot of no longer needed legacy from JUnit 3.x time is simply cluttering the codebase now.
1 parent 21a20ee commit a563cbe

File tree

14 files changed

+59
-112
lines changed

14 files changed

+59
-112
lines changed

tests/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/RcpTestSuite.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@
2727
WorkbenchWindowConfigurerTest.class, ActionBarConfigurerTest.class, IWorkbenchPageTest.class,
2828
WorkbenchSaveRestoreStateTest.class, WorkbenchListenerTest.class, WorkbenchTest.class })
2929
public class RcpTestSuite {
30-
public RcpTestSuite() {
31-
}
3230
}

tests/org.eclipse.ui.tests.rcp/RCP Test Suite.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
3434
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
3535
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
36-
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JRE for JavaSE-17"/>
36+
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
3737
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ui.tests.rcp.RcpTestSuite"/>
3838
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ui.tests.rcp"/>
3939
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/autotests/XmlUtil.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
package org.eclipse.ui.tests.autotests;
1515

1616
import java.io.File;
17-
import java.io.FileInputStream;
18-
import java.io.FileNotFoundException;
1917
import java.io.FileOutputStream;
2018
import java.io.IOException;
2119
import java.io.InputStream;
2220
import java.io.InputStreamReader;
2321
import java.io.OutputStreamWriter;
2422
import java.net.URL;
2523

26-
import org.eclipse.core.runtime.IStatus;
2724
import org.eclipse.core.runtime.Status;
2825
import org.eclipse.ui.IMemento;
2926
import org.eclipse.ui.WorkbenchException;
@@ -44,40 +41,23 @@ public static IMemento read(URL toRead) throws WorkbenchException {
4441
try {
4542
return read(toRead.openStream());
4643
} catch (IOException e) {
47-
throw new WorkbenchException(new Status(IStatus.ERROR,
48-
TestPlugin.getDefault().getBundle().getSymbolicName(),
49-
IStatus.OK, null, e));
50-
}
51-
}
52-
53-
public static IMemento read(File toRead) throws WorkbenchException {
54-
FileInputStream input;
55-
try {
56-
input = new FileInputStream(toRead);
57-
return read(input);
58-
} catch (FileNotFoundException e) {
59-
throw new WorkbenchException(new Status(IStatus.ERROR,
60-
TestPlugin.getDefault().getBundle().getSymbolicName(),
61-
IStatus.OK, null, e));
44+
throw new WorkbenchException(Status.error(TestPlugin.getDefault().getBundle().getSymbolicName(), e));
6245
}
6346
}
6447

6548
public static void write(File file, XMLMemento data) throws WorkbenchException {
6649

67-
FileOutputStream output;
6850
try {
6951
file.getParentFile().mkdirs();
7052
file.delete();
7153
file.createNewFile();
7254

73-
output = new FileOutputStream(file);
74-
try (OutputStreamWriter writer = new OutputStreamWriter(output)) {
55+
try (FileOutputStream output = new FileOutputStream(file);
56+
OutputStreamWriter writer = new OutputStreamWriter(output)) {
7557
data.save(writer);
7658
}
7759
} catch (IOException e) {
78-
throw new WorkbenchException(new Status(IStatus.ERROR,
79-
TestPlugin.getDefault().getBundle().getSymbolicName(),
80-
IStatus.OK, e.toString(), e));
60+
throw new WorkbenchException(Status.error(TestPlugin.getDefault().getBundle().getSymbolicName(), e));
8161
}
8262
}
8363
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package org.eclipse.ui.tests.commands;
1717

1818
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertThrows;
1920
import static org.junit.Assert.assertTrue;
20-
import static org.junit.Assert.fail;
2121

2222
import org.eclipse.core.commands.Command;
2323
import org.eclipse.core.commands.ExecutionException;
@@ -36,15 +36,12 @@
3636
import org.junit.Before;
3737
import org.junit.FixMethodOrder;
3838
import org.junit.Test;
39-
import org.junit.runner.RunWith;
40-
import org.junit.runners.JUnit4;
4139
import org.junit.runners.MethodSorters;
4240

4341
/**
4442
* @since 3.5
4543
* @author Prakash G.R.
4644
*/
47-
@RunWith(JUnit4.class)
4845
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4946
public class ToggleStateTest {
5047

@@ -61,9 +58,7 @@ public void doSetUp() throws Exception {
6158
// Note: this and all other tests are numbered because they must run in a
6259
// specific order.
6360
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=369660
64-
// The old junit3 implementation used a custom suite(). Because junit4 provides
65-
// less options on test run order the tests are now numbered and run in method
66-
// name order.
61+
// Tests are now numbered and run in method name order.
6762
@Test
6863
public void test01DefaultValues() throws Exception {
6964

@@ -85,16 +80,10 @@ public void test01DefaultValues() throws Exception {
8580

8681
@Test
8782
public void test02ExceptionThrown() throws Exception {
88-
8983
Command command3 = commandService.getCommand("org.eclipse.ui.tests.toggleStateCommand3");
90-
try {
91-
handlerService.executeCommand(command3.getId(), null);
92-
fail("Command3 doesn't have any state. An exception must be thrown from the handler, when trying to change that");
93-
} catch (Exception e) {
94-
if(!(e instanceof ExecutionException)) {
95-
throw e;
96-
}
97-
}
84+
assertThrows(
85+
"Command3 doesn't have any state. An exception must be thrown from the handler, when trying to change that",
86+
ExecutionException.class, () -> handlerService.executeCommand(command3.getId(), null));
9887
}
9988

10089
static class MyUIElement extends UIElement{

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_262032.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ protected IStatus run(IProgressMonitor monitor) {
116116
j.join();
117117
tb1.waitForStatus(TestBarrier2.STATUS_WAIT_FOR_DONE);
118118
assertEquals(Status.OK_STATUS, j.getResult());
119-
} catch (InterruptedException e) {fail();}
119+
} catch (InterruptedException e) {
120+
fail(e.getMessage());
121+
}
120122
}
121123

122124
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/NestedSyncExecDeadlockTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ public void resourceChanged(IResourceChangeEvent event) {
5252

5353
private final IWorkspace workspace = ResourcesPlugin.getWorkspace();
5454

55-
public NestedSyncExecDeadlockTest() {
56-
super();
57-
}
58-
5955
public void doTest(final long timeToSleep) throws Exception {
6056
ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell());
6157
dialog.run(true, false, new WorkspaceModifyOperation() {

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/NoFreezeWhileWaitingForRuleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testWaiting() {
9393
blockingJob.join();
9494
} catch (InterruptedException e) {
9595
Thread.currentThread().interrupt();
96-
fail();
96+
fail(e.getMessage());
9797
}
9898
assertFalse("Timeout reached, blocking occurred!", ruleMonitor.isCanceled());
9999
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForLock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void run() {
141141
}
142142
//if we waited too long, fail the test
143143
if (System.currentTimeMillis() - waitStart > 60000) {
144-
assertTrue("Deadlock occurred", false);
144+
fail("Deadlock occurred");
145145
}
146146
}
147147
//if we get here, the test succeeded

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/TestBug105491.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ public void threadChange(Thread thread) {
7474

7575
private final IWorkspace workspace = ResourcesPlugin.getWorkspace();
7676

77-
public TestBug105491() {
78-
super();
79-
}
80-
8177
/**
8278
* Performs the test
8379
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/TestBug108162.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.concurrency;
1515

16-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.Assert.fail;
1717

1818
import java.lang.reflect.InvocationTargetException;
1919

@@ -47,10 +47,6 @@ public void execute(final IProgressMonitor pm) {
4747

4848
private final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4949

50-
public TestBug108162() {
51-
super();
52-
}
53-
5450
/**
5551
* Performs the test
5652
*/
@@ -61,7 +57,7 @@ public void testBug() throws CoreException {
6157
try {
6258
dialog.run(true, false, new LockAcquiringOperation());
6359
// should not succeed
64-
assertTrue("Should not get here", false);
60+
fail("Should not get here");
6561
} catch (InvocationTargetException | InterruptedException | IllegalStateException e) {
6662
// this failure is expected because it tried to fork and block while owning a
6763
// lock.

0 commit comments

Comments
 (0)