Search in sources :

Example 11 with TmfEventRequest

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

the class TmfEventRequestTest method testTmfEventRequestTimeRange.

@Test
public void testTmfEventRequestTimeRange() {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range);
    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", ITmfEventRequest.ALL_DATA, request.getNbRequested());
    assertFalse("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertEquals("getNbRead", 0, request.getNbRead());
    assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 12 with TmfEventRequest

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

the class TmfEventRequestTest method testWaitForStartAfterStart.

// ------------------------------------------------------------------------
// waitForStart
// ------------------------------------------------------------------------
/**
 * Test calling waitForStart() after the request has already been started.
 * It should not block.
 */
@Test
public void testWaitForStartAfterStart() throws InterruptedException {
    final boolean[] flags = new boolean[4];
    TmfEventRequest request = setupTestRequest(flags);
    request.start();
    request.waitForStart();
    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]);
}
Also used : ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 13 with TmfEventRequest

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

the class TmfEventRequestTest method setupTestRequest.

private static TmfEventRequest setupTestRequest(final boolean[] flags) {
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 100, 200) {

        @Override
        public void handleCompleted() {
            super.handleCompleted();
            flags[0] = true;
        }

        @Override
        public void handleSuccess() {
            super.handleSuccess();
            flags[1] = true;
        }

        @Override
        public void handleFailure() {
            super.handleFailure();
            flags[2] = true;
        }

        @Override
        public void handleCancel() {
            super.handleCancel();
            flags[3] = true;
        }
    };
    return request;
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)

Example 14 with TmfEventRequest

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

the class TmfExperimentTest method testProcessRequestForAllEvents.

@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
    final int nbEvents = ITmfEventRequest.ALL_DATA;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final long nbExpectedEvents = NB_EVENTS;
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < nbExpectedEvents; i++) {
        assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
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)

Example 15 with TmfEventRequest

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

the class TmfMultiTraceExperimentTest 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();
            }
        }
    };
    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) 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