rcp: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.ctf.core.tests / src / org / eclipse / tracecompass / ctf / core / tests / trace / CTFStreamInputReaderTest.java
index 67706e9fdc8c93f175d3093c3759e0ccdca30eb7..90e2d23d3fab72d2e318561e2a9f37c59ba16308 100644 (file)
@@ -19,14 +19,16 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Set;
 
+import org.eclipse.tracecompass.ctf.core.CTFException;
 import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
+import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
+import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.StringDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StringDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
 import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
-import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.trace.CTFResponse;
 import org.eclipse.tracecompass.ctf.core.trace.CTFStream;
 import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInput;
@@ -36,8 +38,6 @@ import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableList;
-
 /**
  * The class <code>StreamInputReaderTest</code> contains tests for the class
  * <code>{@link CTFStreamInputReader}</code>.
@@ -52,17 +52,13 @@ public class CTFStreamInputReaderTest {
 
     private CTFStreamInputReader fixture;
 
-    private static ImmutableList<String> wrap(String s) {
-        return ImmutableList.<String> builder().add(s).build();
-    }
-
     /**
      * Perform pre-test initialization.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      */
     @Before
-    public void setUp() throws CTFReaderException {
+    public void setUp() throws CTFException {
         fixture = getStreamInputReader();
         fixture.setName(1);
         fixture.setCurrentEvent(new EventDefinition(new EventDeclaration(),
@@ -71,13 +67,12 @@ public class CTFStreamInputReaderTest {
                         new StructDeclaration(0),
                         null,
                         "packet",
-                        wrap("field"),
-                        new Definition[] { new StringDefinition(new StringDeclaration(), null, "field", "test") }),
+                        new Definition[] { new StringDefinition(StringDeclaration.getStringDeclaration(Encoding.UTF8), null, "field", "test") }),
                 null)
                 );
     }
 
-    private static CTFStreamInputReader getStreamInputReader() throws CTFReaderException {
+    private static CTFStreamInputReader getStreamInputReader() throws CTFException {
         assumeTrue(testTrace.exists());
         CTFTrace trace = testTrace.getTrace();
         CTFStream s = trace.getStream((long) 0);
@@ -109,11 +104,11 @@ public class CTFStreamInputReaderTest {
      * Run the StreamInputReader(StreamInput) constructor test, with an invalid
      * trace.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      * @throws IOException
      */
-    @Test(expected = CTFReaderException.class)
-    public void testStreamInputReader_invalid() throws CTFReaderException, IOException {
+    @Test(expected = CTFException.class)
+    public void testStreamInputReader_invalid() throws CTFException, IOException {
         CTFStreamInput streamInput = new CTFStreamInput(new CTFStream(new CTFTrace("")), new File(""));
         try (CTFStreamInputReader result = new CTFStreamInputReader(streamInput)) {
             assertNotNull(result);
@@ -143,7 +138,7 @@ public class CTFStreamInputReaderTest {
      */
     @Test
     public void testGetCurrentPacketContext() {
-        StructDefinition result = fixture.getCurrentEvent().getPacketContext();
+        ICompositeDefinition result = fixture.getCurrentEvent().getPacketContext();
         assertNotNull(result);
     }
 
@@ -159,11 +154,11 @@ public class CTFStreamInputReaderTest {
     /**
      * Run the void goToLastEvent() method test.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      *             error
      */
     @Test
-    public void testGoToLastEvent1() throws CTFReaderException {
+    public void testGoToLastEvent1() throws CTFException {
         final long endTimestamp = goToEnd();
         final long endTime = 4287422460315L;
         assertEquals(endTime, endTimestamp);
@@ -172,11 +167,11 @@ public class CTFStreamInputReaderTest {
     /**
      * Run the void goToLastEvent() method test.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      *             error
      */
     @Test
-    public void testGoToLastEvent2() throws CTFReaderException {
+    public void testGoToLastEvent2() throws CTFException {
         long timestamp = -1;
         while (fixture.readNextEvent().equals(CTFResponse.OK)) {
             timestamp = fixture.getCurrentEvent().getTimestamp();
@@ -185,7 +180,7 @@ public class CTFStreamInputReaderTest {
         assertEquals(0, timestamp - endTimestamp);
     }
 
-    private long goToEnd() throws CTFReaderException {
+    private long goToEnd() throws CTFException {
         fixture.goToLastEvent();
         return fixture.getCurrentEvent().getTimestamp();
     }
@@ -193,22 +188,22 @@ public class CTFStreamInputReaderTest {
     /**
      * Run the boolean readNextEvent() method test.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      *             error
      */
     @Test
-    public void testReadNextEvent() throws CTFReaderException {
+    public void testReadNextEvent() throws CTFException {
         assertEquals(CTFResponse.OK, fixture.readNextEvent());
     }
 
     /**
      * Run the void seek(long) method test. Seek by direct timestamp
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      *             error
      */
     @Test
-    public void testSeek_timestamp() throws CTFReaderException {
+    public void testSeek_timestamp() throws CTFException {
         long timestamp = 1L;
         fixture.seek(timestamp);
     }
@@ -217,10 +212,10 @@ public class CTFStreamInputReaderTest {
      * Run the seek test. Seek by passing an EventDefinition to which we've
      * given the timestamp we want.
      *
-     * @throws CTFReaderException
+     * @throws CTFException
      */
     @Test
-    public void testSeek_eventDefinition() throws CTFReaderException {
+    public void testSeek_eventDefinition() throws CTFException {
         EventDefinition eventDefinition = new EventDefinition(
                 new EventDeclaration(), getStreamInputReader(), 1L, null, null, null, null);
         fixture.setCurrentEvent(eventDefinition);
This page took 0.028511 seconds and 5 git commands to generate.