lttng: More luna annotation updates
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / trace / TmfCheckpointIndexTest.java
index a888bf872f937ee69e985137be075c75ae1d926a..c727241a7bc7204e148bddd97ea939b4725ed85b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,36 +9,41 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Adapted for TMF Trace Model 1.0
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.trace;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
 import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Test suite for the TmfCheckpointIndexTest class.
  */
-@SuppressWarnings("nls")
-public class TmfCheckpointIndexTest extends TestCase {
+@SuppressWarnings("javadoc")
+public class TmfCheckpointIndexTest {
 
     // ------------------------------------------------------------------------
     // Variables
@@ -55,19 +60,13 @@ public class TmfCheckpointIndexTest extends TestCase {
     // Housekeeping
     // ------------------------------------------------------------------------
 
-    public TmfCheckpointIndexTest(final String name) throws Exception {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() {
         setupTrace(DIRECTORY + File.separator + TEST_STREAM);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    @After
+    public void tearDown() {
         fTrace.dispose();
         fTrace = null;
         fEmptyTrace.dispose();
@@ -78,16 +77,16 @@ public class TmfCheckpointIndexTest extends TestCase {
     // Helper classes
     // ------------------------------------------------------------------------
 
-    private class TestIndexer extends TmfCheckpointIndexer<ITmfTrace<ITmfEvent>> {
-        @SuppressWarnings({ "unchecked", "rawtypes" })
+    private static class TestIndexer extends TmfCheckpointIndexer {
+        @SuppressWarnings({ })
         public TestIndexer(TestTrace testTrace) {
-            super((ITmfTrace) testTrace, BLOCK_SIZE);
+            super(testTrace, BLOCK_SIZE);
         }
-        @SuppressWarnings({ "unchecked", "rawtypes" })
+        @SuppressWarnings({ })
         public TestIndexer(EmptyTestTrace testTrace) {
-            super((ITmfTrace) testTrace, BLOCK_SIZE);
+            super(testTrace, BLOCK_SIZE);
         }
-        public List<TmfCheckpoint> getCheckpoints() {
+        public List<ITmfCheckpoint> getCheckpoints() {
             return getTraceIndex();
         }
     }
@@ -124,7 +123,7 @@ public class TmfCheckpointIndexTest extends TestCase {
                 final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
                 final File test = new File(FileLocator.toFileURL(location).toURI());
                 fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
-                fTrace.indexTrace();
+                fTrace.indexTrace(true);
             } catch (final TmfTraceException e) {
                 e.printStackTrace();
             } catch (final URISyntaxException e) {
@@ -136,7 +135,7 @@ public class TmfCheckpointIndexTest extends TestCase {
 
         if (fEmptyTrace == null) {
             fEmptyTrace = new EmptyTestTrace();
-            fEmptyTrace.indexTrace();
+            fEmptyTrace.indexTrace(true);
         }
     }
 
@@ -144,7 +143,8 @@ public class TmfCheckpointIndexTest extends TestCase {
     // Verify checkpoints
     // ------------------------------------------------------------------------
 
-    public void testTmfTraceIndexing() throws Exception {
+    @Test
+    public void testTmfTraceIndexing() {
         assertEquals("getCacheSize",   BLOCK_SIZE, fTrace.getCacheSize());
         assertEquals("getTraceSize",   NB_EVENTS,  fTrace.getNbEvents());
         assertEquals("getRange-start", 1,          fTrace.getTimeRange().getStartTime().getValue());
@@ -152,14 +152,14 @@ public class TmfCheckpointIndexTest extends TestCase {
         assertEquals("getStartTime",   1,          fTrace.getStartTime().getValue());
         assertEquals("getEndTime",     NB_EVENTS,  fTrace.getEndTime().getValue());
 
-        List<TmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+        List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
         int pageSize = fTrace.getCacheSize();
         assertTrue("Checkpoints exist",  checkpoints != null);
         assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
 
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
-            TmfCheckpoint checkpoint = checkpoints.get(i);
+            ITmfCheckpoint checkpoint = checkpoints.get(i);
             TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
             ITmfEvent event = fTrace.parseEvent(context);
             assertTrue(context.getRank() == i * pageSize);
@@ -167,22 +167,23 @@ public class TmfCheckpointIndexTest extends TestCase {
         }
     }
 
-    public void testEmptyTmfTraceIndexing() throws Exception {
+    @Test
+    public void testEmptyTmfTraceIndexing() {
         assertEquals("getCacheSize",   ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
         assertEquals("getTraceSize",   0,  fEmptyTrace.getNbEvents());
-        assertEquals("getRange-start", TmfTimestamp.BIG_CRUNCH, fEmptyTrace.getTimeRange().getStartTime());
+        assertEquals("getRange-start", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
         assertEquals("getRange-end",   TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
-        assertEquals("getStartTime",   TmfTimestamp.BIG_CRUNCH, fEmptyTrace.getStartTime());
+        assertEquals("getStartTime",   TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
         assertEquals("getEndTime",     TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
 
-        List<TmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
+        List<ITmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
         int pageSize = fEmptyTrace.getCacheSize();
         assertTrue("Checkpoints exist",  checkpoints != null);
         assertEquals("Checkpoints size", 0, checkpoints.size());
 
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
-            TmfCheckpoint checkpoint = checkpoints.get(i);
+            ITmfCheckpoint checkpoint = checkpoints.get(i);
             TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
             ITmfEvent event = fEmptyTrace.parseEvent(context);
             assertTrue(context.getRank() == i * pageSize);
This page took 0.026539 seconds and 5 git commands to generate.