Commit | Line | Data |
---|---|---|
d18dd09b | 1 | /******************************************************************************* |
0316808c | 2 | * Copyright (c) 2009, 2010, 2012 Ericsson |
20658947 | 3 | * |
d18dd09b ASL |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
20658947 | 8 | * |
d18dd09b ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
20658947 | 11 | * Francois Chouinard - Adapted for TMF Trace Model 1.0 |
d18dd09b ASL |
12 | *******************************************************************************/ |
13 | ||
6c13869b | 14 | package org.eclipse.linuxtools.tmf.core.tests.trace; |
d18dd09b ASL |
15 | |
16 | import java.io.File; | |
e1ab8984 FC |
17 | import java.io.IOException; |
18 | import java.net.URISyntaxException; | |
19 | import java.net.URL; | |
d18dd09b ASL |
20 | import java.util.Vector; |
21 | ||
e1ab8984 FC |
22 | import junit.framework.TestCase; |
23 | ||
24 | import org.eclipse.core.runtime.FileLocator; | |
25 | import org.eclipse.core.runtime.Path; | |
6c13869b FC |
26 | import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; |
27 | import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager; | |
72f1e62a | 28 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
7e6347b0 | 29 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
6c13869b FC |
30 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
31 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; | |
32 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; | |
b4f71e4a | 33 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; |
7e6347b0 | 34 | import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; |
6c13869b FC |
35 | import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; |
36 | import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; | |
37 | import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; | |
0316808c | 38 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
7e6347b0 | 39 | import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer; |
6c13869b | 40 | import org.eclipse.linuxtools.tmf.core.trace.TmfContext; |
4918b8f2 | 41 | import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; |
d18dd09b ASL |
42 | |
43 | /** | |
ff4ed569 | 44 | * Test suite for the TmfTrace class. |
d18dd09b | 45 | */ |
3b38ea61 | 46 | @SuppressWarnings("nls") |
d18dd09b ASL |
47 | public class TmfTraceTest extends TestCase { |
48 | ||
f17b2f70 FC |
49 | // ------------------------------------------------------------------------ |
50 | // Variables | |
51 | // ------------------------------------------------------------------------ | |
ff4ed569 | 52 | |
d18dd09b | 53 | private static final String DIRECTORY = "testfiles"; |
85fb0e54 | 54 | private static final String TEST_STREAM = "A-Test-10K"; |
ff4ed569 | 55 | private static final int BLOCK_SIZE = 500; |
e31e01e8 FC |
56 | private static final int NB_EVENTS = 10000; |
57 | private static TmfTraceStub fTrace = null; | |
d18dd09b | 58 | |
20658947 | 59 | private static int SCALE = -3; |
d18dd09b | 60 | |
e31e01e8 | 61 | // ------------------------------------------------------------------------ |
d18dd09b | 62 | // Housekeeping |
e31e01e8 | 63 | // ------------------------------------------------------------------------ |
d18dd09b | 64 | |
f17b2f70 FC |
65 | public TmfTraceTest(final String name) throws Exception { |
66 | super(name); | |
67 | } | |
68 | ||
69 | @Override | |
70 | protected void setUp() throws Exception { | |
71 | super.setUp(); | |
72 | fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM); | |
f17b2f70 FC |
73 | } |
74 | ||
75 | @Override | |
76 | protected void tearDown() throws Exception { | |
77 | super.tearDown(); | |
78 | fTrace.dispose(); | |
79 | fTrace = null; | |
80 | } | |
ff4ed569 FC |
81 | |
82 | // ------------------------------------------------------------------------ | |
83 | // Helper functions | |
84 | // ------------------------------------------------------------------------ | |
85 | ||
f17b2f70 | 86 | private TmfTraceStub setupTrace(final String path) { |
20658947 | 87 | if (fTrace == null) { |
f17b2f70 FC |
88 | try { |
89 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); | |
90 | final File test = new File(FileLocator.toFileURL(location).toURI()); | |
20658947 FC |
91 | fTrace = new TmfTraceStub(test.toURI().getPath(), BLOCK_SIZE); |
92 | fTrace.indexTrace(); | |
b4f71e4a FC |
93 | } catch (final TmfTraceException e) { |
94 | e.printStackTrace(); | |
f17b2f70 FC |
95 | } catch (final URISyntaxException e) { |
96 | e.printStackTrace(); | |
97 | } catch (final IOException e) { | |
98 | e.printStackTrace(); | |
99 | } | |
20658947 | 100 | } |
f17b2f70 | 101 | return fTrace; |
e1ab8984 FC |
102 | } |
103 | ||
e31e01e8 | 104 | // ------------------------------------------------------------------------ |
d18dd09b | 105 | // Constructors |
e31e01e8 | 106 | // ------------------------------------------------------------------------ |
d18dd09b | 107 | |
20658947 | 108 | public void testStandardConstructor() throws Exception { |
f17b2f70 FC |
109 | TmfTraceStub trace = null; |
110 | File testfile = null; | |
111 | try { | |
112 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
113 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
114 | trace = new TmfTraceStub(testfile.toURI().getPath()); | |
20658947 | 115 | trace.indexTrace(); |
f17b2f70 FC |
116 | } catch (final URISyntaxException e) { |
117 | fail("URISyntaxException"); | |
118 | } catch (final IOException e) { | |
119 | fail("IOException"); | |
120 | } | |
20658947 FC |
121 | |
122 | assertFalse ("Open trace", trace == null); | |
123 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
124 | assertNull ("getResource", trace.getResource()); | |
125 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
0316808c | 126 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
20658947 FC |
127 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
128 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
129 | ||
130 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
131 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
132 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
133 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
134 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
ff4ed569 FC |
135 | } |
136 | ||
20658947 | 137 | public void testStandardConstructorCacheSize() throws Exception { |
f17b2f70 FC |
138 | TmfTraceStub trace = null; |
139 | File testfile = null; | |
140 | try { | |
141 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
142 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
143 | trace = new TmfTraceStub(testfile.toURI().getPath(), 0); | |
20658947 FC |
144 | trace.indexTrace(); |
145 | } catch (final URISyntaxException e) { | |
146 | fail("URISyntaxException"); | |
147 | } catch (final IOException e) { | |
148 | fail("IOException"); | |
149 | } | |
150 | ||
151 | assertFalse ("Open trace", trace == null); | |
152 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
153 | assertNull ("getResource", trace.getResource()); | |
154 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
0316808c | 155 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
20658947 FC |
156 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
157 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
158 | ||
159 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
160 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
161 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
162 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
163 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
164 | ||
165 | try { | |
166 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
167 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
168 | trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE); | |
169 | trace.indexTrace(); | |
170 | } catch (final URISyntaxException e) { | |
171 | fail("URISyntaxException"); | |
172 | } catch (final IOException e) { | |
173 | fail("IOException"); | |
174 | } | |
175 | ||
176 | assertFalse ("Open trace", trace == null); | |
177 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
178 | assertNull ("getResource", trace.getResource()); | |
179 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
180 | assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); | |
181 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); | |
182 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
183 | ||
184 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
185 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
186 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
187 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
188 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
189 | } | |
190 | ||
191 | public void testFullConstructor() throws Exception { | |
192 | TmfTraceStub trace = null; | |
193 | File testfile = null; | |
194 | try { | |
195 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
196 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
197 | trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, null); | |
198 | trace.indexTrace(); | |
199 | } catch (final URISyntaxException e) { | |
200 | fail("URISyntaxException"); | |
201 | } catch (final IOException e) { | |
202 | fail("IOException"); | |
203 | } | |
204 | ||
205 | assertFalse ("Open trace", trace == null); | |
206 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
207 | assertNull ("getResource", trace.getResource()); | |
208 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
209 | assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); | |
210 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); | |
211 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
212 | ||
213 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
214 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
215 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
216 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
217 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
218 | } | |
219 | ||
1703b536 FC |
220 | public void testLiveTraceConstructor() throws Exception { |
221 | TmfTraceStub trace = null; | |
222 | File testfile = null; | |
223 | final long interval = 100; | |
224 | try { | |
225 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
226 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
227 | trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, interval); | |
228 | trace.indexTrace(); | |
229 | } catch (final URISyntaxException e) { | |
230 | fail("URISyntaxException"); | |
231 | } catch (final IOException e) { | |
232 | fail("IOException"); | |
233 | } | |
234 | ||
235 | assertFalse ("Open trace", trace == null); | |
236 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
237 | assertNull ("getResource", trace.getResource()); | |
238 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
239 | assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); | |
240 | assertEquals("getStreamingInterval", interval, trace.getStreamingInterval()); | |
241 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
242 | ||
243 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
244 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
245 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
246 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
247 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
248 | } | |
249 | ||
20658947 FC |
250 | @SuppressWarnings({ "rawtypes", "unchecked" }) |
251 | public void testCopyConstructor() throws Exception { | |
252 | TmfTraceStub original = null; | |
253 | TmfTraceStub trace = null; | |
254 | File testfile = null; | |
255 | try { | |
256 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
257 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
7e6347b0 | 258 | original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null)); |
20658947 FC |
259 | trace = new TmfTraceStub(original); |
260 | trace.indexTrace(); | |
f17b2f70 FC |
261 | } catch (final URISyntaxException e) { |
262 | fail("URISyntaxException"); | |
263 | } catch (final IOException e) { | |
264 | fail("IOException"); | |
265 | } | |
20658947 FC |
266 | |
267 | assertFalse ("Open trace", trace == null); | |
268 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
269 | assertNull ("getResource", trace.getResource()); | |
270 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); | |
271 | assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); | |
272 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); | |
273 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
274 | ||
275 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
276 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
277 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
278 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
279 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
280 | ||
281 | // Test the copy of a null trace | |
282 | try { | |
283 | new TmfTraceStub((TmfTraceStub) null); | |
284 | fail("Missing exception"); | |
285 | } catch (final IllegalArgumentException e) { | |
286 | // test passed | |
287 | } catch (final Exception e) { | |
288 | fail("Unexpected exception"); | |
289 | } | |
d18dd09b ASL |
290 | } |
291 | ||
20658947 | 292 | // ------------------------------------------------------------------------ |
1703b536 | 293 | // Trace initialization |
20658947 FC |
294 | // ------------------------------------------------------------------------ |
295 | ||
1703b536 | 296 | public void testInitializeNullPath() throws Exception { |
20658947 | 297 | |
1703b536 FC |
298 | // Instantiate an "empty" trace |
299 | final TmfTraceStub trace = new TmfTraceStub(); | |
20658947 | 300 | |
1703b536 FC |
301 | try { |
302 | trace.initialize(null, null, TmfEvent.class); | |
303 | fail("TmfTrace.initialize() - no exception thrown"); | |
b4f71e4a | 304 | } catch (TmfTraceException e) { |
1703b536 FC |
305 | // Success |
306 | } catch (Exception e) { | |
307 | fail("TmfTrace.initialize() - wrong exception thrown"); | |
308 | } | |
ff4ed569 | 309 | } |
1703b536 FC |
310 | |
311 | public void testInitializeSimplePath() throws Exception { | |
ff4ed569 | 312 | |
1703b536 FC |
313 | // Instantiate an "empty" trace |
314 | final TmfTraceStub trace = new TmfTraceStub(); | |
315 | ||
316 | // Path == trace name | |
317 | String path = "TraceName"; | |
318 | try { | |
319 | trace.initialize(null, path, TmfEvent.class); | |
320 | } catch (Exception e) { | |
321 | fail("TmfTrace.initialize() - Exception thrown"); | |
322 | } | |
323 | ||
324 | assertFalse ("Open trace", trace == null); | |
325 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
326 | assertNull ("getResource", trace.getResource()); | |
327 | assertEquals("getPath", path, trace.getPath()); | |
0316808c | 328 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
1703b536 FC |
329 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
330 | assertEquals("getName", path, trace.getName()); | |
331 | ||
332 | assertEquals("getNbEvents", 0, trace.getNbEvents()); | |
333 | assertEquals("getRange-start", Long.MAX_VALUE, trace.getTimeRange().getStartTime().getValue()); | |
334 | assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue()); | |
335 | assertEquals("getStartTime", Long.MAX_VALUE, trace.getStartTime().getValue()); | |
336 | assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue()); | |
337 | } | |
338 | ||
339 | public void testInitializeNormalPath() throws Exception { | |
340 | ||
341 | // Instantiate an "empty" trace | |
342 | final TmfTraceStub trace = new TmfTraceStub(); | |
343 | ||
344 | // Path == trace name | |
345 | String name = "TraceName"; | |
346 | String path = "/my/trace/path/" + name; | |
347 | try { | |
348 | trace.initialize(null, path, TmfEvent.class); | |
349 | } catch (Exception e) { | |
350 | fail("TmfTrace.initialize() - Exception thrown"); | |
351 | } | |
352 | ||
353 | assertFalse ("Open trace", trace == null); | |
354 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
355 | assertNull ("getResource", trace.getResource()); | |
356 | assertEquals("getPath", path, trace.getPath()); | |
0316808c | 357 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
1703b536 FC |
358 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
359 | assertEquals("getName", name, trace.getName()); | |
360 | ||
361 | assertEquals("getNbEvents", 0, trace.getNbEvents()); | |
362 | assertEquals("getRange-start", Long.MAX_VALUE, trace.getTimeRange().getStartTime().getValue()); | |
363 | assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue()); | |
364 | assertEquals("getStartTime", Long.MAX_VALUE, trace.getStartTime().getValue()); | |
365 | assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue()); | |
366 | } | |
20658947 FC |
367 | |
368 | public void testInitTrace() throws Exception { | |
369 | ||
370 | // Instantiate an "empty" trace | |
371 | final TmfTraceStub trace = new TmfTraceStub(); | |
372 | ||
373 | assertFalse ("Open trace", trace == null); | |
374 | assertNull ("getType", trace.getType()); | |
375 | assertNull ("getResource", trace.getResource()); | |
0316808c | 376 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
20658947 FC |
377 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
378 | assertEquals("getName", "", trace.getName()); | |
379 | ||
380 | assertEquals("getNbEvents", 0, trace.getNbEvents()); | |
381 | assertEquals("getRange-start", Long.MAX_VALUE, trace.getTimeRange().getStartTime().getValue()); | |
382 | assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue()); | |
383 | assertEquals("getStartTime", Long.MAX_VALUE, trace.getStartTime().getValue()); | |
384 | assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue()); | |
385 | ||
386 | // Validate | |
387 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
388 | final File testfile = new File(FileLocator.toFileURL(location).toURI()); | |
389 | assertTrue("validate", trace.validate(null, testfile.getPath())); | |
390 | ||
391 | // InitTrace and wait for indexing completion... | |
392 | trace.initTrace(null, testfile.getPath(), TmfEvent.class); | |
c7e1020d | 393 | trace.indexTrace(); |
20658947 FC |
394 | int nbSecs = 0; |
395 | while (trace.getNbEvents() < NB_EVENTS && nbSecs < 10) { | |
396 | Thread.sleep(1000); | |
397 | nbSecs++; | |
398 | } | |
399 | if (trace.getNbEvents() < NB_EVENTS) { | |
400 | fail("indexing"); | |
401 | } | |
402 | ||
20658947 FC |
403 | assertEquals("getType", TmfEvent.class, trace.getType()); |
404 | assertNull ("getResource", trace.getResource()); | |
0316808c | 405 | assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); |
20658947 FC |
406 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); |
407 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
408 | ||
409 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
410 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
411 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
412 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
413 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
414 | } | |
d18dd09b | 415 | |
ff4ed569 | 416 | // ------------------------------------------------------------------------ |
1703b536 FC |
417 | // Set/Get streaming interval |
418 | // ------------------------------------------------------------------------ | |
419 | ||
420 | public void testSetStreamingInterval() throws Exception { | |
421 | final TmfTraceStub trace = new TmfTraceStub(fTrace); | |
422 | ||
423 | long interval = 0; | |
424 | assertEquals("getStreamingInterval", interval, trace.getStreamingInterval()); | |
425 | ||
426 | interval = 100; | |
427 | trace.setStreamingInterval(interval); | |
428 | assertEquals("getStreamingInterval", interval, trace.getStreamingInterval()); | |
429 | ||
430 | interval = -1; | |
431 | trace.setStreamingInterval(interval); | |
432 | assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); | |
433 | ||
434 | interval = 0; | |
435 | trace.setStreamingInterval(interval); | |
436 | assertEquals("getStreamingInterval", interval, trace.getStreamingInterval()); | |
437 | ||
438 | trace.dispose(); | |
439 | } | |
440 | ||
441 | // ------------------------------------------------------------------------ | |
442 | // Set/Get time range | |
ff4ed569 FC |
443 | // ------------------------------------------------------------------------ |
444 | ||
445 | public void testSetTimeRange() throws Exception { | |
f17b2f70 | 446 | final TmfTraceStub trace = new TmfTraceStub(fTrace); |
20658947 | 447 | trace.indexTrace(); |
f17b2f70 | 448 | |
ff4ed569 FC |
449 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); |
450 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
451 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
452 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
453 | ||
454 | trace.setTimeRange(new TmfTimeRange(new TmfTimestamp(100), new TmfTimestamp(200))); | |
455 | assertEquals("setTimeRange", 100, trace.getTimeRange().getStartTime().getValue()); | |
456 | assertEquals("setTimeRange", 200, trace.getTimeRange().getEndTime().getValue()); | |
457 | assertEquals("setTimeRange", 100, trace.getStartTime().getValue()); | |
458 | assertEquals("setTimeRange", 200, trace.getEndTime().getValue()); | |
f17b2f70 FC |
459 | |
460 | trace.dispose(); | |
ff4ed569 | 461 | } |
f17b2f70 | 462 | |
ff4ed569 | 463 | public void testSetStartTime() throws Exception { |
f17b2f70 | 464 | final TmfTraceStub trace = new TmfTraceStub(fTrace); |
20658947 | 465 | trace.indexTrace(); |
f17b2f70 | 466 | |
ff4ed569 FC |
467 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); |
468 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
469 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
470 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
471 | ||
472 | trace.setStartTime(new TmfTimestamp(100)); | |
473 | assertEquals("setStartTime", 100, trace.getTimeRange().getStartTime().getValue()); | |
474 | assertEquals("setStartTime", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
475 | assertEquals("setStartTime", 100, trace.getStartTime().getValue()); | |
476 | assertEquals("setStartTime", NB_EVENTS, trace.getEndTime().getValue()); | |
f17b2f70 FC |
477 | |
478 | trace.dispose(); | |
ff4ed569 | 479 | } |
f17b2f70 | 480 | |
ff4ed569 | 481 | public void testSetEndTime() throws Exception { |
f17b2f70 | 482 | final TmfTraceStub trace = new TmfTraceStub(fTrace); |
20658947 | 483 | trace.indexTrace(); |
f17b2f70 | 484 | |
ff4ed569 FC |
485 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); |
486 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
487 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
488 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
489 | ||
490 | trace.setEndTime(new TmfTimestamp(100)); | |
491 | assertEquals("setEndTime", 1, trace.getTimeRange().getStartTime().getValue()); | |
492 | assertEquals("setEndTime", 100, trace.getTimeRange().getEndTime().getValue()); | |
493 | assertEquals("setEndTime", 1, trace.getStartTime().getValue()); | |
494 | assertEquals("setEndTime", 100, trace.getEndTime().getValue()); | |
f17b2f70 FC |
495 | |
496 | trace.dispose(); | |
ff4ed569 | 497 | } |
f17b2f70 | 498 | |
b75d6b65 FC |
499 | public void testSetNbEvents() throws Exception { |
500 | final TmfTraceStub trace = new TmfTraceStub(fTrace); | |
501 | trace.indexTrace(); | |
502 | ||
503 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
504 | ||
505 | trace.setNbEvents(0); | |
506 | assertEquals("getNbEvents", 0, trace.getNbEvents()); | |
507 | ||
508 | trace.setNbEvents(-1); | |
509 | assertEquals("getNbEvents", 0, trace.getNbEvents()); | |
510 | ||
511 | trace.setNbEvents(NB_EVENTS + 1); | |
512 | assertEquals("getNbEvents", NB_EVENTS + 1, trace.getNbEvents()); | |
513 | ||
514 | trace.setNbEvents(NB_EVENTS); | |
515 | assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); | |
516 | ||
517 | trace.dispose(); | |
518 | } | |
519 | ||
e31e01e8 | 520 | // ------------------------------------------------------------------------ |
7e6347b0 FC |
521 | // seekEvent on location (note: does not reliably set the rank) |
522 | // ------------------------------------------------------------------------ | |
523 | ||
524 | public void testSeekEventOnCacheBoundary() throws Exception { | |
525 | ||
526 | // Position trace at event rank 0 | |
527 | ITmfContext context = fTrace.seekEvent(0); | |
528 | ITmfEvent event = fTrace.parseEvent(context); | |
529 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
530 | assertEquals("Event rank", 0, context.getRank()); | |
531 | ||
532 | context = fTrace.seekEvent(context.getLocation()); | |
533 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
534 | ||
535 | event = fTrace.parseEvent(context); | |
536 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
537 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
538 | ||
c32744d6 | 539 | event = fTrace.getNext(context); |
7e6347b0 FC |
540 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
541 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
542 | ||
543 | // Position trace at event rank 1000 | |
544 | ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); | |
545 | context = fTrace.seekEvent(tmpContext.getLocation()); | |
546 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
547 | ||
548 | event = fTrace.parseEvent(context); | |
549 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); | |
550 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
551 | ||
c32744d6 | 552 | event = fTrace.getNext(context); |
7e6347b0 FC |
553 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
554 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
555 | ||
556 | // Position trace at event rank 4000 | |
557 | tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); | |
558 | context = fTrace.seekEvent(tmpContext.getLocation()); | |
559 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
560 | ||
561 | event = fTrace.parseEvent(context); | |
562 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); | |
563 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
564 | ||
c32744d6 | 565 | event = fTrace.getNext(context); |
7e6347b0 FC |
566 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
567 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
568 | } | |
569 | ||
570 | public void testSeekEventNotOnCacheBoundary() throws Exception { | |
571 | ||
572 | // Position trace at event rank 9 | |
573 | ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); | |
574 | TmfContext context = fTrace.seekEvent(tmpContext.getLocation()); | |
575 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
576 | ||
577 | ITmfEvent event = fTrace.parseEvent(context); | |
578 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); | |
579 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
580 | ||
c32744d6 | 581 | event = fTrace.getNext(context); |
7e6347b0 FC |
582 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
583 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
584 | ||
585 | // Position trace at event rank 999 | |
586 | tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); | |
587 | context = fTrace.seekEvent(tmpContext.getLocation()); | |
588 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
589 | ||
590 | event = fTrace.parseEvent(context); | |
591 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); | |
592 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
593 | ||
c32744d6 | 594 | event = fTrace.getNext(context); |
7e6347b0 FC |
595 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
596 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
597 | ||
598 | // Position trace at event rank 1001 | |
599 | tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); | |
600 | context = fTrace.seekEvent(tmpContext.getLocation()); | |
601 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
602 | ||
603 | event = fTrace.parseEvent(context); | |
604 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); | |
605 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
606 | ||
c32744d6 | 607 | event = fTrace.getNext(context); |
7e6347b0 FC |
608 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
609 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
610 | ||
611 | // Position trace at event rank 4500 | |
612 | tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); | |
613 | context = fTrace.seekEvent(tmpContext.getLocation()); | |
614 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
615 | ||
616 | event = fTrace.parseEvent(context); | |
617 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); | |
618 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
619 | ||
c32744d6 | 620 | event = fTrace.getNext(context); |
7e6347b0 FC |
621 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
622 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
623 | } | |
624 | ||
625 | public void testSeekEventOutOfScope() throws Exception { | |
626 | ||
627 | // Position trace at beginning | |
628 | ITmfContext tmpContext = fTrace.seekEvent(0); | |
629 | ITmfContext context = fTrace.seekEvent(tmpContext.getLocation()); | |
630 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
631 | ||
632 | ITmfEvent event = fTrace.parseEvent(context); | |
633 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
634 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
635 | ||
c32744d6 | 636 | event = fTrace.getNext(context); |
7e6347b0 FC |
637 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
638 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
639 | ||
640 | // Position trace at event passed the end | |
0316808c FC |
641 | context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0)); |
642 | assertNull("Event timestamp", context.getLocation()); | |
7e6347b0 FC |
643 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
644 | ||
c32744d6 | 645 | event = fTrace.getNext(context); |
0316808c | 646 | assertNull("Event", event); |
7e6347b0 FC |
647 | } |
648 | ||
649 | // ------------------------------------------------------------------------ | |
650 | // seekEvent on timestamp (note: does not reliably set the rank) | |
54d55ced FC |
651 | // ------------------------------------------------------------------------ |
652 | ||
20658947 | 653 | public void testSeekEventOnNullTimestamp() throws Exception { |
54d55ced | 654 | |
f17b2f70 | 655 | // Position trace at event rank 0 |
7e6347b0 | 656 | ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null); |
ff4ed569 | 657 | assertEquals("Event rank", 0, context.getRank()); |
9b635e61 | 658 | |
72f1e62a | 659 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced | 660 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
20658947 | 661 | assertEquals("Event rank", 0, context.getRank()); |
54d55ced FC |
662 | } |
663 | ||
54d55ced FC |
664 | public void testSeekEventOnTimestampOnCacheBoundary() throws Exception { |
665 | ||
f17b2f70 FC |
666 | // Position trace at event rank 0 |
667 | ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0)); | |
54d55ced | 668 | assertEquals("Event rank", 0, context.getRank()); |
9b635e61 | 669 | |
72f1e62a | 670 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
671 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
672 | assertEquals("Event rank", 0, context.getRank()); | |
f17b2f70 | 673 | |
c32744d6 | 674 | event = fTrace.getNext(context); |
75828b1a | 675 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
e31e01e8 | 676 | assertEquals("Event rank", 1, context.getRank()); |
d18dd09b | 677 | |
f17b2f70 | 678 | // Position trace at event rank 1000 |
54d55ced FC |
679 | context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); |
680 | assertEquals("Event rank", 1000, context.getRank()); | |
f17b2f70 | 681 | |
9b635e61 | 682 | event = fTrace.parseEvent(context); |
54d55ced FC |
683 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
684 | assertEquals("Event rank", 1000, context.getRank()); | |
f17b2f70 | 685 | |
c32744d6 | 686 | event = fTrace.getNext(context); |
e31e01e8 FC |
687 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
688 | assertEquals("Event rank", 1001, context.getRank()); | |
d18dd09b | 689 | |
f17b2f70 | 690 | // Position trace at event rank 4000 |
54d55ced FC |
691 | context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); |
692 | assertEquals("Event rank", 4000, context.getRank()); | |
f17b2f70 | 693 | |
9b635e61 | 694 | event = fTrace.parseEvent(context); |
54d55ced FC |
695 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
696 | assertEquals("Event rank", 4000, context.getRank()); | |
f17b2f70 | 697 | |
c32744d6 | 698 | event = fTrace.getNext(context); |
e31e01e8 FC |
699 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
700 | assertEquals("Event rank", 4001, context.getRank()); | |
75828b1a | 701 | } |
d18dd09b | 702 | |
54d55ced FC |
703 | public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception { |
704 | ||
f17b2f70 FC |
705 | // Position trace at event rank 1 |
706 | ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0)); | |
54d55ced | 707 | assertEquals("Event rank", 1, context.getRank()); |
f17b2f70 | 708 | |
72f1e62a | 709 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
710 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
711 | assertEquals("Event rank", 1, context.getRank()); | |
f17b2f70 | 712 | |
c32744d6 | 713 | event = fTrace.getNext(context); |
54d55ced FC |
714 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
715 | assertEquals("Event rank", 2, context.getRank()); | |
d18dd09b | 716 | |
f17b2f70 FC |
717 | // Position trace at event rank 9 |
718 | context = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); | |
54d55ced | 719 | assertEquals("Event rank", 9, context.getRank()); |
f17b2f70 | 720 | |
9b635e61 | 721 | event = fTrace.parseEvent(context); |
54d55ced FC |
722 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
723 | assertEquals("Event rank", 9, context.getRank()); | |
f17b2f70 | 724 | |
c32744d6 | 725 | event = fTrace.getNext(context); |
e31e01e8 FC |
726 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
727 | assertEquals("Event rank", 10, context.getRank()); | |
d18dd09b | 728 | |
f17b2f70 | 729 | // Position trace at event rank 999 |
54d55ced FC |
730 | context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); |
731 | assertEquals("Event rank", 999, context.getRank()); | |
f17b2f70 | 732 | |
9b635e61 | 733 | event = fTrace.parseEvent(context); |
54d55ced | 734 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
e31e01e8 | 735 | assertEquals("Event rank", 999, context.getRank()); |
f17b2f70 | 736 | |
c32744d6 | 737 | event = fTrace.getNext(context); |
54d55ced FC |
738 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
739 | assertEquals("Event rank", 1000, context.getRank()); | |
e31e01e8 | 740 | |
f17b2f70 | 741 | // Position trace at event rank 1001 |
54d55ced | 742 | context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); |
e31e01e8 | 743 | assertEquals("Event rank", 1001, context.getRank()); |
f17b2f70 | 744 | |
9b635e61 | 745 | event = fTrace.parseEvent(context); |
54d55ced FC |
746 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
747 | assertEquals("Event rank", 1001, context.getRank()); | |
f17b2f70 | 748 | |
c32744d6 | 749 | event = fTrace.getNext(context); |
54d55ced FC |
750 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
751 | assertEquals("Event rank", 1002, context.getRank()); | |
752 | ||
f17b2f70 | 753 | // Position trace at event rank 4500 |
54d55ced FC |
754 | context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); |
755 | assertEquals("Event rank", 4500, context.getRank()); | |
f17b2f70 | 756 | |
9b635e61 | 757 | event = fTrace.parseEvent(context); |
54d55ced FC |
758 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
759 | assertEquals("Event rank", 4500, context.getRank()); | |
f17b2f70 | 760 | |
c32744d6 | 761 | event = fTrace.getNext(context); |
54d55ced FC |
762 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
763 | assertEquals("Event rank", 4501, context.getRank()); | |
75828b1a | 764 | } |
d18dd09b | 765 | |
54d55ced | 766 | public void testSeekEventOnTimestampOutOfScope() throws Exception { |
d18dd09b | 767 | |
f17b2f70 FC |
768 | // Position trace at beginning |
769 | ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0)); | |
54d55ced | 770 | assertEquals("Event rank", 0, context.getRank()); |
f17b2f70 | 771 | |
72f1e62a | 772 | ITmfEvent event = fTrace.parseEvent(context); |
75828b1a | 773 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
54d55ced | 774 | assertEquals("Event rank", 0, context.getRank()); |
f17b2f70 | 775 | |
c32744d6 | 776 | event = fTrace.getNext(context); |
54d55ced FC |
777 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
778 | assertEquals("Event rank", 1, context.getRank()); | |
75828b1a | 779 | |
f17b2f70 | 780 | // Position trace at event passed the end |
54d55ced | 781 | context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0)); |
0316808c | 782 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
f17b2f70 | 783 | |
9b635e61 | 784 | event = fTrace.parseEvent(context); |
75828b1a | 785 | assertEquals("Event timestamp", null, event); |
0316808c | 786 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
f17b2f70 | 787 | |
c32744d6 | 788 | event = fTrace.getNext(context); |
54d55ced | 789 | assertEquals("Event timestamp", null, event); |
0316808c | 790 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
d18dd09b ASL |
791 | } |
792 | ||
54d55ced FC |
793 | // ------------------------------------------------------------------------ |
794 | // seekEvent on rank | |
795 | // ------------------------------------------------------------------------ | |
796 | ||
20658947 FC |
797 | public void testSeekEventOnNegativeRank() throws Exception { |
798 | ||
799 | // Position trace at event rank 0 | |
800 | ITmfContext context = fTrace.seekEvent(-1); | |
801 | assertEquals("Event rank", 0, context.getRank()); | |
802 | ||
803 | ITmfEvent event = fTrace.parseEvent(context); | |
804 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
805 | assertEquals("Event rank", 0, context.getRank()); | |
806 | } | |
807 | ||
54d55ced | 808 | public void testSeekOnRankOnCacheBoundary() throws Exception { |
e31e01e8 | 809 | |
f17b2f70 FC |
810 | // On lower bound, returns the first event (ts = 1) |
811 | ITmfContext context = fTrace.seekEvent(0); | |
54d55ced | 812 | assertEquals("Event rank", 0, context.getRank()); |
f17b2f70 | 813 | |
72f1e62a | 814 | ITmfEvent event = fTrace.parseEvent(context); |
e31e01e8 | 815 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
54d55ced | 816 | assertEquals("Event rank", 0, context.getRank()); |
f17b2f70 | 817 | |
c32744d6 | 818 | event = fTrace.getNext(context); |
54d55ced FC |
819 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
820 | assertEquals("Event rank", 1, context.getRank()); | |
e31e01e8 | 821 | |
f17b2f70 | 822 | // Position trace at event rank 1000 |
54d55ced FC |
823 | context = fTrace.seekEvent(1000); |
824 | assertEquals("Event rank", 1000, context.getRank()); | |
f17b2f70 | 825 | |
9b635e61 | 826 | event = fTrace.parseEvent(context); |
54d55ced FC |
827 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
828 | assertEquals("Event rank", 1000, context.getRank()); | |
f17b2f70 | 829 | |
c32744d6 | 830 | event = fTrace.getNext(context); |
54d55ced FC |
831 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
832 | assertEquals("Event rank", 1001, context.getRank()); | |
e31e01e8 | 833 | |
f17b2f70 | 834 | // Position trace at event rank 4000 |
54d55ced FC |
835 | context = fTrace.seekEvent(4000); |
836 | assertEquals("Event rank", 4000, context.getRank()); | |
f17b2f70 | 837 | |
9b635e61 | 838 | event = fTrace.parseEvent(context); |
54d55ced FC |
839 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
840 | assertEquals("Event rank", 4000, context.getRank()); | |
f17b2f70 | 841 | |
c32744d6 | 842 | event = fTrace.getNext(context); |
54d55ced FC |
843 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
844 | assertEquals("Event rank", 4001, context.getRank()); | |
e31e01e8 FC |
845 | } |
846 | ||
54d55ced | 847 | public void testSeekOnRankNotOnCacheBoundary() throws Exception { |
d18dd09b | 848 | |
f17b2f70 FC |
849 | // Position trace at event rank 9 |
850 | ITmfContext context = fTrace.seekEvent(9); | |
54d55ced | 851 | assertEquals("Event rank", 9, context.getRank()); |
f17b2f70 | 852 | |
72f1e62a | 853 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
854 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
855 | assertEquals("Event rank", 9, context.getRank()); | |
f17b2f70 | 856 | |
c32744d6 | 857 | event = fTrace.getNext(context); |
54d55ced FC |
858 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
859 | assertEquals("Event rank", 10, context.getRank()); | |
d18dd09b | 860 | |
f17b2f70 | 861 | // Position trace at event rank 999 |
54d55ced FC |
862 | context = fTrace.seekEvent(999); |
863 | assertEquals("Event rank", 999, context.getRank()); | |
f17b2f70 | 864 | |
9b635e61 | 865 | event = fTrace.parseEvent(context); |
54d55ced FC |
866 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
867 | assertEquals("Event rank", 999, context.getRank()); | |
f17b2f70 | 868 | |
c32744d6 | 869 | event = fTrace.getNext(context); |
54d55ced FC |
870 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
871 | assertEquals("Event rank", 1000, context.getRank()); | |
d18dd09b | 872 | |
f17b2f70 | 873 | // Position trace at event rank 1001 |
54d55ced FC |
874 | context = fTrace.seekEvent(1001); |
875 | assertEquals("Event rank", 1001, context.getRank()); | |
f17b2f70 | 876 | |
9b635e61 | 877 | event = fTrace.parseEvent(context); |
54d55ced FC |
878 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
879 | assertEquals("Event rank", 1001, context.getRank()); | |
f17b2f70 | 880 | |
c32744d6 | 881 | event = fTrace.getNext(context); |
54d55ced FC |
882 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
883 | assertEquals("Event rank", 1002, context.getRank()); | |
884 | ||
f17b2f70 | 885 | // Position trace at event rank 4500 |
54d55ced FC |
886 | context = fTrace.seekEvent(4500); |
887 | assertEquals("Event rank", 4500, context.getRank()); | |
f17b2f70 | 888 | |
9b635e61 | 889 | event = fTrace.parseEvent(context); |
54d55ced FC |
890 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
891 | assertEquals("Event rank", 4500, context.getRank()); | |
f17b2f70 | 892 | |
c32744d6 | 893 | event = fTrace.getNext(context); |
54d55ced FC |
894 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
895 | assertEquals("Event rank", 4501, context.getRank()); | |
d18dd09b ASL |
896 | } |
897 | ||
0316808c | 898 | public void testSeekEventOnRankOutOfScope() throws Exception { |
54d55ced | 899 | |
f17b2f70 FC |
900 | // Position trace at beginning |
901 | ITmfContext context = fTrace.seekEvent(-1); | |
54d55ced | 902 | assertEquals("Event rank", 0, context.getRank()); |
f17b2f70 | 903 | |
72f1e62a | 904 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
905 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
906 | assertEquals("Event rank", 0, context.getRank()); | |
f17b2f70 | 907 | |
c32744d6 | 908 | event = fTrace.getNext(context); |
54d55ced FC |
909 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
910 | assertEquals("Event rank", 1, context.getRank()); | |
911 | ||
f17b2f70 | 912 | // Position trace at event passed the end |
54d55ced FC |
913 | context = fTrace.seekEvent(NB_EVENTS); |
914 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
f17b2f70 | 915 | |
9b635e61 | 916 | event = fTrace.parseEvent(context); |
0316808c | 917 | assertNull("Event", event); |
54d55ced | 918 | assertEquals("Event rank", NB_EVENTS, context.getRank()); |
f17b2f70 | 919 | |
c32744d6 | 920 | event = fTrace.getNext(context); |
0316808c | 921 | assertNull("Event", event); |
54d55ced FC |
922 | assertEquals("Event rank", NB_EVENTS, context.getRank()); |
923 | } | |
f17b2f70 | 924 | |
20658947 FC |
925 | // ------------------------------------------------------------------------ |
926 | // parseEvent - make sure parseEvent doesn't update the context | |
927 | // ------------------------------------------------------------------------ | |
928 | ||
929 | public void testParseEvent() throws Exception { | |
930 | ||
931 | final int NB_READS = 20; | |
932 | ||
933 | // On lower bound, returns the first event (ts = 0) | |
934 | final TmfContext context = (TmfContext) fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); | |
935 | TmfContext svContext = new TmfContext(context); | |
936 | ||
937 | ITmfEvent event = fTrace.parseEvent(context); | |
938 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
939 | assertEquals("Event rank", 0, context.getRank()); | |
940 | assertTrue("parseEvent", context.equals(svContext)); | |
941 | ||
942 | event = fTrace.parseEvent(context); | |
943 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
944 | assertEquals("Event rank", 0, context.getRank()); | |
945 | assertTrue("parseEvent", context.equals(svContext)); | |
946 | ||
947 | event = fTrace.parseEvent(context); | |
948 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
949 | assertEquals("Event rank", 0, context.getRank()); | |
950 | assertTrue("parseEvent", context.equals(svContext)); | |
951 | ||
952 | // Position the trace at event NB_READS | |
953 | for (int i = 1; i < NB_READS; i++) { | |
c32744d6 | 954 | event = fTrace.getNext(context); |
20658947 FC |
955 | assertEquals("Event timestamp", i, event.getTimestamp().getValue()); |
956 | } | |
957 | ||
958 | svContext = new TmfContext(context); | |
959 | event = fTrace.parseEvent(context); | |
960 | assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue()); | |
961 | assertEquals("Event rank", NB_READS -1 , context.getRank()); | |
962 | assertTrue("parseEvent", context.equals(svContext)); | |
963 | ||
964 | event = fTrace.parseEvent(context); | |
965 | assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue()); | |
966 | assertEquals("Event rank", NB_READS - 1, context.getRank()); | |
967 | assertTrue("parseEvent", context.equals(svContext)); | |
968 | } | |
969 | ||
970 | // ------------------------------------------------------------------------ | |
b4f71e4a | 971 | // readNextEvent - updates the context |
20658947 FC |
972 | // ------------------------------------------------------------------------ |
973 | ||
b4f71e4a | 974 | public void testReadNextEvent() throws Exception { |
20658947 FC |
975 | |
976 | final int NB_READS = 20; | |
977 | ||
978 | // On lower bound, returns the first event (ts = 1) | |
979 | final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); | |
980 | ||
981 | // Read NB_EVENTS | |
982 | ITmfEvent event; | |
983 | for (int i = 0; i < NB_READS; i++) { | |
c32744d6 | 984 | event = fTrace.getNext(context); |
20658947 FC |
985 | assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); |
986 | assertEquals("Event rank", i + 1, context.getRank()); | |
987 | } | |
988 | ||
989 | // Make sure we stay positioned | |
990 | event = fTrace.parseEvent(context); | |
991 | assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue()); | |
992 | assertEquals("Event rank", NB_READS, context.getRank()); | |
993 | } | |
994 | ||
e31e01e8 | 995 | // ------------------------------------------------------------------------ |
d18dd09b | 996 | // processRequest |
e31e01e8 | 997 | // ------------------------------------------------------------------------ |
d18dd09b | 998 | |
e31e01e8 | 999 | @SuppressWarnings("unchecked") |
7e6347b0 FC |
1000 | public void testProcessEventRequestForAllEvents() throws Exception { |
1001 | final int BLOCK_SIZE = 1; | |
1002 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
1003 | ||
1004 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); | |
1005 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { | |
1006 | @Override | |
1007 | public void handleData(final TmfEvent event) { | |
1008 | super.handleData(event); | |
1009 | requestedEvents.add(event); | |
1010 | } | |
1011 | }; | |
1012 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); | |
1013 | providers[0].sendRequest(request); | |
1014 | request.waitForCompletion(); | |
1015 | ||
1016 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
1017 | assertTrue("isCompleted", request.isCompleted()); | |
1018 | assertFalse("isCancelled", request.isCancelled()); | |
1019 | ||
1020 | // Ensure that we have distinct events. | |
1021 | // Don't go overboard: we are not validating the stub! | |
1022 | for (int i = 0; i < NB_EVENTS; i++) { | |
1023 | assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue()); | |
1024 | } | |
1025 | } | |
1026 | ||
1027 | @SuppressWarnings("unchecked") | |
1028 | public void testProcessEventRequestForNbEvents() throws Exception { | |
d18dd09b ASL |
1029 | final int BLOCK_SIZE = 100; |
1030 | final int NB_EVENTS = 1000; | |
1031 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
1032 | ||
f17b2f70 | 1033 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
e31e01e8 | 1034 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f17b2f70 FC |
1035 | @Override |
1036 | public void handleData(final TmfEvent event) { | |
1037 | super.handleData(event); | |
1038 | requestedEvents.add(event); | |
1039 | } | |
d18dd09b | 1040 | }; |
f17b2f70 | 1041 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
951d134a FC |
1042 | providers[0].sendRequest(request); |
1043 | request.waitForCompletion(); | |
d18dd09b ASL |
1044 | |
1045 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
1046 | assertTrue("isCompleted", request.isCompleted()); | |
1047 | assertFalse("isCancelled", request.isCancelled()); | |
1048 | ||
1049 | // Ensure that we have distinct events. | |
f17b2f70 | 1050 | // Don't go overboard: we are not validating the stub! |
20658947 | 1051 | for (int i = 0; i < NB_EVENTS; i++) { |
7e6347b0 | 1052 | assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue()); |
20658947 | 1053 | } |
d18dd09b | 1054 | } |
f17b2f70 | 1055 | |
e31e01e8 | 1056 | @SuppressWarnings("unchecked") |
7e6347b0 | 1057 | public void testProcessEventRequestForSomeEvents() throws Exception { |
d18dd09b | 1058 | final int BLOCK_SIZE = 1; |
7e6347b0 FC |
1059 | final long startTime = 100; |
1060 | final int NB_EVENTS = 1000; | |
d18dd09b ASL |
1061 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); |
1062 | ||
7e6347b0 | 1063 | final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); |
e31e01e8 | 1064 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f17b2f70 FC |
1065 | @Override |
1066 | public void handleData(final TmfEvent event) { | |
1067 | super.handleData(event); | |
1068 | requestedEvents.add(event); | |
1069 | } | |
d18dd09b | 1070 | }; |
f17b2f70 | 1071 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
951d134a FC |
1072 | providers[0].sendRequest(request); |
1073 | request.waitForCompletion(); | |
d18dd09b ASL |
1074 | |
1075 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
1076 | assertTrue("isCompleted", request.isCompleted()); | |
1077 | assertFalse("isCancelled", request.isCancelled()); | |
1078 | ||
1079 | // Ensure that we have distinct events. | |
f17b2f70 | 1080 | // Don't go overboard: we are not validating the stub! |
20658947 | 1081 | for (int i = 0; i < NB_EVENTS; i++) { |
7e6347b0 FC |
1082 | assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue()); |
1083 | } | |
1084 | } | |
1085 | ||
1086 | @SuppressWarnings("unchecked") | |
1087 | public void testProcessEventRequestForOtherEvents() throws Exception { | |
1088 | final int BLOCK_SIZE = 1; | |
1089 | final int startIndex = 99; | |
1090 | final long startTime = 100; | |
1091 | final int NB_EVENTS = 1000; | |
1092 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
1093 | ||
1094 | final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); | |
1095 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) { | |
1096 | @Override | |
1097 | public void handleData(final TmfEvent event) { | |
1098 | super.handleData(event); | |
1099 | requestedEvents.add(event); | |
1100 | } | |
1101 | }; | |
1102 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); | |
1103 | providers[0].sendRequest(request); | |
1104 | request.waitForCompletion(); | |
1105 | ||
1106 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
1107 | assertTrue("isCompleted", request.isCompleted()); | |
1108 | assertFalse("isCancelled", request.isCancelled()); | |
1109 | ||
1110 | // Ensure that we have distinct events. | |
1111 | // Don't go overboard: we are not validating the stub! | |
1112 | for (int i = 0; i < NB_EVENTS; i++) { | |
1113 | assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue()); | |
1114 | } | |
1115 | } | |
1116 | ||
1117 | @SuppressWarnings("unchecked") | |
1118 | public void testProcessDataRequestForSomeEvents() throws Exception { | |
1119 | final int startIndex = 100; | |
1120 | final int NB_EVENTS = 1000; | |
1121 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
1122 | ||
1123 | final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, startIndex, NB_EVENTS) { | |
1124 | @Override | |
1125 | public void handleData(final TmfEvent event) { | |
1126 | super.handleData(event); | |
1127 | requestedEvents.add(event); | |
1128 | } | |
1129 | }; | |
1130 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); | |
1131 | providers[0].sendRequest(request); | |
1132 | request.waitForCompletion(); | |
1133 | ||
1134 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
1135 | assertTrue("isCompleted", request.isCompleted()); | |
1136 | assertFalse("isCancelled", request.isCancelled()); | |
1137 | ||
1138 | // Ensure that we have distinct events. | |
1139 | // Don't go overboard: we are not validating the stub! | |
1140 | for (int i = 0; i < NB_EVENTS; i++) { | |
1141 | assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue()); | |
20658947 | 1142 | } |
d18dd09b | 1143 | } |
f17b2f70 | 1144 | |
e31e01e8 | 1145 | // ------------------------------------------------------------------------ |
d18dd09b | 1146 | // cancel |
e31e01e8 | 1147 | // ------------------------------------------------------------------------ |
d18dd09b | 1148 | |
e31e01e8 | 1149 | @SuppressWarnings("unchecked") |
f17b2f70 | 1150 | public void testCancel() throws Exception { |
d18dd09b ASL |
1151 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); |
1152 | ||
f17b2f70 | 1153 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
cb866e08 | 1154 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f17b2f70 FC |
1155 | int nbRead = 0; |
1156 | @Override | |
1157 | public void handleData(final TmfEvent event) { | |
1158 | super.handleData(event); | |
1159 | requestedEvents.add(event); | |
20658947 | 1160 | if (++nbRead == BLOCK_SIZE) { |
f17b2f70 | 1161 | cancel(); |
20658947 | 1162 | } |
f17b2f70 | 1163 | } |
d18dd09b | 1164 | }; |
f17b2f70 | 1165 | final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
951d134a FC |
1166 | providers[0].sendRequest(request); |
1167 | request.waitForCompletion(); | |
d18dd09b | 1168 | |
cb866e08 | 1169 | assertEquals("nbEvents", BLOCK_SIZE, requestedEvents.size()); |
d18dd09b ASL |
1170 | assertTrue("isCompleted", request.isCompleted()); |
1171 | assertTrue("isCancelled", request.isCancelled()); | |
1172 | } | |
e31e01e8 | 1173 | |
1703b536 FC |
1174 | // ------------------------------------------------------------------------ |
1175 | // toString | |
1176 | // ------------------------------------------------------------------------ | |
1177 | ||
1178 | public void testDefaultTmfTraceStub() throws Exception { | |
1179 | assertFalse ("Open trace", fTrace == null); | |
1180 | assertEquals("getType", TmfEvent.class, fTrace.getType()); | |
1181 | assertNull ("getResource", fTrace.getResource()); | |
1182 | assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize()); | |
1183 | assertEquals("getStreamingInterval", 0, fTrace.getStreamingInterval()); | |
1184 | assertEquals("getName", TEST_STREAM, fTrace.getName()); | |
1185 | ||
1186 | assertEquals("getNbEvents", NB_EVENTS, fTrace.getNbEvents()); | |
1187 | assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue()); | |
1188 | assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue()); | |
1189 | assertEquals("getStartTime", 1, fTrace.getStartTime().getValue()); | |
1190 | assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue()); | |
1191 | ||
1192 | String expected = "TmfTrace [fPath=" + fTrace.getPath() + ", fCacheSize=" + fTrace.getCacheSize() + | |
1193 | ", fNbEvents=" + fTrace.getNbEvents() + ", fStartTime=" + fTrace.getStartTime() + | |
1194 | ", fEndTime=" + fTrace.getEndTime() + ", fStreamingInterval=" + fTrace.getStreamingInterval() + | |
1195 | "]"; | |
1196 | assertEquals("toString", expected, fTrace.toString()); | |
1197 | } | |
1198 | ||
e31e01e8 | 1199 | } |