ctf: Fix API inconsistencies
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamInputTest.java
index 84686a073a43306b6c3c425dbc45cc1edaf37a07..9a1e75ab641d9b0f8fc5cb05712c7812f72b5578 100644 (file)
@@ -1,17 +1,20 @@
 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;
+import java.io.IOException;
 import java.nio.channels.FileChannel;
 
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
 import org.eclipse.linuxtools.ctf.core.tests.TestParams;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.Stream;
 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
-import org.eclipse.linuxtools.ctf.core.trace.StreamInputPacketIndex;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -19,17 +22,18 @@ import org.junit.Test;
 /**
  * The class <code>StreamInputTest</code> contains tests for the class
  * <code>{@link StreamInput}</code>.
- * 
+ *
  * @author ematkho
  * @version $Revision: 1.0 $
  */
+@SuppressWarnings("javadoc")
 public class StreamInputTest {
 
     private StreamInput fixture;
 
     /**
      * Launch the test.
-     * 
+     *
      * @param args
      *            the command line arguments
      */
@@ -39,9 +43,11 @@ public class StreamInputTest {
 
     /**
      * Perform pre-test initialization.
+     *
+     * @throws CTFReaderException
      */
     @Before
-    public void setUp() {
+    public void setUp() throws CTFReaderException {
         fixture = new StreamInput(new Stream(TestParams.createTrace()),
                 (FileChannel) null, createFile());
         fixture.setTimestampEnd(1L);
@@ -69,11 +75,16 @@ public class StreamInputTest {
 
     /**
      * Run the FileChannel getFileChannel() method test.
+     *
+     * @throws IOException
      */
     @Test
-    public void testGetFileChannel() {
+    public void testGetFileChannel() throws IOException {
         FileChannel result = fixture.getFileChannel();
         assertNull(result);
+        if (result != null) {
+            result.close();
+        }
     }
 
     /**
@@ -85,15 +96,6 @@ public class StreamInputTest {
         assertNotNull(result);
     }
 
-    /**
-     * Run the StreamInputPacketIndex getIndex() method test.
-     */
-    @Test
-    public void testGetIndex() {
-        StreamInputPacketIndex result = fixture.getIndex();
-        assertNotNull(result);
-    }
-
     /**
      * Run the String getPath() method test.
      */
@@ -136,5 +138,40 @@ public class StreamInputTest {
     @Test
     public void testSetTimestampEnd() {
         fixture.setTimestampEnd(1L);
+        assertEquals(fixture.getTimestampEnd(), 1L);
+    }
+
+    StreamInput s1;
+    StreamInput s2;
+
+
+    @Test
+    public void testEquals1() throws CTFReaderException{
+        s1 = new StreamInput(new Stream(TestParams.createTrace()),
+                (FileChannel) null, createFile());
+        assertFalse(s1.equals(null));
+    }
+
+    @Test
+    public void testEquals2() throws CTFReaderException{
+        s1 = new StreamInput(new Stream(TestParams.createTrace()),
+                (FileChannel) null, createFile());
+        assertFalse(s1.equals(new Long(23L)));
+
+    }
+    @Test
+    public void testEquals3() throws CTFReaderException{
+        s1 = new StreamInput(new Stream(TestParams.createTrace()),
+                (FileChannel) null, createFile());
+        assertEquals(s1,s1);
+
+    }
+    @Test
+    public void testEquals4() throws CTFReaderException{
+        s1 = new StreamInput(new Stream(TestParams.createTrace()),
+                (FileChannel) null, createFile());
+        s2 = new StreamInput(new Stream(TestParams.createTrace()),
+                (FileChannel) null, createFile());
+        assertEquals(s1,s2);
     }
 }
\ No newline at end of file
This page took 0.025823 seconds and 5 git commands to generate.