| author | Matthew Khouzam | 2012-03-16 12:50:29 (EDT) |
|---|---|---|
| committer | Francois Chouinard | 2012-03-19 17:43:54 (EDT) |
| commit | d0bf7c0ef35d7f04fd7f07848d8a8a90d78ff515 (patch) (side-by-side diff) | |
| tree | 3e985dda89e3c54d00c0c551b2f15b416a09dfe8 | |
| parent | 9901a4af877c6d74fe200597b175dd8bf6caecfb (diff) | |
| download | org.eclipse.linuxtools-d0bf7c0ef35d7f04fd7f07848d8a8a90d78ff515.zip org.eclipse.linuxtools-d0bf7c0ef35d7f04fd7f07848d8a8a90d78ff515.tar.gz org.eclipse.linuxtools-d0bf7c0ef35d7f04fd7f07848d8a8a90d78ff515.tar.bz2 | |
Improved test coverage.
4 files changed, 136 insertions, 13 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java index 5f4546f..2b576d8 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java +++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java @@ -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); + } + } diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java index 4d21fde..543c907 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java +++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java @@ -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 */ @@ -69,8 +69,17 @@ public class MetadataTest { } /** + * 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) diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java index fd3ea36..cf660c8 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java +++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java @@ -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. diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java index 092b240..749bf39 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java @@ -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$ |

