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());
}
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;
}
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());
}
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());
}
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;
}
Aggregations