use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestTest method testWaitForStartBeforeStart.
/**
* Test calling waitForStart() before the request is started. It should not
* block.
*/
@Test
public void testWaitForStartBeforeStart() throws InterruptedException {
final boolean[] flags = new boolean[4];
TmfEventRequest request = setupTestRequest(flags);
Thread t = new Thread() {
@Override
public void run() {
try {
request.waitForStart();
} catch (InterruptedException e) {
// nothing
}
}
};
t.setPriority(Thread.MAX_PRIORITY);
t.start();
request.start();
t.join();
request.done();
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertTrue("handleCompleted", flags[0]);
assertTrue("handleSuccess", flags[1]);
assertFalse("handleFailure", flags[2]);
assertFalse("handleCancel", flags[3]);
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestTest method testFail.
// ------------------------------------------------------------------------
// fail
// ------------------------------------------------------------------------
@Test
public void testFail() {
final boolean[] flags = new boolean[4];
TmfEventRequest request = setupTestRequest(flags);
request.fail(new IllegalArgumentException("Bad argument"));
final Throwable failCause = request.getFailureCause();
assertTrue("isCompleted", request.isCompleted());
assertTrue("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertNotNull("Cause of failure", failCause);
assertEquals("Cause of failure message", "Bad argument", failCause.getMessage());
assertTrue("handleCompleted", flags[0]);
assertFalse("handleSuccess", flags[1]);
assertTrue("handleFailure", flags[2]);
assertFalse("handleCancel", flags[3]);
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestTest method testDone.
// ------------------------------------------------------------------------
// done
// ------------------------------------------------------------------------
@Test
public void testDone() {
final boolean[] flags = new boolean[4];
TmfEventRequest request = setupTestRequest(flags);
request.done();
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertTrue("handleCompleted", flags[0]);
assertTrue("handleSuccess", flags[1]);
assertFalse("handleFailure", flags[2]);
assertFalse("handleCancel", flags[3]);
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestTest method testWaitForStartAfterDone.
/**
* Test calling waitForStart() after the request has ended. It should not
* block.
*/
@Test
public void testWaitForStartAfterDone() throws InterruptedException {
final boolean[] flags = new boolean[4];
TmfEventRequest request = setupTestRequest(flags);
request.start();
request.done();
request.waitForStart();
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertTrue("handleCompleted", flags[0]);
assertTrue("handleSuccess", flags[1]);
assertFalse("handleFailure", flags[2]);
assertFalse("handleCancel", flags[3]);
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testAddEvent2.
@Test
public void testAddEvent2() {
TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND, 0);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
coalescedRequest.addRequest(req1);
coalescedRequest.addRequest(req2);
assertEquals("addRequest", 0, coalescedRequest.getIndex());
assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
}
Aggregations