ctf: Allow the test traces to be used by other plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.trace;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5 import static org.junit.Assume.assumeTrue;
6
7 import java.nio.channels.FileChannel;
8 import java.util.HashMap;
9 import java.util.Set;
10
11 import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
12 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
13 import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces;
14 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
15 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
16 import org.eclipse.linuxtools.ctf.core.trace.Stream;
17 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
18 import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
19 import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Test;
23
24 /**
25 * The class <code>StreamTest</code> contains tests for the class
26 * <code>{@link Stream}</code>.
27 *
28 * @author ematkho
29 * @version $Revision: 1.0 $
30 */
31 @SuppressWarnings("javadoc")
32 public class StreamTest {
33
34 private static final int TRACE_INDEX = 0;
35
36 private Stream fixture;
37
38 /**
39 * Launch the test.
40 *
41 * @param args
42 * the command line arguments
43 */
44 public static void main(String[] args) {
45 new org.junit.runner.JUnitCore().run(StreamTest.class);
46 }
47
48 /**
49 * Perform pre-test initialization.
50 *
51 * @throws CTFReaderException
52 */
53 @Before
54 public void setUp() throws CTFReaderException {
55 assumeTrue(CtfTestTraces.tracesExist());
56 fixture = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
57 fixture.setEventContext(new StructDeclaration(1L));
58 fixture.setPacketContext(new StructDeclaration(1L));
59 fixture.setEventHeader(new StructDeclaration(1L));
60 fixture.setId(1L);
61 fixture.addInput(new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)),
62 (FileChannel) null, CtfTestTraces.getEmptyFile()));
63 }
64
65 /**
66 * Perform post-test clean-up.
67 */
68 @After
69 public void tearDown() {
70 // Add additional tear down code here
71 }
72
73 /**
74 * Run the Stream(CTFTrace) constructor test.
75 *
76 * @throws CTFReaderException
77 */
78 @Test
79 public void testStream() throws CTFReaderException {
80 CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX);
81 Stream result = new Stream(trace);
82 assertNotNull(result);
83 }
84
85 /**
86 * Run the void addEvent(EventDeclaration) method test with the basic
87 * event.
88 * @throws ParseException
89 */
90 @Test
91 public void testAddEvent_base() throws ParseException {
92 EventDeclaration event = new EventDeclaration();
93 fixture.addEvent(event);
94 }
95
96 /**
97 * Run the boolean eventContextIsSet() method test.
98 */
99 @Test
100 public void testEventContextIsSet() {
101 assertTrue(fixture.isEventContextSet());
102 }
103 /**
104 * Run the boolean eventContextIsSet() method test.
105 */
106 @Test
107 public void testToString() {
108 assertNotNull(fixture.toString());
109 }
110
111 /**
112 * Run the boolean eventHeaderIsSet() method test.
113 */
114 @Test
115 public void testEventHeaderIsSet() {
116 assertTrue(fixture.isEventHeaderSet());
117 }
118
119 /**
120 * Run the StructDeclaration getEventContextDecl() method test.
121 */
122 @Test
123 public void testGetEventContextDecl() {
124 assertNotNull(fixture.getEventContextDecl());
125 }
126
127 /**
128 * Run the StructDeclaration getEventHeaderDecl() method test.
129 */
130 @Test
131 public void testGetEventHeaderDecl() {
132 assertNotNull(fixture.getEventHeaderDecl());
133 }
134
135 /**
136 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
137 */
138 @Test
139 public void testGetEvents() {
140 HashMap<Long, IEventDeclaration> result = fixture.getEvents();
141 assertNotNull(result);
142 }
143
144 /**
145 * Run the Long getId() method test.
146 */
147 @Test
148 public void testGetId() {
149 Long result = fixture.getId();
150 assertNotNull(result);
151 }
152
153 /**
154 * Run the StructDeclaration getPacketContextDecl() method test.
155 */
156 @Test
157 public void testGetPacketContextDecl() {
158 StructDeclaration result = fixture.getPacketContextDecl();
159 assertNotNull(result);
160 }
161
162 /**
163 * Run the Set<StreamInput> getStreamInputs() method test.
164 */
165 @Test
166 public void testGetStreamInputs() {
167 Set<StreamInput> result = fixture.getStreamInputs();
168 assertNotNull(result);
169 }
170
171 /**
172 * Run the CTFTrace getTrace() method test.
173 */
174 @Test
175 public void testGetTrace() {
176 CTFTrace result = fixture.getTrace();
177 assertNotNull(result);
178 }
179
180 /**
181 * Run the boolean idIsSet() method test.
182 */
183 @Test
184 public void testIdIsSet() {
185 boolean result = fixture.isIdSet();
186 assertTrue(result);
187 }
188
189 /**
190 * Run the boolean packetContextIsSet() method test.
191 */
192 @Test
193 public void testPacketContextIsSet() {
194 boolean result = fixture.isPacketContextSet();
195 assertTrue(result);
196 }
197
198
199 /**
200 * Run the void setEventContext(StructDeclaration) method test.
201 */
202 @Test
203 public void testSetEventContext() {
204 StructDeclaration eventContext = new StructDeclaration(1L);
205 fixture.setEventContext(eventContext);
206 }
207
208 /**
209 * Run the void setEventHeader(StructDeclaration) method test.
210 */
211 @Test
212 public void testSetEventHeader() {
213 StructDeclaration eventHeader = new StructDeclaration(1L);
214 fixture.setEventHeader(eventHeader);
215 }
216
217 /**
218 * Run the void setId(long) method test.
219 */
220 @Test
221 public void testSetId() {
222 long id = 1L;
223 fixture.setId(id);
224 }
225
226 /**
227 * Run the void setPacketContext(StructDeclaration) method test.
228 */
229 @Test
230 public void testSetPacketContext() {
231 StructDeclaration packetContext = new StructDeclaration(1L);
232 fixture.setPacketContext(packetContext);
233 }
234 }
This page took 0.048012 seconds and 6 git commands to generate.