ctf: Depend on the tracecompass-test-traces project
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.core.tests / src / org / eclipse / tracecompass / tmf / ctf / core / tests / context / CtfTmfContextTest.java
index 1e1bba68e11b277ad14ae1a6b25b9b8b93e4905e..eb1ca690549058bb3bd1dab10493f391c354dda1 100644 (file)
@@ -16,16 +16,15 @@ package org.eclipse.tracecompass.tmf.ctf.core.tests.context;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
 
 import java.util.ArrayList;
 
-import org.eclipse.core.resources.IResource;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.ctf.core.context.CtfTmfContext;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -37,7 +36,7 @@ import org.junit.Test;
  */
 public class CtfTmfContextTest {
 
-    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
+    private static final @NonNull CtfTestTrace testTrace = CtfTestTrace.KERNEL;
     private static final long begin = 1332170682440133097L; /*
                                                              * Trace start time
                                                              */
@@ -55,16 +54,20 @@ public class CtfTmfContextTest {
 
     /**
      * Pre-test initialization
-     *
-     * @throws TmfTraceException
-     *             If the trace couldn't be init'ed, which shouldn't happen.
      */
     @Before
-    public void setUp() throws TmfTraceException {
-        assumeTrue(testTrace.exists());
-        trace = new CtfTmfTrace();
-        String path = testTrace.getPath();
-        trace.initTrace((IResource) null, path, CtfTmfEvent.class);
+    public void setUp() {
+        trace = CtfTmfTestTraceUtils.getTrace(testTrace);
+    }
+
+    /**
+     * Post-test clean-up.
+     */
+    @After
+    public void tearDown() {
+        if (trace != null) {
+            trace.dispose();
+        }
     }
 
     /**
@@ -95,9 +98,9 @@ public class CtfTmfContextTest {
         double increment = (end - begin) / lwcCount;
         final ArrayList<Long> vals = new ArrayList<>();
         final ArrayList<Thread> threads = new ArrayList<>();
-        final ArrayList<CtfTmfContext> tooManyContexts = new ArrayList<>();
 
-        for (double i = begin; i < end; i += increment) {
+        double time = begin;
+        for (int i = 0; i < lwcCount; i++) {
             SeekerThread thread = new SeekerThread() {
                 @Override
                 public void run() {
@@ -108,19 +111,19 @@ public class CtfTmfContextTest {
                         if (lwc.getCurrentEvent() != null) {
                             vals.add(lwc.getCurrentEvent().getTimestamp().getValue());
                         }
-                        tooManyContexts.add(lwc);
                     }
                 }
             };
-            thread.setVal((long) i);
+            thread.setVal((long) time);
             threads.add(thread);
             thread.start();
+            time += increment;
         }
 
         for (Thread t : threads) {
             t.join();
         }
-        assertEquals("seeks done ", lwcCount + 1, vals.size());
+        assertEquals("seeks done ", lwcCount, vals.size());
         for (long val : vals) {
             assertTrue("val >= begin, " + val + " " + begin, val >= begin);
             assertTrue("val >= end, " + val + " " + end, val <= end);
This page took 0.025124 seconds and 5 git commands to generate.