ctf: Clean up unit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamTest.java
index cf660c8f9fbd545b87db965f6504e19d27bd661a..568262d23b455ab4019a7a3edd4732b67858fab2 100644 (file)
@@ -1,21 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
 package org.eclipse.linuxtools.ctf.core.tests.trace;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
 
 import java.nio.channels.FileChannel;
 import java.util.HashMap;
 import java.util.Set;
 
-import org.eclipse.linuxtools.ctf.core.event.EventDeclaration;
-import org.eclipse.linuxtools.ctf.core.event.metadata.exceptions.ParseException;
+import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
-import org.eclipse.linuxtools.ctf.core.tests.TestParams;
+import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces;
 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.ctf.core.trace.StreamInput;
-import org.junit.After;
+import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -26,52 +38,38 @@ import org.junit.Test;
  * @author ematkho
  * @version $Revision: 1.0 $
  */
+@SuppressWarnings("javadoc")
 public class StreamTest {
 
-    private Stream fixture;
+    private static final int TRACE_INDEX = 0;
 
-    /**
-     * Launch the test.
-     *
-     * @param args
-     *            the command line arguments
-     */
-    public static void main(String[] args) {
-        new org.junit.runner.JUnitCore().run(StreamTest.class);
-    }
+    private Stream fixture;
 
     /**
      * Perform pre-test initialization.
-     * 
-     * @throws CTFReaderException 
+     *
+     * @throws CTFReaderException
      */
     @Before
     public void setUp() throws CTFReaderException {
-        fixture = new Stream(TestParams.createTrace());
+        assumeTrue(CtfTestTraces.tracesExist());
+        fixture = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
         fixture.setEventContext(new StructDeclaration(1L));
         fixture.setPacketContext(new StructDeclaration(1L));
         fixture.setEventHeader(new StructDeclaration(1L));
         fixture.setId(1L);
-        fixture.addInput(new StreamInput(new Stream(TestParams.createTrace()),
-                (FileChannel) null, TestParams.getEmptyFile()));
-    }
-
-    /**
-     * Perform post-test clean-up.
-     */
-    @After
-    public void tearDown() {
-        // Add additional tear down code here
+        fixture.addInput(new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)),
+                (FileChannel) null, CtfTestTraces.getEmptyFile()));
     }
 
     /**
      * Run the Stream(CTFTrace) constructor test.
-     * 
-     * @throws CTFReaderException 
+     *
+     * @throws CTFReaderException
      */
     @Test
     public void testStream() throws CTFReaderException {
-        CTFTrace trace = TestParams.createTrace();
+        CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX);
         Stream result = new Stream(trace);
         assertNotNull(result);
     }
@@ -87,27 +85,12 @@ public class StreamTest {
         fixture.addEvent(event);
     }
 
-    /**
-     * Run the void addEvent(EventDeclaration) method test with an event
-     * of which we modified the id.
-     * @throws ParseException
-     *
-     * @throws ParseException
-     */
-    @Test
-    public void testAddEvent_modifiedEvent() throws ParseException {
-        EventDeclaration event = new EventDeclaration();
-        event.setId(1L);
-        fixture.addEvent(event);
-        assertNotNull(fixture);
-    }
-
     /**
      * Run the boolean eventContextIsSet() method test.
      */
     @Test
     public void testEventContextIsSet() {
-        assertTrue(fixture.eventContextIsSet());
+        assertTrue(fixture.isEventContextSet());
     }
     /**
      * Run the boolean eventContextIsSet() method test.
@@ -122,7 +105,7 @@ public class StreamTest {
      */
     @Test
     public void testEventHeaderIsSet() {
-        assertTrue(fixture.eventHeaderIsSet());
+        assertTrue(fixture.isEventHeaderSet());
     }
 
     /**
@@ -146,7 +129,7 @@ public class StreamTest {
      */
     @Test
     public void testGetEvents() {
-        HashMap<Long, EventDeclaration> result = fixture.getEvents();
+        HashMap<Long, IEventDeclaration> result = fixture.getEvents();
         assertNotNull(result);
     }
 
@@ -191,7 +174,7 @@ public class StreamTest {
      */
     @Test
     public void testIdIsSet() {
-        boolean result = fixture.idIsSet();
+        boolean result = fixture.isIdSet();
         assertTrue(result);
     }
 
@@ -200,7 +183,7 @@ public class StreamTest {
      */
     @Test
     public void testPacketContextIsSet() {
-        boolean result = fixture.packetContextIsSet();
+        boolean result = fixture.isPacketContextSet();
         assertTrue(result);
     }
 
This page took 0.025992 seconds and 5 git commands to generate.