use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent 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());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfMipmapStateProviderTest method init.
/**
* Startup code, build a state system with n attributes always going up
* linearly
*/
@BeforeClass
public static void init() {
TmfMipmapStateProviderStub mmp = new TmfMipmapStateProviderStub(RESOLUTION, Type.LONG);
IStateHistoryBackend be = StateHistoryBackendFactory.createInMemoryBackend(SSID, 0);
ITmfStateSystemBuilder ssb = StateSystemFactory.newStateSystem(be);
mmp.assignTargetStateSystem(ssb);
ssq = ssb;
for (long time = START_TIME; time <= END_TIME; time += INTERVAL) {
long value = time / INTERVAL;
ITmfEvent event = mmp.createEvent(time, value);
mmp.processEvent(event);
}
mmp.dispose();
ssq.waitUntilBuilt();
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TimeOffsetTest method testClearOffset.
@Test
public void testClearOffset() throws TmfTraceException {
ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
TimestampTransformFactory.setTimestampTransform(fResource, tt);
TimestampTransformFactory.setTimestampTransform(fResource, null);
ITmfTrace trace = createAndIndexTrace();
final TmfContext context = (TmfContext) trace.seekEvent(0);
ITmfEvent event = trace.getNext(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
event = trace.getNext(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
trace.dispose();
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent 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.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfExperimentTest method testGetNextAfterSeekingOnRank_1.
@Test
public void testGetNextAfterSeekingOnRank_1() {
final long INITIAL_RANK = 0L;
final int NB_READS = 20;
// On lower bound, returns the first event (rank = 0)
final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK);
validateContextRanks(context);
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
event = fExperiment.getNext(context);
assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue());
assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank());
}
// Make sure we stay positioned
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
validateContextRanks(context);
}
Aggregations