Skip to content

Commit 249d98a

Browse files
Jörg Kubitzjukzi
authored andcommitted
runtime tests: throw dedicated TestException
To make it easier to filter test output for unintended exceptions.
1 parent ca5ed8a commit 249d98a

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class LogSerializationTest {
3535

3636
static class TestException extends Exception {
3737
private static final long serialVersionUID = 1L;
38-
39-
TestException() {
40-
super();
41-
}
4238
}
4339

4440
private File logFile = null;
@@ -139,7 +135,16 @@ protected IStatus[] getInterestingMultiStatuses() {
139135
interestingChildren[i] = subArray;
140136
}
141137
int childOff = 0;
142-
return new IStatus[] {new MultiStatus("plugin-id", 1, interestingChildren[childOff++ % len], "message", null), new MultiStatus("org.foo.bar", 5, interestingChildren[childOff++ % len], "message", new NullPointerException()), new MultiStatus("plugin-id", 8, interestingChildren[childOff++ % len], "message", null), new MultiStatus("plugin-id", 0, interestingChildren[childOff++ % len], "message", new IllegalStateException()), new MultiStatus("plugin-id", 65756, interestingChildren[childOff++ % len], "message", null), new MultiStatus(".", 1, interestingChildren[childOff++ % len], "message", null), new MultiStatus("org.foo.blaz", 1, interestingChildren[childOff++ % len], "", null), new MultiStatus("plugin-id", 1, interestingChildren[childOff++ % len], "%$(% 98%(%(*^", null),
138+
return new IStatus[] { new MultiStatus("plugin-id", 1, interestingChildren[childOff++ % len], "message", null),
139+
new MultiStatus("org.foo.bar", 5, interestingChildren[childOff++ % len], "message",
140+
new TestException()),
141+
new MultiStatus("plugin-id", 8, interestingChildren[childOff++ % len], "message", null),
142+
new MultiStatus("plugin-id", 0, interestingChildren[childOff++ % len], "message",
143+
new TestException()),
144+
new MultiStatus("plugin-id", 65756, interestingChildren[childOff++ % len], "message", null),
145+
new MultiStatus(".", 1, interestingChildren[childOff++ % len], "message", null),
146+
new MultiStatus("org.foo.blaz", 1, interestingChildren[childOff++ % len], "", null),
147+
new MultiStatus("plugin-id", 1, interestingChildren[childOff++ % len], "%$(% 98%(%(*^", null),
143148
new MultiStatus("plugin-id", 1, "message", null), new MultiStatus("..", 87326, "", null),};
144149
}
145150

runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public void testGetLogLocation() throws IOException {
142142
assertEquals("4.0", initialLocation, Platform.getLogFileLocation());
143143
}
144144

145+
static class TestException extends Exception {
146+
private static final long serialVersionUID = 1L;
147+
}
145148
@Test
146149
public void testRunnable() {
147150
final List<Throwable> exceptions = new ArrayList<>();
@@ -152,7 +155,7 @@ public void testRunnable() {
152155
ILogListener logListener = (status, plugin) -> collected.add(status);
153156
Platform.addLogListener(logListener);
154157

155-
final Exception exception = new Exception("PlatformTest.testRunnable: this exception is thrown on purpose as part of the test.");
158+
final Exception exception = new TestException();
156159
ISafeRunnable runnable = new ISafeRunnable() {
157160
@Override
158161
public void handleException(Throwable t) {

runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ public boolean shouldRun() {
443443

444444
}
445445

446+
static class TestException extends RuntimeException {
447+
private static final long serialVersionUID = 1L;
448+
}
449+
446450
/**
447451
* Test of an ill-behaving {@link Job#shouldRun()}.
448452
*/
@@ -463,7 +467,7 @@ protected IStatus run(IProgressMonitor monitor) {
463467

464468
@Override
465469
public boolean shouldRun() {
466-
throw new RuntimeException("Exception thrown on purpose as part of a test");
470+
throw new TestException();
467471
}
468472
}
469473
ShouldRunJob j = new ShouldRunJob();
@@ -1085,7 +1089,7 @@ public void testJoinFailingListener() throws InterruptedException {
10851089
shortJob.addJobChangeListener(new JobChangeAdapter() {
10861090
@Override
10871091
public void done(IJobChangeEvent event) {
1088-
throw new RuntimeException("This exception thrown on purpose as part of a test");
1092+
throw new TestException();
10891093
}
10901094
});
10911095
final AtomicIntegerArray status = new AtomicIntegerArray(new int[1]);

0 commit comments

Comments
 (0)