Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfTmfEventTest.java
index 9a11af0b123ddf9f38b44e978fe86e15c630f2ec..a48e7d5dca4b1a6e7c8e92ef30781ee2addde506 100644 (file)
@@ -28,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.tests.shared.CtfTmfTestTraces;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -43,7 +43,7 @@ import org.junit.Test;
  */
 public class CtfTmfEventTest {
 
-    private static final int TRACE_INDEX = 0;
+    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
 
     private static CtfTmfEvent nullEvent;
     private CtfTmfEvent fixture;
@@ -61,8 +61,8 @@ public class CtfTmfEventTest {
      */
     @Before
     public void setUp() {
-        assumeTrue(CtfTmfTestTraces.tracesExist());
-        CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
+        assumeTrue(testTrace.exists());
+        CtfTmfTrace trace = testTrace.getTrace();
         CtfIterator tr = new CtfIterator(trace);
         tr.advance();
         fixture = tr.getCurrentEvent();
@@ -91,7 +91,7 @@ public class CtfTmfEventTest {
     @Test
     public void testGetEventName() {
         String result = nullEvent.getEventName();
-        assertEquals("Empty CTF event", result); //$NON-NLS-1$
+        assertEquals("Empty CTF event", result);
     }
 
     /**
@@ -108,7 +108,7 @@ public class CtfTmfEventTest {
      */
     @Test
     public void testGetFieldValue() {
-        String fieldName = "pid"; //$NON-NLS-1$
+        String fieldName = "pid";
         ITmfEventField result = fixture.getContent().getField(fieldName);
 
         assertNotNull(result);
@@ -125,6 +125,26 @@ public class CtfTmfEventTest {
         assertArrayEquals(fields2, fields);
     }
 
+    /**
+     * Run the ITmfEventField getSubFieldValue(String[]) method test.
+     */
+    @Test
+    public void testGetSubFieldValue() {
+        /* Field exists */
+        String[] names = { "pid" };
+        assertNotNull(fixture.getContent().getSubField(names));
+
+        /* First field exists, not the second */
+        String[] names2 = { "pid", "abcd" };
+        assertNull(fixture.getContent().getSubField(names2));
+
+        /* Both field do not exist */
+        String[] names3 = { "pfid", "abcd" };
+        assertNull(fixture.getContent().getSubField(names3));
+
+        /* TODO Missing case of embedded field, need event for it */
+    }
+
     /**
      * Run the long getID() method test.
      */
@@ -154,10 +174,10 @@ public class CtfTmfEventTest {
         String source = fixture.getSource();
         ITmfEventType type = fixture.getType();
         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$
+        assertEquals("kernel", trace.getName());
+        assertEquals("channel0_1", reference);
+        assertEquals("1", source);
+        assertEquals("lttng_statedump_vm_map", type.toString());
     }
 
     /**
@@ -169,7 +189,7 @@ public class CtfTmfEventTest {
         Set<String> attributes = fixture.listCustomAttributes();
         assertEquals(0, attributes.size());
 
-        String attrib = fixture.getCustomAttribute("bozo"); //$NON-NLS-1$
+        String attrib = fixture.getCustomAttribute("bozo");
         assertNull(attrib);
     }
 
@@ -179,7 +199,7 @@ public class CtfTmfEventTest {
     @Test
     public void testToString() {
         String s = fixture.getContent().toString();
-        assertEquals("pid=1922, start=0xb73ea000, end=0xb73ec000, flags=0x8000075, inode=917738, pgoff=0", s); //$NON-NLS-1$
+        assertEquals("pid=1922, start=0xb73ea000, end=0xb73ec000, flags=0x8000075, inode=917738, pgoff=0", s);
     }
 
     /**
@@ -192,8 +212,8 @@ public class CtfTmfEventTest {
         assertSame(nullEvent2, nullEvent);
         assertNotNull(nullEvent);
         assertEquals(-1, nullEvent.getCPU());
-        assertEquals("Empty CTF event", nullEvent.getEventName()); //$NON-NLS-1$
-        assertEquals("No stream", nullEvent.getReference()); //$NON-NLS-1$
+        assertEquals("Empty CTF event", nullEvent.getEventName());
+        assertEquals("No stream", nullEvent.getReference());
         assertArrayEquals(new ITmfEventField[0], nullEvent.getContent().getFields());
         assertEquals(-1L, nullEvent.getID());
         assertEquals(-1L, nullEvent.getTimestamp().getValue());
This page took 0.025951 seconds and 5 git commands to generate.