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