Search in sources :

Example 1 with TmfEventRequestStub

use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testFail.

// ------------------------------------------------------------------------
// fail
// ------------------------------------------------------------------------
@Test
public void testFail() {
    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.fail(new IllformedLocaleException("Hi"));
    // Validate the coalescing request
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isFailed", request.isFailed());
    final Throwable failCause = request.getFailureCause();
    assertNotNull("Cause of failure", failCause);
    assertEquals("Cause of failure message", "Hi", failCause.getMessage());
    assertFalse("isCancelled", request.isCancelled());
    assertTrue("handleCompleted", crFlags[0]);
    assertFalse("handleSuccess", crFlags[1]);
    assertTrue("handleFailure", crFlags[2]);
    assertFalse("handleCancel", crFlags[3]);
    // Validate the first coalesced request
    assertTrue("isCompleted", subRequest1.isCompleted());
    assertTrue("isFailed", subRequest1.isFailed());
    assertFalse("isCancelled", subRequest1.isCancelled());
    // Validate the second coalesced request
    assertTrue("isCompleted", subRequest2.isCompleted());
    assertTrue("isFailed", subRequest2.isFailed());
    assertFalse("isCancelled", subRequest2.isCancelled());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) IllformedLocaleException(java.util.IllformedLocaleException) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 2 with TmfEventRequestStub

use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testDone.

// ------------------------------------------------------------------------
// done
// ------------------------------------------------------------------------
@Test
public void testDone() {
    // Test request
    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.done();
    // Validate the coalescing request
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertTrue("handleCompleted", crFlags[0]);
    assertTrue("handleSuccess", crFlags[1]);
    assertFalse("handleFailure", crFlags[2]);
    assertFalse("handleCancel", crFlags[3]);
    // Validate the first coalesced request
    assertTrue("isCompleted", subRequest1.isCompleted());
    assertFalse("isFailed", subRequest1.isFailed());
    assertFalse("isCancelled", subRequest1.isCancelled());
    // Validate the second coalesced request
    assertTrue("isCompleted", subRequest2.isCompleted());
    assertFalse("isFailed", subRequest2.isFailed());
    assertFalse("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 3 with TmfEventRequestStub

use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testAddEvent1.

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

Example 4 with TmfEventRequestStub

use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.

the class TmfEventRequestIntegrationTest method testSingleRequestException.

/**
 * Test the behavior of a failed request
 *
 * @throws InterruptedException
 *             The test timed out
 */
@Test
public void testSingleRequestException() throws InterruptedException {
    TmfTrace trace = fTrace;
    TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {

        @Override
        public void handleData(@NonNull ITmfEvent data) {
            throw new IllegalArgumentException();
        }
    };
    trace.sendRequest(requestFail);
    requestFail.waitForCompletion();
    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) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 5 with TmfEventRequestStub

use of org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub in project tracecompass by tracecompass.

the class TmfEventRequestTest method testTmfEventRequestWithDependencyLevel.

@Test
public void testTmfEventRequestWithDependencyLevel() {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200, ExecutionType.FOREGROUND, 1);
    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", 100, request.getNbRequested());
    assertFalse("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertEquals("getNbRead", 0, request.getNbRead());
    assertEquals("getDependencyLevel", 1, 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)

Aggregations

TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)16 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)15 Test (org.junit.Test)14 TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)8 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)6 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)4 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)4 NonNull (org.eclipse.jdt.annotation.NonNull)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)2 IllformedLocaleException (java.util.IllformedLocaleException)1 Before (org.junit.Before)1