Search in sources :

Example 1 with TmfCoalescedEventRequest

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

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

the class TmfCoalescedEventRequestTest method setupTestRequest.

private TmfCoalescedEventRequest setupTestRequest(final boolean[] flags) {
    TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0) {

        @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 : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)

Example 3 with TmfCoalescedEventRequest

use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest 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 4 with TmfCoalescedEventRequest

use of org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest 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 5 with TmfCoalescedEventRequest

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

the class TmfCoalescedEventRequestTest method setUp.

// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
@Before
public void setUp() {
    fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
    fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 100, ExecutionType.FOREGROUND, 0);
    fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND, 0);
    fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND, 0);
    fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
    fRequestCount = fRequest1c.getRequestId() + 1;
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Before(org.junit.Before)

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