use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testTmfCoalescedEventRequestIndexNbEventsBlocksize.
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
@Test
public void testTmfCoalescedEventRequestIndexNbEventsBlocksize() {
TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
assertEquals("getRequestId", fRequestCount++, request.getRequestId());
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
assertEquals("getRange", range1, request.getRange());
assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
}
use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testIsCompatible.
// ------------------------------------------------------------------------
// isCompatible
// ------------------------------------------------------------------------
@Test
public void testIsCompatible() {
TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200);
assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
assertTrue("isCompatible", coalescedRequest.isCompatible(req3));
}
use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestIntegrationTest method testRequestException.
/**
* Test the behavior of multiple coalesced requests when one fails
*
* @throws InterruptedException
* The test timed out
*/
@Test
public void testRequestException() throws InterruptedException {
TmfTrace trace = fTrace;
TmfCoalescedEventRequest allRequests = new TmfCoalescedEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0);
TmfEventRequest requestOk = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0);
requestOk.setProviderFilter(trace);
allRequests.addRequest(requestOk);
TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {
@Override
public void handleData(@NonNull ITmfEvent data) {
throw new IllegalArgumentException();
}
};
requestFail.setProviderFilter(trace);
allRequests.addRequest(requestFail);
trace.sendRequest(allRequests);
requestOk.waitForCompletion();
requestFail.waitForCompletion();
assertTrue(requestOk.isCompleted());
assertFalse(requestOk.isCancelled());
assertFalse(requestOk.isFailed());
assertTrue(requestFail.isCompleted());
assertFalse(requestFail.isCancelled());
assertTrue(requestFail.isFailed());
}
use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testIsCompatibleDependency.
@Test
public void testIsCompatibleDependency() {
TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 1);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200, ExecutionType.FOREGROUND, 0);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 2000, ExecutionType.FOREGROUND, 1);
TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200, ExecutionType.FOREGROUND, 2);
assertFalse("isCompatible", coalescedRequest.isCompatible(req1));
assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
assertFalse("isCompatible", coalescedRequest.isCompatible(req3));
coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
assertFalse("isCompatible", coalescedRequest.isCompatible(req2));
assertFalse("isCompatible", coalescedRequest.isCompatible(req3));
}
use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testCancel.
// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() {
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.cancel();
// Validate the coalescing request
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertTrue("isCancelled", request.isCancelled());
assertTrue("handleCompleted", crFlags[0]);
assertFalse("handleSuccess", crFlags[1]);
assertFalse("handleFailure", crFlags[2]);
assertTrue("handleCancel", crFlags[3]);
// Validate the first coalesced request
assertTrue("isCompleted", subRequest1.isCompleted());
assertFalse("isFailed", subRequest1.isFailed());
assertTrue("isCancelled", subRequest1.isCancelled());
// Validate the second coalesced request
assertTrue("isCompleted", subRequest2.isCompleted());
assertFalse("isFailed", subRequest2.isFailed());
assertTrue("isCancelled", subRequest2.isCancelled());
}
Aggregations