ctf: replace HashMaps with ArrayLists for EventDeclaration storage
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / EventDeclarationTest.java
index 181c15c9b82b4e6dff1b3071ce2f87f484a486e9..ddb000ded041ef9ebb9cc208cc89eff044a10194 100644 (file)
@@ -24,7 +24,7 @@ import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
-import org.eclipse.linuxtools.ctf.core.trace.Stream;
+import org.eclipse.linuxtools.ctf.core.trace.CTFStream;
 import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,7 +55,7 @@ public class EventDeclarationTest {
         fixture.setContext(new StructDeclaration(1L));
         fixture.setId(1L);
         fixture.setFields(new StructDeclaration(1L));
-        fixture.setStream(new Stream(testTrace.getTrace()));
+        fixture.setStream(new CTFStream(testTrace.getTrace()));
         fixture.setName("");
     }
 
@@ -99,7 +99,7 @@ public class EventDeclarationTest {
         obj.setContext(new StructDeclaration(1L));
         obj.setId(1L);
         obj.setFields(new StructDeclaration(1L));
-        obj.setStream(new Stream(testTrace.getTrace()));
+        obj.setStream(new CTFStream(testTrace.getTrace()));
         obj.setName("");
 
         assertTrue(fixture.equals(fixture));
@@ -217,8 +217,7 @@ public class EventDeclarationTest {
      */
     @Test
     public void testGetId() {
-        Long result = fixture.getId();
-        assertNotNull(result);
+        assertEquals(1,fixture.id());
     }
 
     /**
@@ -235,7 +234,7 @@ public class EventDeclarationTest {
      */
     @Test
     public void testGetStream() {
-        Stream result = fixture.getStream();
+        CTFStream result = fixture.getStream();
         assertNotNull(result);
     }
 
@@ -253,7 +252,7 @@ public class EventDeclarationTest {
      */
     @Test
     public void testHashCode_null() {
-        fixture.setStream((Stream) null);
+        fixture.setStream((CTFStream) null);
         fixture.setName((String) null);
 
         int result = fixture.hashCode();
@@ -303,7 +302,7 @@ public class EventDeclarationTest {
      */
     @Test
     public void testStreamIsSet_null() {
-        fixture.setStream((Stream) null);
+        fixture.setStream((CTFStream) null);
 
         boolean result = fixture.streamIsSet();
         assertEquals(false, result);
@@ -316,26 +315,26 @@ public class EventDeclarationTest {
      */
     @Test
     public void testEventDefinition() throws CTFReaderException {
-        CTFTrace trace = testTrace.getTrace();
-        CTFTraceReader tr = new CTFTraceReader(trace);
-        tr.advance();
-        EventDefinition ed = new EventDefinition(null, null);
-        ed = tr.getCurrentEventDef();
-        assertNotNull(ed);
-        assertNotNull(ed.getPath());
-        assertNotNull(ed.getDeclaration());
-        assertNotNull(ed.getFields());
-        assertNull(ed.getContext());
-        assertNotNull(ed.getPacketContext());
-        assertNotNull(ed.getCPU());
-        assertNotNull(ed.getPacketContext());
-        assertNotNull(ed.getStreamInputReader());
-        assertNull(ed.lookupDefinition("context"));
-        assertNotNull(ed.lookupDefinition("fields"));
-        assertNull(ed.lookupDefinition("other"));
-        assertNotNull(ed.toString());
-        ed.setContext( ed.getFields());
-        assertNotNull(ed.toString());
+        try (CTFTrace trace = testTrace.getTrace();) {
+            EventDefinition ed = null;
+            try (CTFTraceReader tr = new CTFTraceReader(trace);) {
+                tr.advance();
+                ed = tr.getCurrentEventDef();
+            }
+
+            assertNotNull(ed);
+            assertNotNull(ed.getScopePath());
+            assertNotNull(ed.getDeclaration());
+            assertNotNull(ed.getFields());
+            assertNull(ed.getContext());
+            assertNotNull(ed.getPacketContext());
+            assertNotNull(ed.getCPU());
+            assertNotNull(ed.getStreamInputReader());
+            assertNull(ed.lookupDefinition("context"));
+            assertNotNull(ed.lookupDefinition("fields"));
+            assertNull(ed.lookupDefinition("other"));
+            assertNotNull(ed.toString());
+        }
     }
 
     EventDeclaration e1;
This page took 0.026015 seconds and 5 git commands to generate.