ctf: move getStreams to an iterable.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / CTFTraceTest.java
index 0fd73cb3ed458b77cbc711b051f3456d4fd0a9a3..b69ce43e2093b4df50e655eef180609fcc3d0b42 100644 (file)
@@ -23,7 +23,6 @@ import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
 import java.nio.ByteOrder;
-import java.util.Map;
 import java.util.UUID;
 
 import org.eclipse.linuxtools.ctf.core.event.CTFClock;
@@ -45,15 +44,8 @@ import org.junit.Test;
  */
 public class CTFTraceTest {
 
-    private static final String TRACES_DIRECTORY = "../org.eclipse.linuxtools.ctf.core.tests/traces";
-
-    private static final String METADATA_FILENAME = "metadata";
-
     private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
 
-    private static final String CTF_VERSION_NUMBER = "1.8";
-    private static final String CTF_SUITE_TEST_DIRECTORY = "ctf-testsuite/tests/" + CTF_VERSION_NUMBER;
-
     private CTFTrace fixture;
 
     /**
@@ -199,15 +191,6 @@ public class CTFTraceTest {
         assertNotNull(result);
     }
 
-    /**
-     * Run the Map<Long, Stream> getStreams() method test.
-     */
-    @Test
-    public void testGetStreams() {
-        Map<Long, Stream> result = fixture.getStreams();
-        assertNotNull(result);
-    }
-
     /**
      * Run the File getTraceDirectory() method test.
      */
@@ -237,11 +220,11 @@ public class CTFTraceTest {
     }
 
     /**
-     * Run the boolean majortIsSet() method test.
+     * Run the boolean majorIsSet() method test.
      */
     @Test
-    public void testMajortIsSet() {
-        boolean result = fixture.majortIsSet();
+    public void testMajorIsSet() {
+        boolean result = fixture.majorIsSet();
         assertTrue(result);
     }
 
@@ -364,7 +347,7 @@ public class CTFTraceTest {
     @Test
     public void testLookupEnvironment_1() {
         String key = "";
-        String result = fixture.lookupEnvironment(key);
+        String result = fixture.getEnvironment().get(key);
         assertNull(result);
     }
 
@@ -374,7 +357,7 @@ public class CTFTraceTest {
     @Test
     public void testLookupEnvironment_2() {
         String key = "otherTest";
-        String result = fixture.lookupEnvironment(key);
+        String result = fixture.getEnvironment().get(key);
         assertNull(result);
     }
 
@@ -385,7 +368,7 @@ public class CTFTraceTest {
     public void testLookupEnvironment_3() {
         String key = "test";
         fixture.addEnvironmentVar(key, key);
-        String result = fixture.lookupEnvironment(key);
+        String result = fixture.getEnvironment().get(key);
         assertTrue(result.equals(key));
     }
 
@@ -397,74 +380,10 @@ public class CTFTraceTest {
         String key = "test";
         fixture.addEnvironmentVar(key, "bozo");
         fixture.addEnvironmentVar(key, "the clown");
-        String result = fixture.lookupEnvironment(key);
+        String result = fixture.getEnvironment().get(key);
         assertNotNull(result);
     }
 
-    /**
-     * Open traces in specified directories and expect them to fail
-     *
-     * @throws CTFReaderException not expected
-     */
-    @Test
-    public void testFailedParse() throws CTFReaderException {
-        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/fail"), true);
-    }
-
-    /**
-     * Open traces in specified directories and expect them to succeed
-     *
-     * @throws CTFReaderException not expected
-     */
-    @Test
-    public void testSuccessfulParse() throws CTFReaderException {
-        parseTracesInDirectory(getTestTracesSubDirectory("kernel"), false);
-        parseTracesInDirectory(getTestTracesSubDirectory("trace2"), false);
-        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/pass"), false);
-    }
-
-    /**
-     * Get the File object for the subDir in the traces directory. If the sub directory doesn't exist, the test is skipped.
-     */
-    private static File getTestTracesSubDirectory(String subDir) {
-        File file = new File(TRACES_DIRECTORY + "/" + subDir);
-        assumeTrue(file.isDirectory());
-        return file;
-    }
-
-    /**
-     * Parse the traces in given directory recursively
-     *
-     * @param directory The directory to search in
-     * @param expectException Whether or not traces in this directory are expected to throw an exception when parsed
-     * @throws CTFReaderException
-     */
-    void parseTracesInDirectory(File directory, boolean expectException) throws CTFReaderException {
-        for (File file : directory.listFiles()) {
-            if (file.getName().equals(METADATA_FILENAME)) {
-                try {
-                    new CTFTrace(directory);
-                    if (expectException) {
-                        fail("Trace was expected to fail parsing: " + directory);
-                    }
-                } catch (RuntimeException e) {
-                    if (!expectException) {
-                        throw new CTFReaderException("Failed parsing " + directory, e);
-                    }
-                } catch (CTFReaderException e) {
-                    if (!expectException) {
-                        throw new CTFReaderException("Failed parsing " + directory, e);
-                    }
-                }
-                return;
-            }
-
-            if (file.isDirectory()) {
-                parseTracesInDirectory(file, expectException);
-            }
-        }
-    }
-
     /**
      * Test for getCallsite(eventName, ip)
      * @throws CTFReaderException not expected
This page took 0.031657 seconds and 5 git commands to generate.