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