Commit | Line | Data |
---|---|---|
4bd7f2db AM |
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 | ||
866e5b51 FC |
12 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
13 | ||
14 | import static org.junit.Assert.assertNotNull; | |
15 | import static org.junit.Assert.assertTrue; | |
e5acb357 | 16 | import static org.junit.Assume.assumeTrue; |
866e5b51 FC |
17 | |
18 | import java.nio.channels.FileChannel; | |
0594c61c | 19 | import java.util.Map; |
866e5b51 FC |
20 | import java.util.Set; |
21 | ||
8e964be1 | 22 | import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; |
866e5b51 | 23 | import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; |
32bf80d2 | 24 | import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; |
13be1a8f | 25 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
866e5b51 | 26 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; |
486efb2e AM |
27 | import org.eclipse.linuxtools.ctf.core.trace.Stream; |
28 | import org.eclipse.linuxtools.ctf.core.trace.StreamInput; | |
8e964be1 | 29 | import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration; |
ce2388e0 | 30 | import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException; |
866e5b51 FC |
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>. | |
e291b8c8 | 37 | * |
866e5b51 FC |
38 | * @author ematkho |
39 | * @version $Revision: 1.0 $ | |
40 | */ | |
be6df2d8 | 41 | @SuppressWarnings("javadoc") |
866e5b51 FC |
42 | public class StreamTest { |
43 | ||
32bf80d2 AM |
44 | private static final int TRACE_INDEX = 0; |
45 | ||
866e5b51 FC |
46 | private Stream fixture; |
47 | ||
866e5b51 FC |
48 | /** |
49 | * Perform pre-test initialization. | |
788ddcbc MK |
50 | * |
51 | * @throws CTFReaderException | |
866e5b51 FC |
52 | */ |
53 | @Before | |
13be1a8f | 54 | public void setUp() throws CTFReaderException { |
32bf80d2 AM |
55 | assumeTrue(CtfTestTraces.tracesExist()); |
56 | fixture = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)); | |
866e5b51 FC |
57 | fixture.setEventContext(new StructDeclaration(1L)); |
58 | fixture.setPacketContext(new StructDeclaration(1L)); | |
59 | fixture.setEventHeader(new StructDeclaration(1L)); | |
60 | fixture.setId(1L); | |
32bf80d2 AM |
61 | fixture.addInput(new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), |
62 | (FileChannel) null, CtfTestTraces.getEmptyFile())); | |
866e5b51 FC |
63 | } |
64 | ||
866e5b51 FC |
65 | /** |
66 | * Run the Stream(CTFTrace) constructor test. | |
788ddcbc MK |
67 | * |
68 | * @throws CTFReaderException | |
866e5b51 FC |
69 | */ |
70 | @Test | |
13be1a8f | 71 | public void testStream() throws CTFReaderException { |
32bf80d2 | 72 | CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); |
866e5b51 FC |
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. | |
e291b8c8 | 80 | * @throws ParseException |
866e5b51 FC |
81 | */ |
82 | @Test | |
83 | public void testAddEvent_base() throws ParseException { | |
84 | EventDeclaration event = new EventDeclaration(); | |
85 | fixture.addEvent(event); | |
86 | } | |
87 | ||
866e5b51 FC |
88 | /** |
89 | * Run the boolean eventContextIsSet() method test. | |
90 | */ | |
91 | @Test | |
92 | public void testEventContextIsSet() { | |
9ac2eb62 | 93 | assertTrue(fixture.isEventContextSet()); |
866e5b51 | 94 | } |
e291b8c8 MK |
95 | /** |
96 | * Run the boolean eventContextIsSet() method test. | |
97 | */ | |
98 | @Test | |
99 | public void testToString() { | |
100 | assertNotNull(fixture.toString()); | |
101 | } | |
866e5b51 FC |
102 | |
103 | /** | |
104 | * Run the boolean eventHeaderIsSet() method test. | |
105 | */ | |
106 | @Test | |
107 | public void testEventHeaderIsSet() { | |
9ac2eb62 | 108 | assertTrue(fixture.isEventHeaderSet()); |
866e5b51 FC |
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() { | |
0594c61c | 132 | Map<Long, IEventDeclaration> result = fixture.getEvents(); |
866e5b51 FC |
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() { | |
9ac2eb62 | 177 | boolean result = fixture.isIdSet(); |
866e5b51 FC |
178 | assertTrue(result); |
179 | } | |
180 | ||
181 | /** | |
182 | * Run the boolean packetContextIsSet() method test. | |
183 | */ | |
184 | @Test | |
185 | public void testPacketContextIsSet() { | |
9ac2eb62 | 186 | boolean result = fixture.isPacketContextSet(); |
866e5b51 FC |
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 | } |