Updated some javadoc in org.eclipse.linuxtools.tmf.core plug-in
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamInputPacketIndexTest.java
CommitLineData
866e5b51
FC
1package org.eclipse.linuxtools.ctf.core.tests.trace;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotNull;
5
6import java.util.Collection;
7import java.util.ListIterator;
8
9import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
ce2388e0
FC
10import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndex;
11import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndexEntry;
866e5b51
FC
12import org.junit.After;
13import org.junit.Before;
14import org.junit.Test;
15
16/**
17 * The class <code>StreamInputPacketIndexTest</code> contains tests for the
18 * class <code>{@link StreamInputPacketIndex}</code>.
ce2388e0 19 *
866e5b51
FC
20 * @author ematkho
21 * @version $Revision: 1.0 $
22 */
23public class StreamInputPacketIndexTest {
24
25 private StreamInputPacketIndex fixture;
26 private StreamInputPacketIndexEntry entry;
27
28 /**
29 * Launch the test.
ce2388e0 30 *
866e5b51
FC
31 * @param args
32 * the command line arguments
33 */
34 public static void main(String[] args) {
35 new org.junit.runner.JUnitCore().run(StreamInputPacketIndexTest.class);
36 }
37
38 /**
39 * Perform pre-test initialization.
ce2388e0 40 *
866e5b51
FC
41 * @throws CTFReaderException
42 */
43 @Before
44 public void setUp() throws CTFReaderException {
45 fixture = new StreamInputPacketIndex();
46 fixture.addEntry(new StreamInputPacketIndexEntry(1L));
47 entry = new StreamInputPacketIndexEntry(1L);
48 }
49
50 /**
51 * Perform post-test clean-up.
52 */
53 @After
54 public void tearDown() {
55 // Add additional tear down code here
56 }
57
58 /**
59 * Run the StreamInputPacketIndex() constructor test.
60 */
61 @Test
62 public void testStreamInputPacketIndex() {
63 assertNotNull(fixture);
64 }
65
66 /**
67 * Run the void addEntry(StreamInputPacketIndexEntry) method test, by
68 * specifying only 1 parameter to the entry.
ce2388e0 69 *
866e5b51
FC
70 * @throws CTFReaderException
71 */
72 @Test
73 public void testAddEntry_1param() throws CTFReaderException {
ce2388e0 74 entry.setPacketSizeBits(0);
866e5b51
FC
75 fixture.addEntry(entry);
76 }
77
78 /**
79 * Run the void addEntry(StreamInputPacketIndexEntry) method test by
80 * specifying 2 parameters to the entry.
ce2388e0 81 *
866e5b51
FC
82 * @throws CTFReaderException
83 */
84 @Test
85 public void testAddEntry_2params() throws CTFReaderException {
ce2388e0
FC
86 entry.setPacketSizeBits(1);
87 entry.setContentSizeBits(0);
866e5b51
FC
88 fixture.addEntry(entry);
89 }
90
91 /**
92 * Run the void addEntry(StreamInputPacketIndexEntry) method test, by
93 * specifying all 4 parameters to the entry.
ce2388e0 94 *
866e5b51
FC
95 * @throws CTFReaderException
96 */
97 @Test
98 public void testAddEntry_4params() throws CTFReaderException {
ce2388e0
FC
99 entry.setTimestampBegin(1L);
100 entry.setPacketSizeBits(1);
101 entry.setContentSizeBits(1);
102 entry.setTimestampEnd(1L);
866e5b51
FC
103 fixture.addEntry(entry);
104 }
105
106 /**
107 * Run the Collection<StreamInputPacketIndexEntry> getEntries() method test.
108 */
109 @Test
110 public void testGetEntries() {
111 Collection<StreamInputPacketIndexEntry> result = fixture.getEntries();
112
113 assertNotNull(result);
114 assertEquals(1, result.size());
115 }
116
117 /**
118 * Run the ListIterator<StreamInputPacketIndexEntry> listIterator() method
119 * test, with no parameter to listIterator().
120 */
121 @Test
122 public void testListIterator_noparam() {
123 ListIterator<StreamInputPacketIndexEntry> result = fixture.listIterator();
124
125 assertNotNull(result);
126 assertEquals(true, result.hasNext());
127 assertEquals(-1, result.previousIndex());
128 assertEquals(false, result.hasPrevious());
129 assertEquals(0, result.nextIndex());
130 }
131
132 /**
133 * Run the ListIterator<StreamInputPacketIndexEntry> listIterator(n) method
134 * test, with n = 1.
135 */
136 @Test
137 public void testListIterator_withparam() {
138 ListIterator<StreamInputPacketIndexEntry> result = fixture.listIterator(1);
139
140 assertNotNull(result);
141 assertEquals(false, result.hasNext());
142 assertEquals(0, result.previousIndex());
143 assertEquals(true, result.hasPrevious());
144 assertEquals(1, result.nextIndex());
145 assertEquals(false, result.hasNext());
146 }
147
148 /**
149 * Run the ListIterator<StreamInputPacketIndexEntry> search(long) method
150 * test with a valid timestamp.
151 */
152 @Test
153 public void testSearch_valid() {
154 ListIterator<StreamInputPacketIndexEntry> result = fixture.search(1L);
155
156 assertNotNull(result);
157 assertEquals(true, result.hasNext());
158 assertEquals(-1, result.previousIndex());
159 assertEquals(false, result.hasPrevious());
160 assertEquals(0, result.nextIndex());
161 }
162
163 /**
164 * Run the ListIterator<StreamInputPacketIndexEntry> search(long) method
165 * test with an invalid timestamp.
166 */
167 @Test(expected = java.lang.IllegalArgumentException.class)
168 public void testSearch_invalid() {
169 ListIterator<StreamInputPacketIndexEntry> result = fixture.search(-1L);
170
171 assertNotNull(result);
172 }
173}
This page took 0.032504 seconds and 5 git commands to generate.