Skip to content
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 @@ -15,7 +15,7 @@
package org.eclipse.core.tests.runtime.jobs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.time.Duration;
import org.eclipse.core.internal.jobs.JobListeners;
Expand Down Expand Up @@ -100,6 +100,6 @@ protected final void assertNoTimeoutOccurred() throws Exception {
int jobListenerTimeout = JobListeners.getJobListenerTimeout();
JobListeners.resetJobListenerTimeout();
int defaultTimeout = JobListeners.getJobListenerTimeout();
assertEquals("See logfile for TimeoutException to get details.", defaultTimeout, jobListenerTimeout);
assertEquals(defaultTimeout, jobListenerTimeout, "See logfile for TimeoutException to get details.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
package org.eclipse.core.tests.runtime.jobs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -94,7 +95,7 @@ public IProgressMonitor monitorFor(IProgressMonitor monitor) {
passedMonitor.set(monitor);
manager.beginRule(rule, monitor);
try {
assertTrue("Monitor not created for " + monitor, createdMonitor.get());
assertTrue(createdMonitor.get(), "Monitor not created for " + monitor);
} finally {
manager.endRule(rule);
}
Expand Down Expand Up @@ -129,8 +130,8 @@ public void testComplexRuleStarting() {
//all jobs should be running
//the status flag should be set to START
for (int i = 0; i < status.length(); i++) {
assertEquals("1." + i, Job.RUNNING, jobs[i].getState());
assertEquals("2." + i, TestBarrier2.STATUS_START, status.get(i));
assertEquals(Job.RUNNING, jobs[i].getState(), i);
assertEquals(TestBarrier2.STATUS_START, status.get(i), i);
}

//the order that the jobs will be executed
Expand All @@ -150,9 +151,9 @@ public void testComplexRuleStarting() {
}

//the first job should be running, the remaining jobs should be waiting
assertEquals("3.0", TestBarrier2.STATUS_RUNNING, status.get(order[0]));
assertEquals("3.0", TestBarrier2.STATUS_BLOCKED, status.get(order[1]));
assertEquals("3.0", TestBarrier2.STATUS_BLOCKED, status.get(order[2]));
assertEquals(TestBarrier2.STATUS_RUNNING, status.get(order[0]));
assertEquals(TestBarrier2.STATUS_BLOCKED, status.get(order[1]));
assertEquals(TestBarrier2.STATUS_BLOCKED, status.get(order[2]));

//let the first job finish
status.set(order[0], TestBarrier2.STATUS_WAIT_FOR_DONE);
Expand Down Expand Up @@ -187,9 +188,9 @@ public void testComplexRuleStarting() {

for (int i = 0; i < jobs.length; i++) {
//check that the final status of all jobs is correct
assertEquals("9." + i, TestBarrier2.STATUS_DONE, status.get(i));
assertEquals("10." + i, Job.NONE, jobs[i].getState());
assertEquals("11." + i, IStatus.OK, jobs[i].getResult().getSeverity());
assertEquals(TestBarrier2.STATUS_DONE, status.get(i), i);
assertEquals(Job.NONE, jobs[i].getState(), i);
assertEquals(IStatus.OK, jobs[i].getResult().getSeverity(), i);
}
}

Expand All @@ -215,10 +216,10 @@ public void testSimpleRuleStarting() {
TestBarrier2.waitForStatus(status, 0, TestBarrier2.STATUS_START);
TestBarrier2.waitForStatus(status, 1, TestBarrier2.STATUS_START);

assertEquals("2.0", Job.RUNNING, jobs[0].getState());
assertEquals("2.1", Job.RUNNING, jobs[1].getState());
assertEquals("2.2", TestBarrier2.STATUS_START, status.get(0));
assertEquals("2.3", TestBarrier2.STATUS_START, status.get(1));
assertEquals(Job.RUNNING, jobs[0].getState());
assertEquals(Job.RUNNING, jobs[1].getState());
assertEquals(TestBarrier2.STATUS_START, status.get(0));
assertEquals(TestBarrier2.STATUS_START, status.get(1));

//the order of execution of the jobs (by their index in the status array)
int first = 0;
Expand All @@ -237,8 +238,8 @@ public void testSimpleRuleStarting() {

//only the first job should be running
//the other job should be blocked by the beginRule method
assertEquals("3.1", TestBarrier2.STATUS_RUNNING, status.get(first));
assertEquals("3.2", TestBarrier2.STATUS_WAIT_FOR_RUN, status.get(second));
assertEquals(TestBarrier2.STATUS_RUNNING, status.get(first));
assertEquals(TestBarrier2.STATUS_WAIT_FOR_RUN, status.get(second));

//let the first job finish execution and call endRule
//the second thread will then become unblocked
Expand All @@ -251,8 +252,8 @@ public void testSimpleRuleStarting() {
TestBarrier2.waitForStatus(status, second, TestBarrier2.STATUS_RUNNING);

//the first job is done, the second job is executing
assertEquals("4.1", TestBarrier2.STATUS_DONE, status.get(first));
assertEquals("4.2", TestBarrier2.STATUS_RUNNING, status.get(second));
assertEquals(TestBarrier2.STATUS_DONE, status.get(first));
assertEquals(TestBarrier2.STATUS_RUNNING, status.get(second));

//let the second job finish execution
status.set(second, TestBarrier2.STATUS_WAIT_FOR_DONE);
Expand All @@ -261,8 +262,8 @@ public void testSimpleRuleStarting() {
TestBarrier2.waitForStatus(status, second, TestBarrier2.STATUS_DONE);

//both jobs are done now
assertEquals("5.1", TestBarrier2.STATUS_DONE, status.get(first));
assertEquals("5.2", TestBarrier2.STATUS_DONE, status.get(second));
assertEquals(TestBarrier2.STATUS_DONE, status.get(first));
assertEquals(TestBarrier2.STATUS_DONE, status.get(second));

//flip the order of execution of the jobs
int temp = first;
Expand All @@ -275,12 +276,12 @@ public void testSimpleRuleStarting() {
waitForEnd(jobs[first]);

//check that the final status of both jobs is correct
assertEquals("6.1", TestBarrier2.STATUS_DONE, status.get(0));
assertEquals("6.2", TestBarrier2.STATUS_DONE, status.get(1));
assertEquals("6.3", Job.NONE, jobs[0].getState());
assertEquals("6.4", Job.NONE, jobs[1].getState());
assertEquals("6.5", IStatus.OK, jobs[0].getResult().getSeverity());
assertEquals("6.6", IStatus.OK, jobs[1].getResult().getSeverity());
assertEquals(TestBarrier2.STATUS_DONE, status.get(0));
assertEquals(TestBarrier2.STATUS_DONE, status.get(1));
assertEquals(Job.NONE, jobs[0].getState());
assertEquals(Job.NONE, jobs[1].getState());
assertEquals(IStatus.OK, jobs[0].getResult().getSeverity());
assertEquals(IStatus.OK, jobs[1].getResult().getSeverity());
}

@Test
Expand Down Expand Up @@ -374,8 +375,8 @@ protected IStatus run(IProgressMonitor monitor) {
job.setRule(rule1);
job.schedule();
waitForEnd(job);
assertNotNull("1.0", exception[0]);
assertTrue("1.1", exception[0].getMessage().indexOf("does not match outer scope rule") > 0);
assertNotNull(exception[0]);
assertTrue(exception[0].getMessage().indexOf("does not match outer scope rule") > 0);
}

@Test
Expand Down Expand Up @@ -501,7 +502,7 @@ public void testSimpleOtherThreadAccess() {
//ignore
}
//the thread should be dead now
assertTrue("1.0", !endingThread.isAlive());
assertFalse(endingThread.isAlive());

//should be able to end the rule from this thread
manager.endRule(rule1);
Expand All @@ -526,7 +527,7 @@ public void testSimpleOtherThreadAccess() {
//ignore
}
//the thread should be dead now
assertTrue("2." + i, !t.isAlive());
assertFalse(t.isAlive(), i + "");
}

//try to end the rules when they are all started
Expand All @@ -541,7 +542,7 @@ public void testSimpleOtherThreadAccess() {
//ignore
}
//the thread should be dead now
assertTrue("3." + i, !t.isAlive());
assertFalse(t.isAlive(), i + "");
}

//try to end the rules after manager.endRule() has been called
Expand All @@ -557,7 +558,7 @@ public void testSimpleOtherThreadAccess() {
//ignore
}
//the thread should be dead now
assertTrue("4." + i, !t.isAlive());
assertFalse(t.isAlive(), i + "");
}
}

Expand All @@ -575,7 +576,7 @@ private void waitForEnd(Job job) {
}
Thread.yield();
//sanity test to avoid hanging tests
assertTrue("Timeout waiting for job to end", i++ < 100);
assertTrue(i++ < 100, "Timeout waiting for job to end");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.core.runtime.jobs.ILock;
import org.eclipse.core.runtime.jobs.Job;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void run() {

// Now attempt acquire lock1 with an integer delay
try {
assertTrue(!lock1.acquire(60 * 1000));
assertFalse(lock1.acquire(60 * 1000));
} catch (InterruptedException e) {
tb2.setStatus(INTERRUPTED);
}
Expand Down Expand Up @@ -110,7 +111,7 @@ public void run() {
// We should now be able to acquire lock1 without difficulty
assertTrue(lock1.acquire(1000));
// T2 should still hold the lock2
assertTrue(!lock2.acquire(0));
assertFalse(lock2.acquire(0));

tb2.setStatus(RELEASE_LOCK);
assertTrue(lock2.acquire(1000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.IProgressMonitor;
Expand Down Expand Up @@ -83,8 +83,8 @@ protected IStatus run(IProgressMonitor monitor) {
if (exceptionInJob.get() != null) {
throw exceptionInJob.get();
}
assertEquals(blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called", CLEARED,
blocked[0]);
assertEquals(CLEARED, blocked[0],
blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called");
}

/**
Expand Down Expand Up @@ -147,8 +147,8 @@ protected IStatus run(IProgressMonitor monitor) {
if (exceptionInJob.get() != null) {
throw exceptionInJob.get();
}
assertEquals(blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called", CLEARED,
blocked[0]);
assertEquals(CLEARED, blocked[0],
blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called");
}

/**
Expand Down Expand Up @@ -207,7 +207,8 @@ protected IStatus run(IProgressMonitor monitor) {
if (exceptionInJob.get() != null) {
throw exceptionInJob.get();
}
assertEquals(blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called", CLEARED, blocked[0]);
assertEquals(CLEARED, blocked[0],
blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called");
}

/**
Expand Down Expand Up @@ -263,7 +264,8 @@ protected IStatus run(IProgressMonitor monitor) {
if (exceptionInJob.get() != null) {
throw exceptionInJob.get();
}
assertEquals(blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called", CLEARED, blocked[0]);
assertEquals(CLEARED, blocked[0],
blocked[0] == UNSET ? "setBlocked never called" : "clearBlocked never called");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.concurrent.Semaphore;
import org.eclipse.core.runtime.IProgressMonitor;
Expand Down Expand Up @@ -43,7 +43,7 @@ public void testBug() throws Exception {
Thread.sleep(2000L);

//lock should now be free if C is finished
assertTrue("Failed: Job C was not run", m_jobBStopHint.tryAcquire());
assertTrue(m_jobBStopHint.tryAcquire(), "Failed: Job C was not run");
}

private void scheduleJobA(long delay) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package org.eclipse.core.tests.runtime.jobs;

import static org.eclipse.core.tests.runtime.RuntimeTestsPlugin.PI_RUNTIME_TESTS;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -23,7 +23,6 @@
import java.io.ObjectOutputStream;
import java.nio.file.Files;
import java.util.concurrent.atomic.AtomicIntegerArray;
import junit.framework.AssertionFailedError;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand Down Expand Up @@ -93,7 +92,7 @@ protected IStatus run(IProgressMonitor monitor) {
fakeBuild.join();
assertTrue(job.getResult() != null && job.getResult().isOK());
assertTrue(fakeBuild.getResult() != null && fakeBuild.getResult().isOK());
} catch (AssertionFailedError e) {
} catch (AssertionError e) {
// the test failed so there is a deadlock, but this deadlock would prevent us
// from reporting test results; serialize the error to a helper file and
// exit JVM to "resolve" deadlock
Expand All @@ -119,9 +118,9 @@ public void testVerifyResult() throws IOException, ClassNotFoundException {
// if the file does not exist, there was no deadlock so the whole test pass
if (file.exists()) {
try {
AssertionFailedError e;
AssertionError e;
try (ObjectInputStream stream = new ObjectInputStream(Files.newInputStream(file.toPath()))) {
e = (AssertionFailedError) stream.readObject();
e = (AssertionError) stream.readObject();
}
throw e;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -39,7 +39,7 @@ public void testWaitingThreadJob() {
j.setRule(rootRule);
j.schedule();
waitForCompletion(j);
assertFalse("Job was blocked", j.wasBlocked());
assertFalse(j.wasBlocked(), "Job was blocked");
}

class ShouldNotBeBlockedJob extends Job {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testCancelSchedule() throws InterruptedException {
job.cancel();
job.schedule();

assertTrue("Job should start after schedule. Iteration " + i, startedLatch.await(5, TimeUnit.SECONDS));
assertTrue(startedLatch.await(5, TimeUnit.SECONDS), "Job should start after schedule. Iteration " + i);

// A sequence of cancellations and rescheduling that is not expected to affect
// further operations.
Expand All @@ -97,7 +97,7 @@ public void testCancelSchedule() throws InterruptedException {
job.schedule();

job.cancel();
assertTrue("Job should stop after cancellation. Iteration " + i, job.join(5000, null));
assertTrue(job.join(5000, null), "Job should stop after cancellation. Iteration " + i);

}
} finally {
Expand Down Expand Up @@ -126,8 +126,8 @@ public void testReportDoneOncePerSchedule() throws InterruptedException {
// Job post-processing may happen after it is switched to NONE state
// join() alone is not enough
Thread.sleep(200);
assertEquals("Job should be completed once per schedule.", eventCount.scheduledCount.get(),
eventCount.doneCount.get());
assertEquals(eventCount.scheduledCount.get(), eventCount.doneCount.get(),
"Job should be completed once per schedule.");

} finally {
job.cancelWithoutRelyingOnFramework = true;
Expand Down
Loading
Loading