Make the TmfLocation final and get rid of clone()
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / trace / TmfTraceTest.java
index 7716e6d0d47faf68e30c2b942dfac4441258e014..143dc5ff3fc4e0305de66a0b2edb3280812829e3 100644 (file)
@@ -23,8 +23,8 @@ import junit.framework.TestCase;
 
 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;
@@ -35,6 +35,7 @@ import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
 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;
@@ -43,7 +44,7 @@ import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 /**
  * Test suite for the TmfTrace class.
  */
-@SuppressWarnings("nls")
+@SuppressWarnings({"nls","javadoc"})
 public class TmfTraceTest extends TestCase {
 
     // ------------------------------------------------------------------------
@@ -62,7 +63,10 @@ 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);
     }
 
@@ -83,7 +87,7 @@ public class TmfTraceTest extends TestCase {
     // 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);
@@ -105,7 +109,8 @@ public class TmfTraceTest extends TestCase {
     // Constructors
     // ------------------------------------------------------------------------
 
-    public void testStandardConstructor() throws Exception {
+    @SuppressWarnings("null")
+    public void testStandardConstructor() throws TmfTraceException {
         TmfTraceStub trace = null;
         File testfile = null;
         try {
@@ -134,7 +139,8 @@ public class TmfTraceTest extends TestCase {
         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 {
@@ -173,7 +179,6 @@ public class TmfTraceTest extends TestCase {
             fail("IOException");
         }
 
-        assertFalse ("Open trace", trace == null);
         assertEquals("getType",  TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
         assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
@@ -188,7 +193,8 @@ public class TmfTraceTest extends TestCase {
         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 {
@@ -217,7 +223,8 @@ public class TmfTraceTest extends TestCase {
         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;
@@ -247,8 +254,8 @@ public class TmfTraceTest extends TestCase {
         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;
@@ -293,7 +300,7 @@ public class TmfTraceTest extends TestCase {
     // Trace initialization
     // ------------------------------------------------------------------------
 
-    public void testInitializeNullPath() throws Exception {
+    public void testInitializeNullPath() {
 
         // Instantiate an "empty" trace
         final TmfTraceStub trace = new TmfTraceStub();
@@ -307,8 +314,8 @@ public class TmfTraceTest extends TestCase {
             fail("TmfTrace.initialize() - wrong exception thrown");
         }
     }
-        
-    public void testInitializeSimplePath() throws Exception {
+
+    public void testInitializeSimplePath() {
 
         // Instantiate an "empty" trace
         final TmfTraceStub trace = new TmfTraceStub();
@@ -320,8 +327,7 @@ public class TmfTraceTest extends TestCase {
         } 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());
@@ -336,7 +342,7 @@ public class TmfTraceTest extends TestCase {
         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();
@@ -349,8 +355,7 @@ public class TmfTraceTest extends TestCase {
         } 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());
@@ -365,12 +370,11 @@ public class TmfTraceTest extends TestCase {
         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());
@@ -389,7 +393,7 @@ public class TmfTraceTest extends TestCase {
         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) {
@@ -400,7 +404,6 @@ public class TmfTraceTest extends TestCase {
             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());
@@ -418,7 +421,7 @@ public class TmfTraceTest extends TestCase {
     // Set/Get streaming interval
     // ------------------------------------------------------------------------
 
-    public void testSetStreamingInterval() throws Exception {
+    public void testSetStreamingInterval() throws TmfTraceException {
         final TmfTraceStub trace = new TmfTraceStub(fTrace);
 
         long interval = 0;
@@ -427,15 +430,15 @@ public class TmfTraceTest extends TestCase {
         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();
     }
 
@@ -443,7 +446,7 @@ public class TmfTraceTest extends TestCase {
     // Set/Get time range
     // ------------------------------------------------------------------------
 
-    public void testSetTimeRange() throws Exception {
+    public void testSetTimeRange() throws TmfTraceException {
         final TmfTraceStub trace = new TmfTraceStub(fTrace);
         trace.indexTrace();
 
@@ -461,7 +464,7 @@ public class TmfTraceTest extends TestCase {
         trace.dispose();
     }
 
-    public void testSetStartTime() throws Exception {
+    public void testSetStartTime() throws TmfTraceException {
         final TmfTraceStub trace = new TmfTraceStub(fTrace);
         trace.indexTrace();
 
@@ -479,7 +482,7 @@ public class TmfTraceTest extends TestCase {
         trace.dispose();
     }
 
-    public void testSetEndTime() throws Exception {
+    public void testSetEndTime() throws TmfTraceException {
         final TmfTraceStub trace = new TmfTraceStub(fTrace);
         trace.indexTrace();
 
@@ -497,7 +500,7 @@ public class TmfTraceTest extends TestCase {
         trace.dispose();
     }
 
-    public void testSetNbEvents() throws Exception {
+    public void testSetNbEvents() throws TmfTraceException {
         final TmfTraceStub trace = new TmfTraceStub(fTrace);
         trace.indexTrace();
 
@@ -522,7 +525,7 @@ public class TmfTraceTest extends TestCase {
     // 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);
@@ -568,7 +571,7 @@ public class TmfTraceTest extends TestCase {
         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));
@@ -623,7 +626,7 @@ public class TmfTraceTest extends TestCase {
         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);
@@ -651,7 +654,7 @@ public class TmfTraceTest extends TestCase {
     // 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);
@@ -662,7 +665,7 @@ public class TmfTraceTest extends TestCase {
         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));
@@ -701,7 +704,7 @@ public class TmfTraceTest extends TestCase {
         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));
@@ -764,7 +767,7 @@ public class TmfTraceTest extends TestCase {
         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));
@@ -795,7 +798,7 @@ public class TmfTraceTest extends TestCase {
     // seekEvent on rank
     // ------------------------------------------------------------------------
 
-    public void testSeekEventOnNegativeRank() throws Exception {
+    public void testSeekEventOnNegativeRank() {
 
         // Position trace at event rank 0
         ITmfContext context = fTrace.seekEvent(-1);
@@ -806,7 +809,7 @@ public class TmfTraceTest extends TestCase {
         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);
@@ -845,7 +848,7 @@ public class TmfTraceTest extends TestCase {
         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);
@@ -896,7 +899,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event rank", 4501, context.getRank());
     }
 
-    public void testSeekEventOnRankOutOfScope() throws Exception {
+    public void testSeekEventOnRankOutOfScope() {
 
         // Position trace at beginning
         ITmfContext context = fTrace.seekEvent(-1);
@@ -927,7 +930,7 @@ public class TmfTraceTest extends TestCase {
     // parseEvent - make sure parseEvent doesn't update the context
     // ------------------------------------------------------------------------
 
-    public void testParseEvent() throws Exception {
+    public void testParseEvent() {
 
         final int NB_READS = 20;
 
@@ -969,48 +972,243 @@ public class TmfTraceTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // 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();
 
@@ -1025,21 +1223,21 @@ public class TmfTraceTest extends TestCase {
         }
     }
 
-    @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();
 
@@ -1054,22 +1252,22 @@ public class TmfTraceTest extends TestCase {
         }
     }
 
-    @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();
 
@@ -1084,23 +1282,23 @@ public class TmfTraceTest extends TestCase {
         }
     }
 
-    @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();
 
@@ -1115,20 +1313,20 @@ public class TmfTraceTest extends TestCase {
         }
     }
 
-    @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();
 
@@ -1147,15 +1345,14 @@ public class TmfTraceTest extends TestCase {
     // 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) {
@@ -1163,7 +1360,7 @@ public class TmfTraceTest extends TestCase {
                 }
             }
         };
-        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();
 
@@ -1176,7 +1373,7 @@ public class TmfTraceTest extends TestCase {
     // toString
     // ------------------------------------------------------------------------
 
-    public void testDefaultTmfTraceStub() throws Exception {
+    public void testDefaultTmfTraceStub() {
         assertFalse ("Open trace", fTrace == null);
         assertEquals("getType",  TmfEvent.class, fTrace.getType());
         assertNull  ("getResource", fTrace.getResource());
@@ -1197,4 +1394,4 @@ public class TmfTraceTest extends TestCase {
         assertEquals("toString", expected, fTrace.toString());
     }
 
-}
\ No newline at end of file
+}
This page took 0.06037 seconds and 5 git commands to generate.