ctf: Make sure CTFTraceTest's are independent
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / CTFTraceTest.java
index 3c88a43da60cbecbab0b5d6f0d71fe8c455efcb0..0caf60fd31ca809b305a7c0af131f4467ad97163 100644 (file)
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
@@ -31,7 +32,6 @@ import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
 import org.eclipse.linuxtools.ctf.core.trace.Stream;
 import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,25 +40,14 @@ import org.junit.Test;
  * <code>{@link CTFTrace}</code>.
  *
  * @author ematkho
- * @version $Revision: 1.0 $
  */
-@SuppressWarnings("javadoc")
+@SuppressWarnings("nls")
 public class CTFTraceTest {
 
     private static final int TRACE_INDEX = 0;
 
     private CTFTrace fixture;
 
-    /**
-     * Launch the test.
-     *
-     * @param args
-     *            the command line arguments
-     */
-    public static void main(String[] args) {
-        new org.junit.runner.JUnitCore().run(CTFTraceTest.class);
-    }
-
     /**
      * Perform pre-test initialization.
      */
@@ -73,14 +62,6 @@ public class CTFTraceTest {
         fixture.setByteOrder(ByteOrder.BIG_ENDIAN);
     }
 
-    /**
-     * Perform post-test clean-up.
-     */
-    @After
-    public void tearDown() {
-        // Add additional tear down code here
-    }
-
     /**
      * Run the CTFTrace(File) constructor test with a known existing trace.
      */
@@ -94,10 +75,11 @@ public class CTFTraceTest {
      * Run the CTFTrace(File) constructor test with an invalid path.
      *
      * @throws CTFReaderException
+     *             is expected
      */
     @Test(expected = org.eclipse.linuxtools.ctf.core.trace.CTFReaderException.class)
     public void testOpen_invalid() throws CTFReaderException {
-        File path = new File(""); //$NON-NLS-1$
+        File path = new File("");
         CTFTrace result = new CTFTrace(path);
         assertNotNull(result);
     }
@@ -113,19 +95,24 @@ public class CTFTraceTest {
 
     /**
      * Run the void addStream(Stream) method test.
-     *
-     * @throws ParseException
-     * @throws CTFReaderException
      */
     @Test
-    public void testAddStream() throws ParseException, CTFReaderException {
+    public void testAddStream() {
         // test number of streams
         int nbStreams = fixture.nbStreams();
         assertEquals(1, nbStreams);
+
         // Add a stream
-        Stream stream = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
-        stream.setId(1234);
-        fixture.addStream(stream);
+        try {
+            Stream stream = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
+            stream.setId(1234);
+            fixture.addStream(stream);
+        } catch (CTFReaderException e) {
+            fail();
+        } catch (ParseException e) {
+            fail();
+        }
+
         // test number of streams
         nbStreams = fixture.nbStreams();
         assertEquals(2, nbStreams);
@@ -227,7 +214,7 @@ public class CTFTraceTest {
      */
     @Test
     public void testLookupDefinition() {
-        String lookupPath = "trace.packet.header"; //$NON-NLS-1$
+        String lookupPath = "trace.packet.header";
         Definition result = fixture.lookupDefinition(lookupPath);
         assertNotNull(result);
     }
@@ -322,41 +309,11 @@ public class CTFTraceTest {
     }
 
     /**
-     * Run the CTFClock getClock() method test.
-     */
-    @Test
-    public void testGetClock_1() {
-        CTFClock result = fixture.getClock();
-        assertNotNull(result);
-    }
-
-    /**
-     * Run the CTFClock getClock() method test.
-     *
-     */
-    @Test
-    public void testGetClock_2() {
-        CTFClock result = fixture.getClock("Blabla"); //$NON-NLS-1$
-        assertNull(result);
-    }
-
-    /**
-     * Run the CTFClock getClock(String) method test.
-     */
-    @Test
-    public void testGetClock_3() {
-        String name = "invisibleClock"; //$NON-NLS-1$
-        CTFClock result = fixture.getClock(name);
-        assertNull(result);
-    }
-
-
-    /**
-     * Run the CTFClock getClock(String) method test.
+     * Run the CTFClock getClock/setClock method test.
      */
     @Test
-    public void testSetClock_1() {
-        String name = "clockyClock"; //$NON-NLS-1$
+    public void testGetSetClock_1() {
+        String name = "clockyClock";
         fixture.addClock(name, new CTFClock());
         CTFClock result = fixture.getClock(name);
 
@@ -364,20 +321,20 @@ public class CTFTraceTest {
     }
 
     /**
-     * Run the CTFClock getClock(String) method test.
+     * Run the CTFClock getClock/setClock method test.
      */
     @Test
-    public void testSetClock_2() {
-        String name = ""; //$NON-NLS-1$
+    public void testGetSetClock_2() {
+        String name = "";
         CTFClock ctfClock = new CTFClock();
-        ctfClock.addAttribute("name", "Bob"); //$NON-NLS-1$ //$NON-NLS-2$
-        ctfClock.addAttribute("pi", new Double(java.lang.Math.PI)); //$NON-NLS-1$
+        ctfClock.addAttribute("name", "Bob");
+        ctfClock.addAttribute("pi", new Double(java.lang.Math.PI));
         fixture.addClock(name, ctfClock);
         CTFClock result = fixture.getClock(name);
 
         assertNotNull(result);
-        assertTrue( (Double)ctfClock.getProperty("pi")> 3.0); //$NON-NLS-1$
-        assertTrue( ctfClock.getName().equals("Bob")); //$NON-NLS-1$
+        assertTrue((Double) ctfClock.getProperty("pi") > 3.0);
+        assertTrue(ctfClock.getName().equals("Bob"));
     }
 
     /**
@@ -385,7 +342,7 @@ public class CTFTraceTest {
      */
     @Test
     public void testLookupEnvironment_1() {
-        String key = ""; //$NON-NLS-1$
+        String key = "";
         String result = fixture.lookupEnvironment(key);
         assertNull(result);
     }
@@ -395,7 +352,7 @@ public class CTFTraceTest {
      */
     @Test
     public void testLookupEnvironment_2() {
-        String key = "otherTest"; //$NON-NLS-1$
+        String key = "otherTest";
         String result = fixture.lookupEnvironment(key);
         assertNull(result);
     }
@@ -405,7 +362,7 @@ public class CTFTraceTest {
      */
     @Test
     public void testLookupEnvironment_3() {
-        String key = "test"; //$NON-NLS-1$
+        String key = "test";
         fixture.addEnvironmentVar(key, key);
         String result = fixture.lookupEnvironment(key);
         assertTrue(result.equals(key));
@@ -416,9 +373,9 @@ public class CTFTraceTest {
      */
     @Test
     public void testLookupEnvironment_4() {
-        String key = "test"; //$NON-NLS-1$
-        fixture.addEnvironmentVar(key, "bozo"); //$NON-NLS-1$
-        fixture.addEnvironmentVar(key, "the clown"); //$NON-NLS-1$
+        String key = "test";
+        fixture.addEnvironmentVar(key, "bozo");
+        fixture.addEnvironmentVar(key, "the clown");
         String result = fixture.lookupEnvironment(key);
         assertNotNull(result);
     }
This page took 0.026602 seconds and 5 git commands to generate.