import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
-import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
/**
* Test suite for the TmfTrace class.
*/
-@SuppressWarnings("nls")
+@SuppressWarnings({"nls","javadoc"})
public class TmfTraceTest extends TestCase {
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
- public TmfTraceTest(final String name) throws Exception {
+ /**
+ * @param name the test name
+ */
+ public TmfTraceTest(final String name) {
super(name);
}
// Helper functions
// ------------------------------------------------------------------------
- private TmfTraceStub setupTrace(final String path) {
+ private static TmfTraceStub setupTrace(final String path) {
if (fTrace == null) {
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
// Constructors
// ------------------------------------------------------------------------
- public void testStandardConstructor() throws Exception {
+ @SuppressWarnings("null")
+ public void testStandardConstructor() throws TmfTraceException {
TmfTraceStub trace = null;
File testfile = null;
try {
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
}
- public void testStandardConstructorCacheSize() throws Exception {
+ @SuppressWarnings("null")
+ public void testStandardConstructorCacheSize() throws TmfTraceException {
TmfTraceStub trace = null;
File testfile = null;
try {
fail("IOException");
}
- assertFalse ("Open trace", trace == null);
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
}
- public void testFullConstructor() throws Exception {
+ @SuppressWarnings("null")
+ public void testFullConstructor() throws TmfTraceException {
TmfTraceStub trace = null;
File testfile = null;
try {
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
}
- public void testLiveTraceConstructor() throws Exception {
+ @SuppressWarnings("null")
+ public void testLiveTraceConstructor() throws TmfTraceException {
TmfTraceStub trace = null;
File testfile = null;
final long interval = 100;
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testCopyConstructor() throws Exception {
+ @SuppressWarnings("null")
+ public void testCopyConstructor() throws TmfTraceException {
TmfTraceStub original = null;
TmfTraceStub trace = null;
File testfile = null;
// Trace initialization
// ------------------------------------------------------------------------
- public void testInitializeNullPath() throws Exception {
+ public void testInitializeNullPath() {
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
fail("TmfTrace.initialize() - wrong exception thrown");
}
}
-
- public void testInitializeSimplePath() throws Exception {
+
+ public void testInitializeSimplePath() {
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
} catch (Exception e) {
fail("TmfTrace.initialize() - Exception thrown");
}
-
- assertFalse ("Open trace", trace == null);
+
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", path, trace.getPath());
assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
}
- public void testInitializeNormalPath() throws Exception {
+ public void testInitializeNormalPath() {
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
} catch (Exception e) {
fail("TmfTrace.initialize() - Exception thrown");
}
-
- assertFalse ("Open trace", trace == null);
+
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getPath", path, trace.getPath());
assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
}
- public void testInitTrace() throws Exception {
+ public void testInitTrace() throws URISyntaxException, IOException, TmfTraceException, InterruptedException {
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
- assertFalse ("Open trace", trace == null);
assertNull ("getType", trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertTrue("validate", trace.validate(null, testfile.getPath()));
// InitTrace and wait for indexing completion...
- trace.initTrace(null, testfile.getPath(), TmfEvent.class);
+ trace.initTrace(null, testfile.toURI().getPath(), TmfEvent.class);
trace.indexTrace();
int nbSecs = 0;
while (trace.getNbEvents() < NB_EVENTS && nbSecs < 10) {
fail("indexing");
}
- assertFalse ("Open trace", trace == null);
assertEquals("getType", TmfEvent.class, trace.getType());
assertNull ("getResource", trace.getResource());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
// Set/Get streaming interval
// ------------------------------------------------------------------------
- public void testSetStreamingInterval() throws Exception {
+ public void testSetStreamingInterval() throws TmfTraceException {
final TmfTraceStub trace = new TmfTraceStub(fTrace);
long interval = 0;
interval = 100;
trace.setStreamingInterval(interval);
assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
-
+
interval = -1;
trace.setStreamingInterval(interval);
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
-
+
interval = 0;
trace.setStreamingInterval(interval);
assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
-
+
trace.dispose();
}
// Set/Get time range
// ------------------------------------------------------------------------
- public void testSetTimeRange() throws Exception {
+ public void testSetTimeRange() throws TmfTraceException {
final TmfTraceStub trace = new TmfTraceStub(fTrace);
trace.indexTrace();
trace.dispose();
}
- public void testSetStartTime() throws Exception {
+ public void testSetStartTime() throws TmfTraceException {
final TmfTraceStub trace = new TmfTraceStub(fTrace);
trace.indexTrace();
trace.dispose();
}
- public void testSetEndTime() throws Exception {
+ public void testSetEndTime() throws TmfTraceException {
final TmfTraceStub trace = new TmfTraceStub(fTrace);
trace.indexTrace();
trace.dispose();
}
- public void testSetNbEvents() throws Exception {
+ public void testSetNbEvents() throws TmfTraceException {
final TmfTraceStub trace = new TmfTraceStub(fTrace);
trace.indexTrace();
// seekEvent on location (note: does not reliably set the rank)
// ------------------------------------------------------------------------
- public void testSeekEventOnCacheBoundary() throws Exception {
+ public void testSeekEventOnCacheBoundary() {
// Position trace at event rank 0
ITmfContext context = fTrace.seekEvent(0);
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
- public void testSeekEventNotOnCacheBoundary() throws Exception {
+ public void testSeekEventNotOnCacheBoundary() {
// Position trace at event rank 9
ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
- public void testSeekEventOutOfScope() throws Exception {
+ public void testSeekEventOutOfScope() {
// Position trace at beginning
ITmfContext tmpContext = fTrace.seekEvent(0);
// seekEvent on timestamp (note: does not reliably set the rank)
// ------------------------------------------------------------------------
- public void testSeekEventOnNullTimestamp() throws Exception {
+ public void testSeekEventOnNullTimestamp() {
// Position trace at event rank 0
ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null);
assertEquals("Event rank", 0, context.getRank());
}
- public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
+ public void testSeekEventOnTimestampOnCacheBoundary() {
// Position trace at event rank 0
ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0));
assertEquals("Event rank", 4001, context.getRank());
}
- public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
+ public void testSeekEventOnTimestampNotOnCacheBoundary() {
// Position trace at event rank 1
ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0));
assertEquals("Event rank", 4501, context.getRank());
}
- public void testSeekEventOnTimestampOutOfScope() throws Exception {
+ public void testSeekEventOnTimestampOutOfScope() {
// Position trace at beginning
ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0));
// seekEvent on rank
// ------------------------------------------------------------------------
- public void testSeekEventOnNegativeRank() throws Exception {
+ public void testSeekEventOnNegativeRank() {
// Position trace at event rank 0
ITmfContext context = fTrace.seekEvent(-1);
assertEquals("Event rank", 0, context.getRank());
}
- public void testSeekOnRankOnCacheBoundary() throws Exception {
+ public void testSeekOnRankOnCacheBoundary() {
// On lower bound, returns the first event (ts = 1)
ITmfContext context = fTrace.seekEvent(0);
assertEquals("Event rank", 4001, context.getRank());
}
- public void testSeekOnRankNotOnCacheBoundary() throws Exception {
+ public void testSeekOnRankNotOnCacheBoundary() {
// Position trace at event rank 9
ITmfContext context = fTrace.seekEvent(9);
assertEquals("Event rank", 4501, context.getRank());
}
- public void testSeekEventOnRankOutOfScope() throws Exception {
+ public void testSeekEventOnRankOutOfScope() {
// Position trace at beginning
ITmfContext context = fTrace.seekEvent(-1);
// parseEvent - make sure parseEvent doesn't update the context
// ------------------------------------------------------------------------
- public void testParseEvent() throws Exception {
+ public void testParseEvent() {
final int NB_READS = 20;
}
// ------------------------------------------------------------------------
- // readNextEvent - updates the context
+ // getNext - updates the context
// ------------------------------------------------------------------------
- public void testReadNextEvent() throws Exception {
+ public void testGetNextAfteSeekingOnTS_1() {
+ final long INITIAL_TS = 1;
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 1)
- final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0));
+ final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
event = fTrace.getNext(context);
- assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
- assertEquals("Event rank", i + 1, context.getRank());
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
}
// Make sure we stay positioned
event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
- assertEquals("Event rank", NB_READS, context.getRank());
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+ }
+
+ public void testGetNextAfteSeekingOnTS_2() {
+
+ final long INITIAL_TS = 2;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 500)
+ final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+ }
+
+ public void testGetNextAfteSeekingOnTS_3() {
+
+ final long INITIAL_TS = 500;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 500)
+ final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+ }
+
+ 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 = fTrace.seekEvent(INITIAL_RANK);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.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 = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+ }
+
+ public void testGetNextAfterSeekingOnRank_2() {
+
+ final long INITIAL_RANK = 1L;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (rank = 0)
+ final ITmfContext context = fTrace.seekEvent(INITIAL_RANK);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.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 = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+ }
+
+ public void testGetNextAfterSeekingOnRank_3() {
+
+ final long INITIAL_RANK = 500L;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (rank = 0)
+ final ITmfContext context = fTrace.seekEvent(INITIAL_RANK);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.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 = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+ }
+
+ public void testGetNextAfterSeekingOnLocation_1() {
+
+ final ITmfLocation INITIAL_LOC = null;
+ final long INITIAL_TS = 1;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 1)
+ final ITmfContext context = fTrace.seekEvent(INITIAL_LOC);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+ }
+
+ public void testGetNextAfterSeekingOnLocation_2() {
+
+ final ITmfLocation INITIAL_LOC = fTrace.seekEvent(1L).getLocation();
+ final long INITIAL_TS = 2;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 501)
+ final ITmfContext context = fTrace.seekEvent(INITIAL_LOC);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ }
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ }
+
+ public void testGetNextAfterSeekingOnLocation_3() {
+
+ final ITmfLocation INITIAL_LOC = fTrace.seekEvent(500L).getLocation();
+ final long INITIAL_TS = 501;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 501)
+ final ITmfContext context = fTrace.seekEvent(INITIAL_LOC);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fTrace.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ }
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ }
+
+ public void testGetNextLocation() {
+ ITmfContext context1 = fTrace.seekEvent(0);
+ fTrace.getNext(context1);
+ ITmfLocation location = context1.getLocation();
+ ITmfEvent event1 = fTrace.getNext(context1);
+ ITmfContext context2 = fTrace.seekEvent(location);
+ ITmfEvent event2 = fTrace.getNext(context2);
+ assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue());
+ }
+
+ public void testGetNextEndLocation() {
+ ITmfContext context1 = fTrace.seekEvent(fTrace.getNbEvents() - 1);
+ fTrace.getNext(context1);
+ ITmfLocation location = context1.getLocation();
+ ITmfContext context2 = fTrace.seekEvent(location);
+ ITmfEvent event = fTrace.getNext(context2);
+ assertNull("Event", event);
}
// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- public void testProcessEventRequestForAllEvents() throws Exception {
+ @SuppressWarnings("hiding")
+ public void testProcessEventRequestForAllEvents() throws InterruptedException {
final int BLOCK_SIZE = 1;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
}
}
- @SuppressWarnings("unchecked")
- public void testProcessEventRequestForNbEvents() throws Exception {
+ @SuppressWarnings("hiding")
+ public void testProcessEventRequestForNbEvents() throws InterruptedException {
final int BLOCK_SIZE = 100;
final int NB_EVENTS = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
}
}
- @SuppressWarnings("unchecked")
- public void testProcessEventRequestForSomeEvents() throws Exception {
+ @SuppressWarnings("hiding")
+ public void testProcessEventRequestForSomeEvents() throws InterruptedException {
final int BLOCK_SIZE = 1;
final long startTime = 100;
final int NB_EVENTS = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
}
}
- @SuppressWarnings("unchecked")
- public void testProcessEventRequestForOtherEvents() throws Exception {
+ @SuppressWarnings("hiding")
+ public void testProcessEventRequestForOtherEvents() throws InterruptedException {
final int BLOCK_SIZE = 1;
final int startIndex = 99;
final long startTime = 100;
final int NB_EVENTS = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
}
}
- @SuppressWarnings("unchecked")
- public void testProcessDataRequestForSomeEvents() throws Exception {
+ @SuppressWarnings("hiding")
+ public void testProcessDataRequestForSomeEvents() throws InterruptedException {
final int startIndex = 100;
final int NB_EVENTS = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, startIndex, NB_EVENTS) {
+ final TmfDataRequest request = new TmfDataRequest(TmfEvent.class, startIndex, NB_EVENTS) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
// cancel
// ------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- public void testCancel() throws Exception {
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ public void testCancel() throws InterruptedException {
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
int nbRead = 0;
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
if (++nbRead == BLOCK_SIZE) {
}
}
};
- final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ final ITmfDataProvider[] providers = TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
// toString
// ------------------------------------------------------------------------
- public void testDefaultTmfTraceStub() throws Exception {
+ public void testDefaultTmfTraceStub() {
assertFalse ("Open trace", fTrace == null);
assertEquals("getType", TmfEvent.class, fTrace.getType());
assertNull ("getResource", fTrace.getResource());
assertEquals("toString", expected, fTrace.toString());
}
-}
\ No newline at end of file
+}