Search in sources :

Example 16 with TmfCoalescedEventRequest

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());
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Test(org.junit.Test)

Example 17 with TmfCoalescedEventRequest

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));
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 18 with TmfCoalescedEventRequest

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());
}
Also used : TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 19 with TmfCoalescedEventRequest

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));
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 20 with TmfCoalescedEventRequest

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());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Aggregations

TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)22 Test (org.junit.Test)14 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)8 TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)3 Method (java.lang.reflect.Method)2 LinkedList (java.util.LinkedList)2 IllformedLocaleException (java.util.IllformedLocaleException)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)1 ExecutionType (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)1 Before (org.junit.Before)1