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