tmf: Re-enable the unit tests depending on CTF traces
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 13 Feb 2013 20:37:37 +0000 (15:37 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 14 Feb 2013 17:56:39 +0000 (12:56 -0500)
And skip them if the traces are not available.

Also added a new exported test file manager, so that other
plugin tests (like the lttng2 ones) can re-use it.

Change-Id: I71cffad8f68089f3e88582e436a74bb2ec57c897
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/10354
Reviewed-by: Bernd Hufmann <bhufmann@gmail.com>
IP-Clean: Bernd Hufmann <bhufmann@gmail.com>
Tested-by: Bernd Hufmann <bhufmann@gmail.com>
Tested-by: Hudson CI
14 files changed:
org.eclipse.linuxtools.tmf.core.tests/.classpath
org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core.tests/build.properties
org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/AllTmfCoreTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContextTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TestParams.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfEventsStatisticsTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStateStatisticsTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStatisticsTest.java

index 2a987e28541dabf30f380fa3890ff1f723abecf8..36ec9cee4a94032c1f09d43bddda16a2533d679f 100644 (file)
@@ -4,5 +4,6 @@
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="stubs"/>
+       <classpathentry kind="src" path="shared"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index d5a373c2338c06d2e5d9504bbce1a73afcd22cdb..3c3d300d32a7c1b6d79655e963d6b03398481bc8 100644 (file)
@@ -12,5 +12,7 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.core.runtime,
  org.eclipse.core.resources,
  org.eclipse.linuxtools.tmf.core;bundle-version="2.0.0",
- org.eclipse.linuxtools.ctf.core;bundle-version="1.0.0"
-Export-Package: org.eclipse.linuxtools.tmf.tests.stubs.trace;x-friends:="org.eclipse.linuxtools.tmf.ui.tests"
+ org.eclipse.linuxtools.ctf.core;bundle-version="1.0.0",
+ org.eclipse.linuxtools.ctf.core.tests;bundle-version="1.0.0"
+Export-Package: org.eclipse.linuxtools.tmf.core.tests.shared,
+ org.eclipse.linuxtools.tmf.tests.stubs.trace;x-friends:="org.eclipse.linuxtools.tmf.ui.tests"
index 3bbef16a185fbe5e4b457091d32f5979ff1abfde..61f533e67fd8e4d0f1f6a076045df5f7fc34fe34 100644 (file)
@@ -1,4 +1,5 @@
 source.. = stubs/,\
+           shared/,\
            src/
 output.. = bin/
 bin.includes = META-INF/,\
diff --git a/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java b/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java
new file mode 100644 (file)
index 0000000..d99ae7b
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.shared;
+
+import java.io.File;
+
+import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+
+/**
+ * Definitions used by all tests using CTF-TMF trace files.
+ *
+ * To run these tests, you will first need to run the "get-traces.sh" script
+ * located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ .
+ *
+ * @author Alexandre Montplaisir
+ */
+public final class CtfTmfTestTraces {
+
+    private CtfTmfTestTraces() {}
+
+    private static final File emptyFile = new File(""); //$NON-NLS-1$
+    private static CtfTmfTrace emptyTrace = new CtfTmfTrace();
+
+    private static CtfTmfTrace[] testTraces = new CtfTmfTrace[2];
+
+    /**
+     * Get an empty File (new File("");)
+     *
+     * @return An empty file
+     */
+    public static File getEmptyFile() {
+        return emptyFile;
+    }
+
+    /**
+     * Get an empty CtfTmfTrace (new CtfTmfTrace();)
+     *
+     * @return An empty trace
+     */
+    public static CtfTmfTrace getEmptyTrace() {
+        return emptyTrace;
+    }
+
+    /**
+     * Get a reference to the test trace used for the kernel event handler unit
+     * tests.
+     *
+     * Make sure you call {@link #tracesExist()} before calling this!
+     *
+     * @param idx
+     *            The index of the test trace you want
+     * @return A CtfTmfTrace reference to the test trace
+     */
+    public synchronized static CtfTmfTrace getTestTrace(int idx) {
+        if (testTraces[idx] == null) {
+            String tracePath = CtfTestTraces.getTestTracePath(idx);
+            testTraces[idx] = new CtfTmfTrace();
+            try {
+                testTraces[idx].initTrace(null, tracePath, CtfTmfEvent.class);
+            } catch (TmfTraceException e) {
+                /* Should not happen if tracesExist() passed */
+                testTraces[idx] = null;
+                throw new RuntimeException(e);
+            }
+        }
+        return testTraces[idx];
+    }
+
+    // ------------------------------------------------------------------------
+    // Wrappers around direct CtfTestTraces methods
+    // ------------------------------------------------------------------------
+
+    /**
+     * Get the (string) path to a given test trace.
+     *
+     * You should call {@link #tracesExist()} before calling this if you are
+     * going to use this trace for real.
+     *
+     * @param idx
+     *            The index of the trace among all the available ones
+     * @return The path to the test trace
+     */
+    public static String getTestTracePath(int idx) {
+        return CtfTestTraces.getTestTracePath(idx);
+    }
+
+    /**
+     * Check if the test traces are present before trying to open them.
+     *
+     * This should be called in unit tests within a asssumeTrue() call, to skip
+     * the test/test-class if the traces are not available.
+     *
+     * @return True if the trace is available, false if not
+     */
+    public static boolean tracesExist() {
+        return CtfTestTraces.tracesExist();
+    }
+
+}
index 8993a6aa4a8624d88bf5b7c95bbf02efd37bf372..db2363f761990cbc1258b247ecc27f97412590e0 100644 (file)
@@ -23,11 +23,11 @@ import org.junit.runners.Suite;
 @Suite.SuiteClasses({
     TmfCorePluginTest.class,
     org.eclipse.linuxtools.tmf.core.tests.component.AllTests.class,
-//    org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.AllTests.class, // Depends on the CTF traces
+    org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.event.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.request.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.statesystem.AllTests.class,
-//    org.eclipse.linuxtools.tmf.core.tests.statistics.AllTests.class, // Depends on the CTF traces
+    org.eclipse.linuxtools.tmf.core.tests.statistics.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.trace.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.uml2sd.AllTests.class,
     org.eclipse.linuxtools.tmf.core.tests.util.AllTests.class
index cb35f2901233fe6991fb80b9ea4d83c1fcda6125..0c621c7248861182b720ca2cbdbcae047763b3a3 100644 (file)
@@ -17,13 +17,14 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
 
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
 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.CtfTmfTestTraces;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,17 +38,17 @@ import org.junit.Test;
  */
 public class CtfIteratorTest {
 
+    private static final int TRACE_INDEX = 0;
+
     private CtfIterator fixture;
 
     /**
      * Perform pre-test initialization.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Before
-    public void setUp() throws TmfTraceException {
-        fixture = new CtfIterator(createTrace());
+    public void setUp() {
+        assumeTrue(CtfTmfTestTraces.tracesExist());
+        fixture = new CtfIterator(getTrace());
         CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0));
         fixture.setLocation(ctfLocation);
         fixture.increaseRank();
@@ -58,36 +59,31 @@ public class CtfIteratorTest {
      */
     @After
     public void tearDown() {
-        fixture.dispose();
+        if (fixture != null) {
+            fixture.dispose();
+        }
     }
 
-
-    private static CtfTmfTrace createTrace() throws TmfTraceException {
-        return TestParams.createTrace();
+    private static CtfTmfTrace getTrace() {
+        return CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
     }
 
     /**
      * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Test
-    public void testCtfIterator_noinit() throws TmfTraceException {
-        CtfTmfTrace trace = createTrace();
+    public void testCtfIterator_noinit() {
+        CtfTmfTrace trace = getTrace();
         CtfIterator result = new CtfIterator(trace);
         assertNotNull(result);
     }
 
     /**
      * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Test
-    public void testCtfIterator_init() throws TmfTraceException {
-        CtfTmfTrace trace = createTrace();
+    public void testCtfIterator_init() {
+        CtfTmfTrace trace = getTrace();
         trace.init("test"); //$NON-NLS-1$
         CtfIterator result = new CtfIterator(trace);
 
@@ -97,13 +93,10 @@ public class CtfIteratorTest {
     /**
      * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
      * specifies an initial position for the iterator.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Test
-    public void testCtfIterator_position() throws TmfTraceException {
-        CtfTmfTrace trace = createTrace();
+    public void testCtfIterator_position() {
+        CtfTmfTrace trace = getTrace();
         long timestampValue = 1L;
         long rank = 1L;
         CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank);
@@ -132,13 +125,10 @@ public class CtfIteratorTest {
 
     /**
      * Run the int compareTo(CtfIterator) method test.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Test
-    public void testCompareTo() throws TmfTraceException {
-        CtfIterator o = new CtfIterator(createTrace());
+    public void testCompareTo() {
+        CtfIterator o = new CtfIterator(getTrace());
         int result = fixture.compareTo(o);
 
         assertEquals(1L, result);
@@ -147,13 +137,10 @@ public class CtfIteratorTest {
     /**
      * Run the boolean equals(Object) method test. Compare with another iterator
      * on the same trace.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Test
-    public void testEquals_other() throws TmfTraceException {
-        CtfIterator obj = new CtfIterator(createTrace());
+    public void testEquals_other() {
+        CtfIterator obj = new CtfIterator(getTrace());
         CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0));
         obj.setLocation(ctfLocation1);
         obj.increaseRank();
index d95217398b87d164614f4b22e53c002782b4bf97..c75d733b81fa8ad98da7f1f2c32d99eae20d4f55 100644 (file)
@@ -16,14 +16,16 @@ 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.CtfTmfTestTraces;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -35,7 +37,7 @@ import org.junit.Test;
  */
 public class CtfTmfContextTest {
 
-    private static final String PATH = TestParams.getPath();
+    private static final int TRACE_INDEX = 0;
     private static final long begin = 1332170682440133097L; /* Trace start time */
     private static final long end = 1332170692664579801L; /* Trace end time */
 
@@ -57,8 +59,10 @@ public class CtfTmfContextTest {
      */
     @Before
     public void setUp() throws TmfTraceException {
+        assumeTrue(CtfTmfTestTraces.tracesExist());
         trace = new CtfTmfTrace();
-        trace.initTrace((IResource) null, PATH, CtfTmfEvent.class);
+        String path = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX);
+        trace.initTrace((IResource) null, path, CtfTmfEvent.class);
     }
 
     /**
index 0118247aaadeb3921a81acf5b4b016727b0958ea..1e55fedaf1426eedd12b6fe0d6c138f1cbd401a8 100644 (file)
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assume.assumeTrue;
 
 import java.util.Set;
 
@@ -27,7 +28,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEventFactory;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -42,6 +43,8 @@ import org.junit.Test;
  */
 public class CtfTmfEventTest {
 
+    private static final int TRACE_INDEX = 0;
+
     private static CtfTmfEvent nullEvent;
     private CtfTmfEvent fixture;
 
@@ -55,13 +58,11 @@ public class CtfTmfEventTest {
 
     /**
      * Perform pre-test initialization.
-     *
-     * @throws TmfTraceException
-     *             If the test trace is not found
      */
     @Before
-    public void setUp() throws TmfTraceException {
-        CtfTmfTrace trace = TestParams.createTrace();
+    public void setUp() {
+        assumeTrue(CtfTmfTestTraces.tracesExist());
+        CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
         CtfIterator tr = new CtfIterator(trace);
         tr.advance();
         fixture = tr.getCurrentEvent();
@@ -152,11 +153,11 @@ public class CtfTmfEventTest {
         String reference = fixture.getReference();
         String source = fixture.getSource();
         ITmfEventType type = fixture.getType();
-        assertEquals(rank, ITmfContext.UNKNOWN_RANK);
-        assertEquals(trace.getName(), "test"); //$NON-NLS-1$
-        assertEquals(reference,"channel0_1"); //$NON-NLS-1$
-        assertEquals(source, "1"); //$NON-NLS-1$
-        assertEquals(type.toString(), "lttng_statedump_vm_map"); //$NON-NLS-1$
+        assertEquals(ITmfContext.UNKNOWN_RANK, rank);
+        assertEquals("test", trace.getName()); //$NON-NLS-1$
+        assertEquals("channel0_1", reference); //$NON-NLS-1$
+        assertEquals("1", source); //$NON-NLS-1$
+        assertEquals("lttng_statedump_vm_map", type.toString()); //$NON-NLS-1$
     }
 
     /**
index b6ad8e77f1f82ec5386e1f62ddb36a9884b9e32e..5a179ff9cc3bbdb95a54939b37c55afa5983cfcc 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -32,6 +33,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.junit.After;
 import org.junit.Before;
@@ -46,7 +48,8 @@ import org.junit.Test;
  */
 public class CtfTmfTraceTest {
 
-    private static final String PATH = TestParams.getPath();
+    private static final int TRACE_INDEX = 0;
+    private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX);
 
     private CtfTmfTrace fixture;
 
@@ -58,6 +61,7 @@ public class CtfTmfTraceTest {
      */
     @Before
     public void setUp() throws TmfTraceException {
+        assumeTrue(CtfTmfTestTraces.tracesExist());
         fixture = new CtfTmfTrace();
         fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class);
     }
@@ -67,7 +71,9 @@ public class CtfTmfTraceTest {
      */
     @After
     public void tearDown() {
-        fixture.dispose();
+        if (fixture != null) {
+            fixture.dispose();
+        }
     }
 
     /**
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java
deleted file mode 100644 (file)
index c2bf932..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
-
-import java.io.File;
-
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-
-/**
- * This is the set up for the trace files to be used with the ctfAdaptor tests.
- */
-abstract class TestParams {
-
-    /* Path to test traces */
-    private static final String testTracePath1 = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; //$NON-NLS-1$
-    private static CtfTmfTrace testTrace1 = null;
-
-    private static final File emptyFile = new File(""); //$NON-NLS-1$
-    private static CtfTmfTrace emptyTrace = new CtfTmfTrace();
-
-    public static File getEmptyFile() {
-        return emptyFile;
-    }
-
-    public static CtfTmfTrace getEmptyTrace() {
-        return emptyTrace;
-    }
-
-    public static String getPath(){
-        return testTracePath1;
-    }
-
-    public synchronized static CtfTmfTrace createTrace() throws TmfTraceException {
-        if (testTrace1 == null) {
-            testTrace1 = new CtfTmfTrace();
-            testTrace1.initTrace(null, testTracePath1, CtfTmfEvent.class);
-        }
-        return testTrace1;
-    }
-}
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TestParams.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TestParams.java
deleted file mode 100644 (file)
index f8f6c5d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statistics;
-
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-
-/**
- * This is the set up for the trace files to be used with the TmfStatistics
- * tests.
- */
-abstract class TestParams {
-
-    /* Path to test traces */
-    private static final String testTracePath1 = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"; //$NON-NLS-1$
-    private static CtfTmfTrace testTrace1 = null;
-
-    public synchronized static CtfTmfTrace createTrace() throws TmfTraceException {
-        if (testTrace1 == null) {
-            testTrace1 = new CtfTmfTrace();
-            testTrace1.initTrace(null, testTracePath1, CtfTmfEvent.class);
-        }
-        return testTrace1;
-    }
-}
index fc01970a710bc153cb9ba7a3b620ec5c7d67a594..0aebb5e51af5a9705026bda625438e5e0daba7da 100644 (file)
 
 package org.eclipse.linuxtools.tmf.core.tests.statistics;
 
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import static org.junit.Assume.assumeTrue;
+
 import org.eclipse.linuxtools.tmf.core.statistics.TmfEventsStatistics;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
 import org.junit.BeforeClass;
 
 /**
@@ -28,10 +30,7 @@ public class TmfEventsStatisticsTest extends TmfStatisticsTest {
      */
     @BeforeClass
     public static void setUpClass() {
-        try {
-            backend = new TmfEventsStatistics(TestParams.createTrace());
-        } catch (TmfTraceException e) {
-            e.printStackTrace();
-        }
+        assumeTrue(CtfTmfTestTraces.tracesExist());
+        backend = new TmfEventsStatistics(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
     }
 }
index 9c4df93013cccd5da95e316275ad659d619d57e2..1b3c104aaa8f23b9a2d931cd166131f39a1f872c 100644 (file)
 
 package org.eclipse.linuxtools.tmf.core.tests.statistics;
 
+import static org.junit.Assume.assumeTrue;
+
 import java.io.File;
 import java.io.IOException;
 
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
 import org.junit.BeforeClass;
 
 /**
@@ -31,10 +35,12 @@ public class TmfStateStatisticsTest extends TmfStatisticsTest {
      */
     @BeforeClass
     public static void setUpClass() {
+        assumeTrue(CtfTmfTestTraces.tracesExist());
         try {
             File htFile = File.createTempFile("stats-test", ".ht"); //$NON-NLS-1$ //$NON-NLS-2$
             htFile.deleteOnExit();
-            backend = new TmfStateStatistics(TestParams.createTrace(), htFile);
+            CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
+            backend = new TmfStateStatistics(trace, htFile);
         } catch (TmfTraceException e) {
             e.printStackTrace();
         } catch (IOException e) {
index 3c2d28aefb83e64f07c58332c19b874636c995b9..b60a71caedbc3354a9e6912b65ce825df717199b 100644 (file)
@@ -28,6 +28,9 @@ import org.junit.Test;
  */
 public abstract class TmfStatisticsTest {
 
+    /** The index of the test trace used for these tests */
+    protected static final int TRACE_INDEX = 0;
+
     /** The statistics back-end object */
     protected static ITmfStatistics backend;
 
This page took 0.037584 seconds and 5 git commands to generate.