Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime tests: throw dedicated TestException #1670

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Core Tests Runtime
Bundle-SymbolicName: org.eclipse.core.tests.runtime; singleton:=true
Bundle-Version: 3.21.500.qualifier
Bundle-Version: 3.21.600.qualifier
Bundle-Activator: org.eclipse.core.tests.runtime.RuntimeTestsPlugin
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.core.tests.internal.preferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class LogSerializationTest {

static class TestException extends Exception {
private static final long serialVersionUID = 1L;

TestException() {
super();
}
}

private File logFile = null;
Expand Down Expand Up @@ -139,7 +135,16 @@ protected IStatus[] getInterestingMultiStatuses() {
interestingChildren[i] = subArray;
}
int childOff = 0;
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),
return new IStatus[] { new MultiStatus("plugin-id", 1, interestingChildren[childOff++ % len], "message", null),
new MultiStatus("org.foo.bar", 5, interestingChildren[childOff++ % len], "message",
new TestException()),
new MultiStatus("plugin-id", 8, interestingChildren[childOff++ % len], "message", null),
new MultiStatus("plugin-id", 0, interestingChildren[childOff++ % len], "message",
new TestException()),
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),
new MultiStatus("plugin-id", 1, "message", null), new MultiStatus("..", 87326, "", null),};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public void testGetLogLocation() throws IOException {
assertEquals("4.0", initialLocation, Platform.getLogFileLocation());
}

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

final Exception exception = new Exception("PlatformTest.testRunnable: this exception is thrown on purpose as part of the test.");
final Exception exception = new TestException();
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ public boolean shouldRun() {

}

static class TestException extends RuntimeException {
private static final long serialVersionUID = 1L;
}

/**
* Test of an ill-behaving {@link Job#shouldRun()}.
*/
Expand All @@ -463,7 +467,7 @@ protected IStatus run(IProgressMonitor monitor) {

@Override
public boolean shouldRun() {
throw new RuntimeException("Exception thrown on purpose as part of a test");
throw new TestException();
}
}
ShouldRunJob j = new ShouldRunJob();
Expand Down Expand Up @@ -1085,7 +1089,7 @@ public void testJoinFailingListener() throws InterruptedException {
shortJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
throw new RuntimeException("This exception thrown on purpose as part of a test");
throw new TestException();
}
});
final AtomicIntegerArray status = new AtomicIntegerArray(new int[1]);
Expand Down
Loading