use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testFail.
// ------------------------------------------------------------------------
// fail
// ------------------------------------------------------------------------
@Test
public void testFail() {
final boolean[] crFlags = new boolean[4];
TmfCoalescedEventRequest request = setupTestRequest(crFlags);
TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
request.fail(new IllformedLocaleException("Hi"));
// Validate the coalescing request
assertTrue("isCompleted", request.isCompleted());
assertTrue("isFailed", request.isFailed());
final Throwable failCause = request.getFailureCause();
assertNotNull("Cause of failure", failCause);
assertEquals("Cause of failure message", "Hi", failCause.getMessage());
assertFalse("isCancelled", request.isCancelled());
assertTrue("handleCompleted", crFlags[0]);
assertFalse("handleSuccess", crFlags[1]);
assertTrue("handleFailure", crFlags[2]);
assertFalse("handleCancel", crFlags[3]);
// Validate the first coalesced request
assertTrue("isCompleted", subRequest1.isCompleted());
assertTrue("isFailed", subRequest1.isFailed());
assertFalse("isCancelled", subRequest1.isCancelled());
// Validate the second coalesced request
assertTrue("isCompleted", subRequest2.isCompleted());
assertTrue("isFailed", subRequest2.isFailed());
assertFalse("isCancelled", subRequest2.isCancelled());
}
use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testDone.
// ------------------------------------------------------------------------
// done
// ------------------------------------------------------------------------
@Test
public void testDone() {
// Test request
final boolean[] crFlags = new boolean[4];
TmfCoalescedEventRequest request = setupTestRequest(crFlags);
TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
request.done();
// Validate the coalescing request
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertTrue("handleCompleted", crFlags[0]);
assertTrue("handleSuccess", crFlags[1]);
assertFalse("handleFailure", crFlags[2]);
assertFalse("handleCancel", crFlags[3]);
// Validate the first coalesced request
assertTrue("isCompleted", subRequest1.isCompleted());
assertFalse("isFailed", subRequest1.isFailed());
assertFalse("isCancelled", subRequest1.isCancelled());
// Validate the second coalesced request
assertTrue("isCompleted", subRequest2.isCompleted());
assertFalse("isFailed", subRequest2.isFailed());
assertFalse("isCancelled", subRequest2.isCancelled());
}
use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testAddEvent1.
// ------------------------------------------------------------------------
// addEvent
// ------------------------------------------------------------------------
@Test
public void testAddEvent1() {
TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND, 0);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 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());
}
use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.
the class TmfEventRequestIntegrationTest method testSingleRequestException.
/**
* Test the behavior of a failed request
*
* @throws InterruptedException
* The test timed out
*/
@Test
public void testSingleRequestException() throws InterruptedException {
TmfTrace trace = fTrace;
TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {
@Override
public void handleData(@NonNull ITmfEvent data) {
throw new IllegalArgumentException();
}
};
trace.sendRequest(requestFail);
requestFail.waitForCompletion();
assertTrue(requestFail.isCompleted());
assertFalse(requestFail.isCancelled());
assertTrue(requestFail.isFailed());
}
use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.
the class TmfEventRequestTest method testTmfEventRequestWithDependencyLevel.
@Test
public void testTmfEventRequestWithDependencyLevel() {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200, ExecutionType.FOREGROUND, 1);
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
assertEquals("getIndex", 0, request.getIndex());
assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
assertEquals("getDependencyLevel", 1, request.getDependencyLevel());
}
Aggregations