Search in sources :

Example 1 with TestJob

use of org.eclipse.core.tests.harness.TestJob in project eclipse.platform.runtime by eclipse.

the class Bug_320329 method testBug.

public void testBug() {
    // 5 seconds
    Job j1 = new TestJob("job1", 100, 50);
    Job j2 = new TestJob("job2");
    ISchedulingRule rule1 = new IdentityRule();
    ISchedulingRule rule2 = new IdentityRule();
    j1.setRule(rule1);
    j2.setRule(MultiRule.combine(rule1, rule2));
    j1.schedule();
    j2.schedule();
    // busy wait here
    Job.getJobManager().beginRule(rule2, new NullProgressMonitor());
    // Clean up
    Job.getJobManager().endRule(rule2);
    waitForCompletion(j1, 6000);
    waitForCompletion(j2, 6000);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TestJob(org.eclipse.core.tests.harness.TestJob) TestJob(org.eclipse.core.tests.harness.TestJob)

Example 2 with TestJob

use of org.eclipse.core.tests.harness.TestJob in project eclipse.platform.runtime by eclipse.

the class Bug_129551 method testBug.

public void testBug() {
    ISchedulingRule rule = new IdentityRule();
    BugJob job = new BugJob();
    job.setRule(rule);
    TestJob other = new TestJob("bug_129551_other", 1, 1);
    other.setRule(rule);
    job.schedule();
    other.schedule();
    // wait until the first job is about to run
    barrier.waitForStatus(TestBarrier.STATUS_RUNNING);
    // wait to ensure the other job is blocked
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        fail("4.99", e);
    }
    // let the first job go
    barrier.setStatus(TestBarrier.STATUS_START);
    barrier.waitForStatus(TestBarrier.STATUS_DONE);
    // check for failure
    if (failure[0] != null)
        fail(failure[0].getMessage());
    // tell the job not to sleep this time around
    shouldSleep[0] = false;
    job.wakeUp();
    waitForCompletion(job);
    waitForCompletion(other);
}
Also used : TestJob(org.eclipse.core.tests.harness.TestJob) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Aggregations

TestJob (org.eclipse.core.tests.harness.TestJob)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)1