Merge branch 'master' into lttng-luna
[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.io.File;
19 import java.nio.channels.FileChannel;
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.Stream;
29 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
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 Stream}</code>.
38 *
39 * @author ematkho
40 * @version $Revision: 1.0 $
41 */
42 @SuppressWarnings("javadoc")
43 public class StreamTest {
44
45 private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
46
47 private Stream 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 Stream(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 StreamInput(new Stream(testTrace.getTrace()),
63 (FileChannel) null, new File("")));
64 }
65
66 /**
67 * Run the Stream(CTFTrace) constructor test.
68 *
69 * @throws CTFReaderException
70 */
71 @Test
72 public void testStream() throws CTFReaderException {
73 CTFTrace trace = testTrace.getTrace();
74 Stream result = new Stream(trace);
75 assertNotNull(result);
76 }
77
78 /**
79 * Run the void addEvent(EventDeclaration) method test with the basic
80 * event.
81 * @throws ParseException
82 */
83 @Test
84 public void testAddEvent_base() throws ParseException {
85 EventDeclaration event = new EventDeclaration();
86 fixture.addEvent(event);
87 }
88
89 /**
90 * Run the boolean eventContextIsSet() method test.
91 */
92 @Test
93 public void testEventContextIsSet() {
94 assertTrue(fixture.isEventContextSet());
95 }
96 /**
97 * Run the boolean eventContextIsSet() method test.
98 */
99 @Test
100 public void testToString() {
101 assertNotNull(fixture.toString());
102 }
103
104 /**
105 * Run the boolean eventHeaderIsSet() method test.
106 */
107 @Test
108 public void testEventHeaderIsSet() {
109 assertTrue(fixture.isEventHeaderSet());
110 }
111
112 /**
113 * Run the StructDeclaration getEventContextDecl() method test.
114 */
115 @Test
116 public void testGetEventContextDecl() {
117 assertNotNull(fixture.getEventContextDecl());
118 }
119
120 /**
121 * Run the StructDeclaration getEventHeaderDecl() method test.
122 */
123 @Test
124 public void testGetEventHeaderDecl() {
125 assertNotNull(fixture.getEventHeaderDecl());
126 }
127
128 /**
129 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
130 */
131 @Test
132 public void testGetEvents() {
133 Map<Long, IEventDeclaration> result = fixture.getEvents();
134 assertNotNull(result);
135 }
136
137 /**
138 * Run the Long getId() method test.
139 */
140 @Test
141 public void testGetId() {
142 Long result = fixture.getId();
143 assertNotNull(result);
144 }
145
146 /**
147 * Run the StructDeclaration getPacketContextDecl() method test.
148 */
149 @Test
150 public void testGetPacketContextDecl() {
151 StructDeclaration result = fixture.getPacketContextDecl();
152 assertNotNull(result);
153 }
154
155 /**
156 * Run the Set<StreamInput> getStreamInputs() method test.
157 */
158 @Test
159 public void testGetStreamInputs() {
160 Set<StreamInput> result = fixture.getStreamInputs();
161 assertNotNull(result);
162 }
163
164 /**
165 * Run the CTFTrace getTrace() method test.
166 */
167 @Test
168 public void testGetTrace() {
169 CTFTrace result = fixture.getTrace();
170 assertNotNull(result);
171 }
172
173 /**
174 * Run the boolean idIsSet() method test.
175 */
176 @Test
177 public void testIdIsSet() {
178 boolean result = fixture.isIdSet();
179 assertTrue(result);
180 }
181
182 /**
183 * Run the boolean packetContextIsSet() method test.
184 */
185 @Test
186 public void testPacketContextIsSet() {
187 boolean result = fixture.isPacketContextSet();
188 assertTrue(result);
189 }
190
191
192 /**
193 * Run the void setEventContext(StructDeclaration) method test.
194 */
195 @Test
196 public void testSetEventContext() {
197 StructDeclaration eventContext = new StructDeclaration(1L);
198 fixture.setEventContext(eventContext);
199 }
200
201 /**
202 * Run the void setEventHeader(StructDeclaration) method test.
203 */
204 @Test
205 public void testSetEventHeader() {
206 StructDeclaration eventHeader = new StructDeclaration(1L);
207 fixture.setEventHeader(eventHeader);
208 }
209
210 /**
211 * Run the void setId(long) method test.
212 */
213 @Test
214 public void testSetId() {
215 long id = 1L;
216 fixture.setId(id);
217 }
218
219 /**
220 * Run the void setPacketContext(StructDeclaration) method test.
221 */
222 @Test
223 public void testSetPacketContext() {
224 StructDeclaration packetContext = new StructDeclaration(1L);
225 fixture.setPacketContext(packetContext);
226 }
227 }
This page took 0.035974 seconds and 6 git commands to generate.