Search in sources :

Example 1 with BaseTask

use of com.linkedin.parseq.BaseTask in project parseq by linkedin.

the class TestTaskToTrace method testUnfinishedTrace.

@Test
public void testUnfinishedTrace() throws InterruptedException {
    // Used to ensure that the task has started running
    final CountDownLatch cdl = new CountDownLatch(1);
    final SettablePromise<Void> promise = Promises.settable();
    final Task<Void> task = new BaseTask<Void>() {

        @Override
        public Promise<Void> run(final Context context) throws Exception {
            cdl.countDown();
            // Return a promise that won't be satisfied until after out test
            return promise;
        }
    };
    getEngine().run(task);
    assertTrue(cdl.await(5, TimeUnit.SECONDS));
    logTracingResults("TestTaskToTrace.testUnfinishedTrace", task);
    verifyShallowTrace(task);
    // Finish task
    promise.done(null);
}
Also used : Context(com.linkedin.parseq.Context) BaseTask(com.linkedin.parseq.BaseTask) CountDownLatch(java.util.concurrent.CountDownLatch) BaseEngineTest(com.linkedin.parseq.BaseEngineTest) Test(org.testng.annotations.Test)

Aggregations

BaseEngineTest (com.linkedin.parseq.BaseEngineTest)1 BaseTask (com.linkedin.parseq.BaseTask)1 Context (com.linkedin.parseq.Context)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.testng.annotations.Test)1