Improved test coverage.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 16 Mar 2012 16:50:29 +0000 (12:50 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Mon, 19 Mar 2012 21:43:54 +0000 (17:43 -0400)
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java

index 5f4546f5321723afbb75b9e1dc87873633228a87..2b576d89110ec9d018c23a0f5e5804c3995ade7e 100644 (file)
@@ -3,6 +3,7 @@ package org.eclipse.linuxtools.ctf.core.tests.trace;
 import static org.junit.Assert.assertEquals;
 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 java.io.File;
@@ -10,6 +11,7 @@ import java.nio.ByteOrder;
 import java.util.Map;
 import java.util.UUID;
 
+import org.eclipse.linuxtools.ctf.core.event.CTFClock;
 import org.eclipse.linuxtools.ctf.core.event.metadata.exceptions.ParseException;
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
@@ -24,7 +26,7 @@ import org.junit.Test;
 /**
  * The class <code>CTFTraceTest</code> contains tests for the class
  * <code>{@link CTFTrace}</code>.
- * 
+ *
  * @author ematkho
  * @version $Revision: 1.0 $
  */
@@ -34,7 +36,7 @@ public class CTFTraceTest {
 
     /**
      * Launch the test.
-     * 
+     *
      * @param args
      *            the command line arguments
      */
@@ -74,7 +76,7 @@ public class CTFTraceTest {
 
     /**
      * Run the CTFTrace(File) constructor test with an invalid path.
-     * 
+     *
      * @throws CTFReaderException
      */
     @Test(expected = org.eclipse.linuxtools.ctf.core.trace.CTFReaderException.class)
@@ -95,7 +97,7 @@ public class CTFTraceTest {
 
     /**
      * Run the void addStream(Stream) method test.
-     * 
+     *
      * @throws ParseException
      * @throws CTFReaderException 
      */
@@ -304,4 +306,107 @@ public class CTFTraceTest {
         UUID uuid = UUID.randomUUID();
         fixture.setUUID(uuid);
     }
+
+    /**
+     * Run the CTFClock getClock() method test.
+     */
+    @Test
+    public void testGetClock_1() {
+        CTFClock result = fixture.getClock();
+        assertNull(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 = ""; //$NON-NLS-1$
+        CTFClock result = fixture.getClock(name);
+        assertNull(result);
+    }
+
+
+    /**
+     * Run the CTFClock getClock(String) method test.
+     */
+    @Test
+    public void testSetClock_1() {
+        String name = ""; //$NON-NLS-1$
+        fixture.addClock(name, new CTFClock());
+        CTFClock result = fixture.getClock(name);
+
+        assertNotNull(result);
+    }
+
+    /**
+     * Run the CTFClock getClock(String) method test.
+     */
+    @Test
+    public void testSetClock_2() {
+        String name = ""; //$NON-NLS-1$
+        CTFClock ctfClock = new CTFClock();
+        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);
+        assertTrue( ctfClock.getName().equals("Bob"));
+    }
+
+    /**
+     * Run the String lookupEnvironment(String) method test.
+     */
+    @Test
+    public void testLookupEnvironment_1() {
+        String key = "";
+        String result = fixture.lookupEnvironment(key);
+        assertNull(result);
+    }
+
+    /**
+     * Run the String lookupEnvironment(String) method test.
+     */
+    @Test
+    public void testLookupEnvironment_2() {
+        String key = "test";
+        String result = fixture.lookupEnvironment(key);
+        assertNull(result);
+    }
+
+    /**
+     * Run the String lookupEnvironment(String) method test.
+     */
+    @Test
+    public void testLookupEnvironment_3() {
+        String key = "test";
+        fixture.addEnvironmentVar(key, key);
+        String result = fixture.lookupEnvironment(key);
+        assertTrue(result.equals(key));
+    }
+
+    /**
+     * Run the String lookupEnvironment(String) method test.
+     */
+    @Test
+    public void testLookupEnvironment_4() {
+        String key = "test";
+        fixture.addEnvironmentVar(key, "bozo");
+        fixture.addEnvironmentVar(key, "the clown");
+        String result = fixture.lookupEnvironment(key);
+        assertNotNull(result);
+    }
+
 }
index 4d21fdec2effd688d8da6b822aed28b67d170007..543c907e68c802ab2697212917130dbe4d52d1e6 100644 (file)
@@ -15,7 +15,7 @@ import org.junit.Test;
 /**
  * The class <code>MetadataTest</code> contains tests for the class
  * <code>{@link Metadata}</code>.
- * 
+ *
  * @author ematkho
  * @version $Revision: 1.0 $
  */
@@ -25,7 +25,7 @@ public class MetadataTest {
 
     /**
      * Launch the test.
-     * 
+     *
      * @param args
      *            the command line arguments
      */
@@ -68,9 +68,18 @@ public class MetadataTest {
         assertNull(result);
     }
 
+    /**
+     * Test toString
+     */
+    @Test
+    public void testToSting() {
+        String result = fixture.toString();
+        assertNotNull(result);
+    }
+
     /**
      * Run the void parse() method test.
-     * 
+     *
      * @throws CTFReaderException
      */
     @Test(expected = org.eclipse.linuxtools.ctf.core.trace.CTFReaderException.class)
index fd3ea36f7044f7fcc7a1a789794a64baf7d98ba5..cf660c8f9fbd545b87db965f6504e19d27bd661a 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.Test;
 /**
  * The class <code>StreamTest</code> contains tests for the class
  * <code>{@link Stream}</code>.
- * 
+ *
  * @author ematkho
  * @version $Revision: 1.0 $
  */
@@ -32,7 +32,7 @@ public class StreamTest {
 
     /**
      * Launch the test.
-     * 
+     *
      * @param args
      *            the command line arguments
      */
@@ -79,7 +79,7 @@ public class StreamTest {
     /**
      * Run the void addEvent(EventDeclaration) method test with the basic
      * event.
-     * @throws ParseException 
+     * @throws ParseException
      */
     @Test
     public void testAddEvent_base() throws ParseException {
@@ -88,10 +88,10 @@ public class StreamTest {
     }
 
     /**
-     * Run the void addEvent(EventDeclaration) method test with an event 
+     * Run the void addEvent(EventDeclaration) method test with an event
      * of which we modified the id.
-     * @throws ParseException 
-     * 
+     * @throws ParseException
+     *
      * @throws ParseException
      */
     @Test
@@ -99,6 +99,7 @@ public class StreamTest {
         EventDeclaration event = new EventDeclaration();
         event.setId(1L);
         fixture.addEvent(event);
+        assertNotNull(fixture);
     }
 
     /**
@@ -108,6 +109,13 @@ public class StreamTest {
     public void testEventContextIsSet() {
         assertTrue(fixture.eventContextIsSet());
     }
+    /**
+     * Run the boolean eventContextIsSet() method test.
+     */
+    @Test
+    public void testToString() {
+        assertNotNull(fixture.toString());
+    }
 
     /**
      * Run the boolean eventHeaderIsSet() method test.
index 092b24091d7eca1c93136f46a813d4f2efc7ab30..749bf393ba6f6b6bb04d764a77fa2e8b307f019a 100644 (file)
@@ -358,6 +358,7 @@ public class Metadata {
         @Override
         public String toString() {
             /* Only for debugging, shouldn't be externalized */
+            /* Therefore it cannot be covered by test cases */
             return "MetadataPacketHeader [magic=0x" //$NON-NLS-1$
                     + Integer.toHexString(magic) + ", uuid=" //$NON-NLS-1$
                     + Arrays.toString(uuid) + ", checksum=" + checksum //$NON-NLS-1$
This page took 0.028783 seconds and 5 git commands to generate.