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