ctf: Rename Stream* classes to CTFStream*
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / CTFStreamTest.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.io.File;
19 import java.io.FilenameFilter;
20 import java.util.Map;
21 import java.util.Set;
22
23 import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
24 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
25 import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
26 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
27 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
28 import org.eclipse.linuxtools.ctf.core.trace.CTFStream;
29 import org.eclipse.linuxtools.ctf.core.trace.CTFStreamInput;
30 import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
31 import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
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 CTFStream}</code>.
38 *
39 * @author ematkho
40 * @version $Revision: 1.0 $
41 */
42 @SuppressWarnings("javadoc")
43 public class CTFStreamTest {
44
45 private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
46
47 private CTFStream fixture;
48
49 /**
50 * Perform pre-test initialization.
51 *
52 * @throws CTFReaderException
53 */
54 @Before
55 public void setUp() throws CTFReaderException {
56 assumeTrue(testTrace.exists());
57 fixture = new CTFStream(testTrace.getTrace());
58 fixture.setEventContext(new StructDeclaration(1L));
59 fixture.setPacketContext(new StructDeclaration(1L));
60 fixture.setEventHeader(new StructDeclaration(1L));
61 fixture.setId(1L);
62 fixture.addInput(new CTFStreamInput(new CTFStream(testTrace.getTrace()), createFile()));
63 }
64
65 private static File createFile() {
66 File path = new File(testTrace.getPath());
67 return path.listFiles(new FilenameFilter() {
68 @Override
69 public boolean accept(File dir, String name) {
70 if (name.contains("hann")) {
71 return true;
72 }
73 return false;
74 }
75 })[0];
76 }
77
78 /**
79 * Run the Stream(CTFTrace) constructor test.
80 *
81 * @throws CTFReaderException
82 */
83 @Test
84 public void testStream() throws CTFReaderException {
85 CTFTrace trace = testTrace.getTrace();
86 CTFStream result = new CTFStream(trace);
87 assertNotNull(result);
88 }
89
90 /**
91 * Run the void addEvent(EventDeclaration) method test with the basic event.
92 *
93 * @throws ParseException
94 */
95 @Test
96 public void testAddEvent_base() throws ParseException {
97 EventDeclaration event = new EventDeclaration();
98 fixture.addEvent(event);
99 }
100
101 /**
102 * Run the boolean eventContextIsSet() method test.
103 */
104 @Test
105 public void testEventContextIsSet() {
106 assertTrue(fixture.isEventContextSet());
107 }
108
109 /**
110 * Run the boolean eventContextIsSet() method test.
111 */
112 @Test
113 public void testToString() {
114 assertNotNull(fixture.toString());
115 }
116
117 /**
118 * Run the boolean eventHeaderIsSet() method test.
119 */
120 @Test
121 public void testEventHeaderIsSet() {
122 assertTrue(fixture.isEventHeaderSet());
123 }
124
125 /**
126 * Run the StructDeclaration getEventContextDecl() method test.
127 */
128 @Test
129 public void testGetEventContextDecl() {
130 assertNotNull(fixture.getEventContextDecl());
131 }
132
133 /**
134 * Run the StructDeclaration getEventHeaderDecl() method test.
135 */
136 @Test
137 public void testGetEventHeaderDecl() {
138 assertNotNull(fixture.getEventHeaderDecl());
139 }
140
141 /**
142 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
143 */
144 @Test
145 public void testGetEvents() {
146 Map<Long, IEventDeclaration> result = fixture.getEvents();
147 assertNotNull(result);
148 }
149
150 /**
151 * Run the Long getId() method test.
152 */
153 @Test
154 public void testGetId() {
155 Long result = fixture.getId();
156 assertNotNull(result);
157 }
158
159 /**
160 * Run the StructDeclaration getPacketContextDecl() method test.
161 */
162 @Test
163 public void testGetPacketContextDecl() {
164 StructDeclaration result = fixture.getPacketContextDecl();
165 assertNotNull(result);
166 }
167
168 /**
169 * Run the Set<StreamInput> getStreamInputs() method test.
170 */
171 @Test
172 public void testGetStreamInputs() {
173 Set<CTFStreamInput> result = fixture.getStreamInputs();
174 assertNotNull(result);
175 }
176
177 /**
178 * Run the CTFTrace getTrace() method test.
179 */
180 @Test
181 public void testGetTrace() {
182 CTFTrace result = fixture.getTrace();
183 assertNotNull(result);
184 }
185
186 /**
187 * Run the boolean idIsSet() method test.
188 */
189 @Test
190 public void testIdIsSet() {
191 boolean result = fixture.isIdSet();
192 assertTrue(result);
193 }
194
195 /**
196 * Run the boolean packetContextIsSet() method test.
197 */
198 @Test
199 public void testPacketContextIsSet() {
200 boolean result = fixture.isPacketContextSet();
201 assertTrue(result);
202 }
203
204 /**
205 * Run the void setEventContext(StructDeclaration) method test.
206 */
207 @Test
208 public void testSetEventContext() {
209 StructDeclaration eventContext = new StructDeclaration(1L);
210 fixture.setEventContext(eventContext);
211 }
212
213 /**
214 * Run the void setEventHeader(StructDeclaration) method test.
215 */
216 @Test
217 public void testSetEventHeader() {
218 StructDeclaration eventHeader = new StructDeclaration(1L);
219 fixture.setEventHeader(eventHeader);
220 }
221
222 /**
223 * Run the void setId(long) method test.
224 */
225 @Test
226 public void testSetId() {
227 long id = 1L;
228 fixture.setId(id);
229 }
230
231 /**
232 * Run the void setPacketContext(StructDeclaration) method test.
233 */
234 @Test
235 public void testSetPacketContext() {
236 StructDeclaration packetContext = new StructDeclaration(1L);
237 fixture.setPacketContext(packetContext);
238 }
239 }
This page took 0.035399 seconds and 5 git commands to generate.