Search in sources :

Example 41 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest 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 42 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest 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 43 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest 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 44 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest 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)

Example 45 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfExperimentTest method testCancel.

// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
    final int nbEvents = NB_EVENTS;
    final int limit = BLOCK_SIZE;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {

        int nbRead = 0;

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
            if (++nbRead == limit) {
                cancel();
            }
        }

        @Override
        public void handleCancel() {
            if (requestedEvents.size() < limit) {
                System.out.println("aie");
            }
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", limit, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isCancelled", request.isCancelled());
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Aggregations

TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)51 Test (org.junit.Test)36 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)31 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)29 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 Vector (java.util.Vector)15 TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)15 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)11 TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)8 ArrayList (java.util.ArrayList)5 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NonNull (org.eclipse.jdt.annotation.NonNull)3 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 TmfCollapseFilter (org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter)2 ITmfFilter (org.eclipse.tracecompass.tmf.core.filter.ITmfFilter)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 ITmfSyncSequenceDiagramEvent (org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent)2