Search in sources :

Example 36 with TmfEventRequest

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

the class TmfEventRequestTest method testWaitForStartBeforeStart.

/**
 * Test calling waitForStart() before the request is started. It should not
 * block.
 */
@Test
public void testWaitForStartBeforeStart() throws InterruptedException {
    final boolean[] flags = new boolean[4];
    TmfEventRequest request = setupTestRequest(flags);
    Thread t = new Thread() {

        @Override
        public void run() {
            try {
                request.waitForStart();
            } catch (InterruptedException e) {
            // nothing
            }
        }
    };
    t.setPriority(Thread.MAX_PRIORITY);
    t.start();
    request.start();
    t.join();
    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 37 with TmfEventRequest

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

the class TmfEventRequestTest method testFail.

// ------------------------------------------------------------------------
// fail
// ------------------------------------------------------------------------
@Test
public void testFail() {
    final boolean[] flags = new boolean[4];
    TmfEventRequest request = setupTestRequest(flags);
    request.fail(new IllegalArgumentException("Bad argument"));
    final Throwable failCause = request.getFailureCause();
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertNotNull("Cause of failure", failCause);
    assertEquals("Cause of failure message", "Bad argument", failCause.getMessage());
    assertTrue("handleCompleted", flags[0]);
    assertFalse("handleSuccess", flags[1]);
    assertTrue("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 38 with TmfEventRequest

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

the class TmfEventRequestTest method testDone.

// ------------------------------------------------------------------------
// done
// ------------------------------------------------------------------------
@Test
public void testDone() {
    final boolean[] flags = new boolean[4];
    TmfEventRequest request = setupTestRequest(flags);
    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 39 with TmfEventRequest

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

the class TmfEventRequestTest method testWaitForStartAfterDone.

/**
 * Test calling waitForStart() after the request has ended. It should not
 * block.
 */
@Test
public void testWaitForStartAfterDone() throws InterruptedException {
    final boolean[] flags = new boolean[4];
    TmfEventRequest request = setupTestRequest(flags);
    request.start();
    request.done();
    request.waitForStart();
    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 40 with TmfEventRequest

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

the class TmfCoalescedEventRequestTest method testAddEvent2.

@Test
public void testAddEvent2() {
    TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND, 0);
    TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
    TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 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());
}
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

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