LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfTmfContextTest.java
index d95217398b87d164614f4b22e53c002782b4bf97..b901a7f96ebbd0d5f32b5b21c921ed95b5fa0734 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2014 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,21 +9,22 @@
  * Contributors:
  *   Matthew Khouzam - Initial implementation
  *   Alexandre Montplaisir
+ *   Patrick Tasse - Updated for removal of context clone
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
 
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
 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.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfContext;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -35,7 +36,7 @@ import org.junit.Test;
  */
 public class CtfTmfContextTest {
 
-    private static final String PATH = TestParams.getPath();
+    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
     private static final long begin = 1332170682440133097L; /* Trace start time */
     private static final long end = 1332170692664579801L; /* Trace end time */
 
@@ -57,8 +58,10 @@ public class CtfTmfContextTest {
      */
     @Before
     public void setUp() throws TmfTraceException {
+        assumeTrue(testTrace.exists());
         trace = new CtfTmfTrace();
-        trace.initTrace((IResource) null, PATH, CtfTmfEvent.class);
+        String path = testTrace.getPath();
+        trace.initTrace((IResource) null, path, CtfTmfEvent.class);
     }
 
     /**
@@ -87,9 +90,9 @@ public class CtfTmfContextTest {
     public void testTooManyContexts() throws InterruptedException {
         final int lwcCount = 101;
         double increment = (end - begin) / lwcCount;
-        final ArrayList<Long> vals = new ArrayList<Long>();
-        final ArrayList<Thread> threads = new ArrayList<Thread>();
-        final ArrayList<CtfTmfContext> tooManyContexts = new ArrayList<CtfTmfContext>();
+        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) {
             SeekerThread thread = new SeekerThread() {
@@ -111,29 +114,13 @@ public class CtfTmfContextTest {
             thread.start();
         }
 
-        forThread t: threads){
+        for (Thread t: threads){
             t.join();
         }
 
-        for( Long val : vals){
+        for (long val : vals){
             assertTrue(val >= begin);
             assertTrue(val <= end);
         }
     }
-
-    /**
-     * Test for clone method
-     */
-    @Test
-    public void testClone() {
-        CtfTmfContext fixture1 = new CtfTmfContext(trace);
-        CtfTmfContext fixture2 = fixture1.clone();
-        //assertTrue(fixture1.equals(fixture2)); FIXME no .equals() override!
-        assertNotSame(fixture1, fixture2);
-
-        /* Make sure clone() did its job */
-        assertSame(fixture1.getTrace(), fixture2.getTrace());
-        assertSame(fixture1.getLocation(), fixture2.getLocation());
-        assertSame(fixture1.getRank(), fixture2.getRank());
-    }
 }
This page took 0.027707 seconds and 5 git commands to generate.