Commit | Line | Data |
---|---|---|
866e5b51 FC |
1 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
2 | ||
3 | import static org.junit.Assert.assertNotNull; | |
4 | import static org.junit.Assert.assertTrue; | |
e5acb357 | 5 | import static org.junit.Assume.assumeTrue; |
866e5b51 FC |
6 | |
7 | import java.nio.channels.FileChannel; | |
8 | import java.util.HashMap; | |
9 | import java.util.Set; | |
10 | ||
8e964be1 | 11 | import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; |
866e5b51 | 12 | import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; |
32bf80d2 | 13 | import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; |
13be1a8f | 14 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
866e5b51 | 15 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; |
486efb2e AM |
16 | import org.eclipse.linuxtools.ctf.core.trace.Stream; |
17 | import org.eclipse.linuxtools.ctf.core.trace.StreamInput; | |
8e964be1 | 18 | import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration; |
ce2388e0 | 19 | import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException; |
866e5b51 FC |
20 | import org.junit.After; |
21 | import org.junit.Before; | |
22 | import org.junit.Test; | |
23 | ||
24 | /** | |
25 | * The class <code>StreamTest</code> contains tests for the class | |
26 | * <code>{@link Stream}</code>. | |
e291b8c8 | 27 | * |
866e5b51 FC |
28 | * @author ematkho |
29 | * @version $Revision: 1.0 $ | |
30 | */ | |
be6df2d8 | 31 | @SuppressWarnings("javadoc") |
866e5b51 FC |
32 | public class StreamTest { |
33 | ||
32bf80d2 AM |
34 | private static final int TRACE_INDEX = 0; |
35 | ||
866e5b51 FC |
36 | private Stream fixture; |
37 | ||
38 | /** | |
39 | * Launch the test. | |
e291b8c8 | 40 | * |
866e5b51 FC |
41 | * @param args |
42 | * the command line arguments | |
43 | */ | |
44 | public static void main(String[] args) { | |
45 | new org.junit.runner.JUnitCore().run(StreamTest.class); | |
46 | } | |
47 | ||
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 | ||
65 | /** | |
66 | * Perform post-test clean-up. | |
67 | */ | |
68 | @After | |
69 | public void tearDown() { | |
70 | // Add additional tear down code here | |
71 | } | |
72 | ||
73 | /** | |
74 | * Run the Stream(CTFTrace) constructor test. | |
788ddcbc MK |
75 | * |
76 | * @throws CTFReaderException | |
866e5b51 FC |
77 | */ |
78 | @Test | |
13be1a8f | 79 | public void testStream() throws CTFReaderException { |
32bf80d2 | 80 | CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); |
866e5b51 FC |
81 | Stream result = new Stream(trace); |
82 | assertNotNull(result); | |
83 | } | |
84 | ||
85 | /** | |
86 | * Run the void addEvent(EventDeclaration) method test with the basic | |
87 | * event. | |
e291b8c8 | 88 | * @throws ParseException |
866e5b51 FC |
89 | */ |
90 | @Test | |
91 | public void testAddEvent_base() throws ParseException { | |
92 | EventDeclaration event = new EventDeclaration(); | |
93 | fixture.addEvent(event); | |
94 | } | |
95 | ||
866e5b51 FC |
96 | /** |
97 | * Run the boolean eventContextIsSet() method test. | |
98 | */ | |
99 | @Test | |
100 | public void testEventContextIsSet() { | |
9ac2eb62 | 101 | assertTrue(fixture.isEventContextSet()); |
866e5b51 | 102 | } |
e291b8c8 MK |
103 | /** |
104 | * Run the boolean eventContextIsSet() method test. | |
105 | */ | |
106 | @Test | |
107 | public void testToString() { | |
108 | assertNotNull(fixture.toString()); | |
109 | } | |
866e5b51 FC |
110 | |
111 | /** | |
112 | * Run the boolean eventHeaderIsSet() method test. | |
113 | */ | |
114 | @Test | |
115 | public void testEventHeaderIsSet() { | |
9ac2eb62 | 116 | assertTrue(fixture.isEventHeaderSet()); |
866e5b51 FC |
117 | } |
118 | ||
119 | /** | |
120 | * Run the StructDeclaration getEventContextDecl() method test. | |
121 | */ | |
122 | @Test | |
123 | public void testGetEventContextDecl() { | |
124 | assertNotNull(fixture.getEventContextDecl()); | |
125 | } | |
126 | ||
127 | /** | |
128 | * Run the StructDeclaration getEventHeaderDecl() method test. | |
129 | */ | |
130 | @Test | |
131 | public void testGetEventHeaderDecl() { | |
132 | assertNotNull(fixture.getEventHeaderDecl()); | |
133 | } | |
134 | ||
135 | /** | |
136 | * Run the HashMap<Long, EventDeclaration> getEvents() method test. | |
137 | */ | |
138 | @Test | |
139 | public void testGetEvents() { | |
8e964be1 | 140 | HashMap<Long, IEventDeclaration> result = fixture.getEvents(); |
866e5b51 FC |
141 | assertNotNull(result); |
142 | } | |
143 | ||
144 | /** | |
145 | * Run the Long getId() method test. | |
146 | */ | |
147 | @Test | |
148 | public void testGetId() { | |
149 | Long result = fixture.getId(); | |
150 | assertNotNull(result); | |
151 | } | |
152 | ||
153 | /** | |
154 | * Run the StructDeclaration getPacketContextDecl() method test. | |
155 | */ | |
156 | @Test | |
157 | public void testGetPacketContextDecl() { | |
158 | StructDeclaration result = fixture.getPacketContextDecl(); | |
159 | assertNotNull(result); | |
160 | } | |
161 | ||
162 | /** | |
163 | * Run the Set<StreamInput> getStreamInputs() method test. | |
164 | */ | |
165 | @Test | |
166 | public void testGetStreamInputs() { | |
167 | Set<StreamInput> result = fixture.getStreamInputs(); | |
168 | assertNotNull(result); | |
169 | } | |
170 | ||
171 | /** | |
172 | * Run the CTFTrace getTrace() method test. | |
173 | */ | |
174 | @Test | |
175 | public void testGetTrace() { | |
176 | CTFTrace result = fixture.getTrace(); | |
177 | assertNotNull(result); | |
178 | } | |
179 | ||
180 | /** | |
181 | * Run the boolean idIsSet() method test. | |
182 | */ | |
183 | @Test | |
184 | public void testIdIsSet() { | |
9ac2eb62 | 185 | boolean result = fixture.isIdSet(); |
866e5b51 FC |
186 | assertTrue(result); |
187 | } | |
188 | ||
189 | /** | |
190 | * Run the boolean packetContextIsSet() method test. | |
191 | */ | |
192 | @Test | |
193 | public void testPacketContextIsSet() { | |
9ac2eb62 | 194 | boolean result = fixture.isPacketContextSet(); |
866e5b51 FC |
195 | assertTrue(result); |
196 | } | |
197 | ||
198 | ||
199 | /** | |
200 | * Run the void setEventContext(StructDeclaration) method test. | |
201 | */ | |
202 | @Test | |
203 | public void testSetEventContext() { | |
204 | StructDeclaration eventContext = new StructDeclaration(1L); | |
205 | fixture.setEventContext(eventContext); | |
206 | } | |
207 | ||
208 | /** | |
209 | * Run the void setEventHeader(StructDeclaration) method test. | |
210 | */ | |
211 | @Test | |
212 | public void testSetEventHeader() { | |
213 | StructDeclaration eventHeader = new StructDeclaration(1L); | |
214 | fixture.setEventHeader(eventHeader); | |
215 | } | |
216 | ||
217 | /** | |
218 | * Run the void setId(long) method test. | |
219 | */ | |
220 | @Test | |
221 | public void testSetId() { | |
222 | long id = 1L; | |
223 | fixture.setId(id); | |
224 | } | |
225 | ||
226 | /** | |
227 | * Run the void setPacketContext(StructDeclaration) method test. | |
228 | */ | |
229 | @Test | |
230 | public void testSetPacketContext() { | |
231 | StructDeclaration packetContext = new StructDeclaration(1L); | |
232 | fixture.setPacketContext(packetContext); | |
233 | } | |
234 | } |