Commit | Line | Data |
---|---|---|
d18dd09b | 1 | /******************************************************************************* |
e31e01e8 | 2 | * Copyright (c) 2009, 2010 Ericsson |
d18dd09b ASL |
3 | * |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
6c13869b | 13 | package org.eclipse.linuxtools.tmf.core.tests.trace; |
d18dd09b ASL |
14 | |
15 | import java.io.File; | |
e1ab8984 FC |
16 | import java.io.IOException; |
17 | import java.net.URISyntaxException; | |
18 | import java.net.URL; | |
d18dd09b ASL |
19 | import java.util.Vector; |
20 | ||
e1ab8984 FC |
21 | import junit.framework.TestCase; |
22 | ||
23 | import org.eclipse.core.runtime.FileLocator; | |
24 | import org.eclipse.core.runtime.Path; | |
6c13869b FC |
25 | import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; |
26 | import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager; | |
72f1e62a | 27 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
6c13869b FC |
28 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
29 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; | |
30 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; | |
31 | import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; | |
32 | import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; | |
33 | import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; | |
34 | import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint; | |
35 | import org.eclipse.linuxtools.tmf.core.trace.TmfContext; | |
36 | import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; | |
37 | import org.eclipse.linuxtools.tmf.stubs.trace.TmfTraceStub; | |
d18dd09b ASL |
38 | |
39 | /** | |
40 | * <b><u>TmfTraceTest</u></b> | |
41 | * <p> | |
ff4ed569 | 42 | * Test suite for the TmfTrace class. |
d18dd09b | 43 | */ |
3b38ea61 | 44 | @SuppressWarnings("nls") |
d18dd09b ASL |
45 | public class TmfTraceTest extends TestCase { |
46 | ||
ff4ed569 FC |
47 | // ------------------------------------------------------------------------ |
48 | // Variables | |
49 | // ------------------------------------------------------------------------ | |
50 | ||
d18dd09b | 51 | private static final String DIRECTORY = "testfiles"; |
85fb0e54 | 52 | private static final String TEST_STREAM = "A-Test-10K"; |
ff4ed569 | 53 | private static final int BLOCK_SIZE = 500; |
e31e01e8 FC |
54 | private static final int NB_EVENTS = 10000; |
55 | private static TmfTraceStub fTrace = null; | |
d18dd09b ASL |
56 | |
57 | private static byte SCALE = (byte) -3; | |
58 | ||
e31e01e8 | 59 | // ------------------------------------------------------------------------ |
d18dd09b | 60 | // Housekeeping |
e31e01e8 | 61 | // ------------------------------------------------------------------------ |
d18dd09b | 62 | |
ff4ed569 FC |
63 | public TmfTraceTest(String name) throws Exception { |
64 | super(name); | |
65 | } | |
66 | ||
67 | @Override | |
68 | protected void setUp() throws Exception { | |
69 | super.setUp(); | |
70 | fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM); | |
9b635e61 | 71 | // Dummy request to force the trace indexing |
cb866e08 FC |
72 | TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class) { |
73 | @Override | |
f9673903 FC |
74 | public void handleData(TmfEvent event) { |
75 | super.handleData(event); | |
cb866e08 FC |
76 | } |
77 | }; | |
78 | fTrace.sendRequest(request); | |
79 | request.waitForCompletion(); | |
ff4ed569 FC |
80 | } |
81 | ||
82 | @Override | |
83 | protected void tearDown() throws Exception { | |
84 | super.tearDown(); | |
85 | fTrace.dispose(); | |
86 | fTrace = null; | |
87 | } | |
88 | ||
89 | // ------------------------------------------------------------------------ | |
90 | // Helper functions | |
91 | // ------------------------------------------------------------------------ | |
92 | ||
e1ab8984 FC |
93 | private TmfTraceStub setupTrace(String path) { |
94 | if (fTrace == null) { | |
95 | try { | |
cbd4ad82 | 96 | URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); |
e1ab8984 | 97 | File test = new File(FileLocator.toFileURL(location).toURI()); |
b724d349 | 98 | fTrace = new TmfTraceStub(test.toURI().getPath(), BLOCK_SIZE, false); |
e1ab8984 FC |
99 | } catch (URISyntaxException e) { |
100 | e.printStackTrace(); | |
101 | } catch (IOException e) { | |
102 | e.printStackTrace(); | |
103 | } | |
104 | } | |
105 | return fTrace; | |
106 | } | |
107 | ||
e31e01e8 | 108 | // ------------------------------------------------------------------------ |
d18dd09b | 109 | // Constructors |
e31e01e8 | 110 | // ------------------------------------------------------------------------ |
d18dd09b ASL |
111 | |
112 | public void testTmfTraceDefault() throws Exception { | |
e1ab8984 | 113 | TmfTraceStub trace = null; |
ff4ed569 | 114 | File testfile = null; |
e1ab8984 | 115 | try { |
cbd4ad82 | 116 | URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
ff4ed569 | 117 | testfile = new File(FileLocator.toFileURL(location).toURI()); |
b724d349 | 118 | trace = new TmfTraceStub(testfile.toURI().getPath()); |
e1ab8984 | 119 | } catch (URISyntaxException e) { |
ff4ed569 | 120 | fail("URISyntaxException"); |
e1ab8984 | 121 | } catch (IOException e) { |
ff4ed569 | 122 | fail("IOException"); |
e1ab8984 | 123 | } |
ff4ed569 FC |
124 | assertTrue ("Open trace", trace != null); |
125 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
b724d349 | 126 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); |
ff4ed569 | 127 | assertEquals("getName", TEST_STREAM, trace.getName()); |
664902f7 | 128 | assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize()); |
ff4ed569 FC |
129 | } |
130 | ||
131 | public void testTmfTraceDefaultCacheSize() throws Exception { | |
132 | TmfTraceStub trace = null; | |
133 | File testfile = null; | |
134 | try { | |
135 | URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); | |
136 | testfile = new File(FileLocator.toFileURL(location).toURI()); | |
b724d349 | 137 | trace = new TmfTraceStub(testfile.toURI().getPath(), 0); |
ff4ed569 FC |
138 | } catch (URISyntaxException e) { |
139 | fail("URISyntaxException"); | |
140 | } catch (IOException e) { | |
141 | fail("IOException"); | |
142 | } | |
143 | assertTrue ("Open trace", trace != null); | |
144 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
b724d349 | 145 | assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); |
ff4ed569 | 146 | assertEquals("getName", TEST_STREAM, trace.getName()); |
664902f7 | 147 | assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize()); |
d18dd09b ASL |
148 | } |
149 | ||
150 | public void testTmfTrace() throws Exception { | |
ff4ed569 FC |
151 | assertEquals("getType", TmfEvent.class, fTrace.getType()); |
152 | assertEquals("getName", TEST_STREAM, fTrace.getName()); | |
153 | assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize()); | |
154 | } | |
155 | ||
156 | public void testClone() throws Exception { | |
157 | TmfTraceStub trace = fTrace.clone(); | |
158 | assertEquals("getType", TmfEvent.class, trace.getType()); | |
159 | assertEquals("getPath", fTrace.getPath(), trace.getPath()); | |
160 | assertEquals("getName", TEST_STREAM, trace.getName()); | |
161 | assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); | |
162 | assertEquals("getTimeRange", fTrace.getTimeRange(), trace.getTimeRange()); | |
d18dd09b ASL |
163 | } |
164 | ||
ff4ed569 FC |
165 | // ------------------------------------------------------------------------ |
166 | // Get/Set time range | |
167 | // ------------------------------------------------------------------------ | |
168 | ||
169 | public void testSetTimeRange() throws Exception { | |
170 | TmfTraceStub trace = fTrace.clone(); | |
171 | ||
172 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
173 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
174 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
175 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
176 | ||
177 | trace.setTimeRange(new TmfTimeRange(new TmfTimestamp(100), new TmfTimestamp(200))); | |
178 | assertEquals("setTimeRange", 100, trace.getTimeRange().getStartTime().getValue()); | |
179 | assertEquals("setTimeRange", 200, trace.getTimeRange().getEndTime().getValue()); | |
180 | assertEquals("setTimeRange", 100, trace.getStartTime().getValue()); | |
181 | assertEquals("setTimeRange", 200, trace.getEndTime().getValue()); | |
182 | } | |
183 | ||
184 | public void testSetStartTime() throws Exception { | |
185 | TmfTraceStub trace = fTrace.clone(); | |
186 | ||
187 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
188 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
189 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
190 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
191 | ||
192 | trace.setStartTime(new TmfTimestamp(100)); | |
193 | assertEquals("setStartTime", 100, trace.getTimeRange().getStartTime().getValue()); | |
194 | assertEquals("setStartTime", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
195 | assertEquals("setStartTime", 100, trace.getStartTime().getValue()); | |
196 | assertEquals("setStartTime", NB_EVENTS, trace.getEndTime().getValue()); | |
197 | } | |
198 | ||
199 | public void testSetEndTime() throws Exception { | |
200 | TmfTraceStub trace = fTrace.clone(); | |
201 | ||
202 | assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); | |
203 | assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); | |
204 | assertEquals("getStartTime", 1, trace.getStartTime().getValue()); | |
205 | assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); | |
206 | ||
207 | trace.setEndTime(new TmfTimestamp(100)); | |
208 | assertEquals("setEndTime", 1, trace.getTimeRange().getStartTime().getValue()); | |
209 | assertEquals("setEndTime", 100, trace.getTimeRange().getEndTime().getValue()); | |
210 | assertEquals("setEndTime", 1, trace.getStartTime().getValue()); | |
211 | assertEquals("setEndTime", 100, trace.getEndTime().getValue()); | |
212 | } | |
213 | ||
e31e01e8 | 214 | // ------------------------------------------------------------------------ |
54d55ced | 215 | // Verify checkpoints |
e31e01e8 | 216 | // ------------------------------------------------------------------------ |
d18dd09b | 217 | |
ff4ed569 FC |
218 | public void testTmfTraceIndexing() throws Exception { |
219 | assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize()); | |
220 | assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents()); | |
221 | assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue()); | |
222 | assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue()); | |
223 | assertEquals("getStartTime", 1, fTrace.getStartTime().getValue()); | |
224 | assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue()); | |
54d55ced FC |
225 | |
226 | Vector<TmfCheckpoint> checkpoints = fTrace.getCheckpoints(); | |
227 | int pageSize = fTrace.getCacheSize(); | |
228 | assertTrue("Checkpoints exist", checkpoints != null); | |
229 | ||
230 | // Validate that each checkpoint points to the right event | |
231 | for (int i = 0; i < checkpoints.size(); i++) { | |
232 | TmfCheckpoint checkpoint = checkpoints.get(i); | |
233 | TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize); | |
72f1e62a | 234 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
235 | assertTrue(context.getRank() == i * pageSize); |
236 | assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0)); | |
237 | } | |
238 | } | |
239 | ||
240 | // ------------------------------------------------------------------------ | |
241 | // parseEvent - make sure parseEvent doesn't update the context | |
242 | // ------------------------------------------------------------------------ | |
243 | ||
244 | public void testParseEvent() throws Exception { | |
245 | ||
9b635e61 FC |
246 | int NB_READS = 20; |
247 | ||
54d55ced FC |
248 | // On lower bound, returns the first event (ts = 0) |
249 | TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); | |
9b635e61 | 250 | TmfContext svContext = new TmfContext(context); |
54d55ced | 251 | |
72f1e62a | 252 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced | 253 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
9b635e61 FC |
254 | assertEquals("Event rank", 0, context.getRank()); |
255 | assertTrue("parseEvent", context.equals(svContext)); | |
54d55ced FC |
256 | |
257 | event = fTrace.parseEvent(context); | |
258 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
9b635e61 FC |
259 | assertEquals("Event rank", 0, context.getRank()); |
260 | assertTrue("parseEvent", context.equals(svContext)); | |
54d55ced FC |
261 | |
262 | event = fTrace.parseEvent(context); | |
263 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
9b635e61 FC |
264 | assertEquals("Event rank", 0, context.getRank()); |
265 | assertTrue("parseEvent", context.equals(svContext)); | |
54d55ced | 266 | |
9b635e61 FC |
267 | // Position the trace at event NB_READS |
268 | for (int i = 1; i < NB_READS; i++) { | |
54d55ced FC |
269 | event = fTrace.getNextEvent(context); |
270 | assertEquals("Event timestamp", i, event.getTimestamp().getValue()); | |
271 | } | |
272 | ||
9b635e61 | 273 | svContext = new TmfContext(context); |
54d55ced | 274 | event = fTrace.parseEvent(context); |
9b635e61 FC |
275 | assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue()); |
276 | assertEquals("Event rank", NB_READS -1 , context.getRank()); | |
277 | assertTrue("parseEvent", context.equals(svContext)); | |
54d55ced FC |
278 | |
279 | event = fTrace.parseEvent(context); | |
9b635e61 FC |
280 | assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue()); |
281 | assertEquals("Event rank", NB_READS - 1, context.getRank()); | |
282 | assertTrue("parseEvent", context.equals(svContext)); | |
54d55ced FC |
283 | } |
284 | ||
285 | // ------------------------------------------------------------------------ | |
286 | // getNextEvent - updates the context | |
287 | // ------------------------------------------------------------------------ | |
288 | ||
289 | public void testGetNextEvent() throws Exception { | |
290 | ||
9b635e61 FC |
291 | int NB_READS = 20; |
292 | ||
293 | // On lower bound, returns the first event (ts = 1) | |
54d55ced | 294 | TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); |
54d55ced | 295 | |
9b635e61 | 296 | // Read NB_EVENTS |
72f1e62a | 297 | ITmfEvent event; |
9b635e61 | 298 | for (int i = 0; i < NB_READS; i++) { |
54d55ced | 299 | event = fTrace.getNextEvent(context); |
9b635e61 FC |
300 | assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); |
301 | assertEquals("Event rank", i + 1, context.getRank()); | |
54d55ced | 302 | } |
9b635e61 FC |
303 | |
304 | // Make sure we stay positioned | |
305 | event = fTrace.parseEvent(context); | |
306 | assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue()); | |
307 | assertEquals("Event rank", NB_READS, context.getRank()); | |
54d55ced FC |
308 | } |
309 | ||
310 | // ------------------------------------------------------------------------ | |
311 | // seekLocation | |
312 | // Note: seekLocation() does not reliably set the rank | |
313 | // ------------------------------------------------------------------------ | |
314 | ||
315 | public void testSeekLocationOnCacheBoundary() throws Exception { | |
316 | ||
317 | // Position trace at event rank 0 | |
9f584e4c | 318 | TmfContext context = fTrace.seekLocation(null); |
72f1e62a | 319 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced | 320 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
ff4ed569 | 321 | assertEquals("Event rank", 0, context.getRank()); |
9b635e61 FC |
322 | |
323 | context = fTrace.seekLocation(context.getLocation()); | |
324 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
325 | ||
326 | event = fTrace.parseEvent(context); | |
54d55ced | 327 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
9b635e61 FC |
328 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
329 | ||
330 | event = fTrace.getNextEvent(context); | |
331 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); | |
332 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); | |
54d55ced FC |
333 | |
334 | // Position trace at event rank 1000 | |
335 | TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); | |
9b635e61 | 336 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 337 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
338 | |
339 | event = fTrace.parseEvent(context); | |
54d55ced | 340 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
ff4ed569 | 341 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
342 | |
343 | event = fTrace.getNextEvent(context); | |
54d55ced | 344 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
ff4ed569 | 345 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
346 | |
347 | // Position trace at event rank 4000 | |
348 | tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); | |
9b635e61 | 349 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 350 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
351 | |
352 | event = fTrace.parseEvent(context); | |
54d55ced | 353 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
ff4ed569 | 354 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
355 | |
356 | event = fTrace.getNextEvent(context); | |
54d55ced | 357 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
ff4ed569 | 358 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
359 | } |
360 | ||
361 | public void testSeekLocationNotOnCacheBoundary() throws Exception { | |
362 | ||
363 | // Position trace at event rank 9 | |
364 | TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); | |
9b635e61 | 365 | TmfContext context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 366 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 | 367 | |
72f1e62a | 368 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced | 369 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
ff4ed569 | 370 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
371 | |
372 | event = fTrace.getNextEvent(context); | |
54d55ced | 373 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
ff4ed569 | 374 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
375 | |
376 | // Position trace at event rank 999 | |
377 | tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); | |
9b635e61 | 378 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 379 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
380 | |
381 | event = fTrace.parseEvent(context); | |
54d55ced | 382 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
ff4ed569 | 383 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
384 | |
385 | event = fTrace.getNextEvent(context); | |
54d55ced | 386 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
ff4ed569 | 387 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
388 | |
389 | // Position trace at event rank 1001 | |
390 | tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); | |
9b635e61 | 391 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 392 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
393 | |
394 | event = fTrace.parseEvent(context); | |
54d55ced | 395 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
ff4ed569 | 396 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
397 | |
398 | event = fTrace.getNextEvent(context); | |
54d55ced | 399 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
ff4ed569 | 400 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
401 | |
402 | // Position trace at event rank 4500 | |
403 | tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); | |
9b635e61 | 404 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 405 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
406 | |
407 | event = fTrace.parseEvent(context); | |
54d55ced | 408 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
ff4ed569 | 409 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
410 | |
411 | event = fTrace.getNextEvent(context); | |
54d55ced | 412 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
ff4ed569 | 413 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
414 | } |
415 | ||
416 | public void testSeekLocationOutOfScope() throws Exception { | |
417 | ||
418 | // Position trace at beginning | |
419 | TmfContext tmpContext = fTrace.seekLocation(null); | |
9b635e61 | 420 | TmfContext context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 421 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 | 422 | |
72f1e62a | 423 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced | 424 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
ff4ed569 | 425 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
426 | |
427 | event = fTrace.getNextEvent(context); | |
54d55ced | 428 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
ff4ed569 | 429 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
430 | |
431 | // Position trace at event passed the end | |
432 | tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0)); | |
9b635e61 | 433 | context = fTrace.seekLocation(tmpContext.getLocation()); |
ff4ed569 | 434 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
435 | |
436 | event = fTrace.parseEvent(context); | |
54d55ced | 437 | assertEquals("Event timestamp", null, event); |
ff4ed569 | 438 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
9b635e61 FC |
439 | |
440 | event = fTrace.getNextEvent(context); | |
54d55ced | 441 | assertEquals("Event timestamp", null, event); |
ff4ed569 | 442 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
54d55ced FC |
443 | } |
444 | ||
445 | // ------------------------------------------------------------------------ | |
446 | // seekEvent on timestamp | |
447 | // ------------------------------------------------------------------------ | |
d18dd09b | 448 | |
54d55ced FC |
449 | public void testSeekEventOnTimestampOnCacheBoundary() throws Exception { |
450 | ||
451 | // Position trace at event rank 0 | |
452 | TmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0)); | |
453 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 | 454 | |
72f1e62a | 455 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
456 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
457 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 FC |
458 | |
459 | event = fTrace.getNextEvent(context); | |
75828b1a | 460 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
e31e01e8 | 461 | assertEquals("Event rank", 1, context.getRank()); |
d18dd09b | 462 | |
54d55ced FC |
463 | // Position trace at event rank 1000 |
464 | context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); | |
465 | assertEquals("Event rank", 1000, context.getRank()); | |
9b635e61 FC |
466 | |
467 | event = fTrace.parseEvent(context); | |
54d55ced FC |
468 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
469 | assertEquals("Event rank", 1000, context.getRank()); | |
9b635e61 FC |
470 | |
471 | event = fTrace.getNextEvent(context); | |
e31e01e8 FC |
472 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
473 | assertEquals("Event rank", 1001, context.getRank()); | |
d18dd09b | 474 | |
54d55ced FC |
475 | // Position trace at event rank 4000 |
476 | context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); | |
477 | assertEquals("Event rank", 4000, context.getRank()); | |
9b635e61 FC |
478 | |
479 | event = fTrace.parseEvent(context); | |
54d55ced FC |
480 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
481 | assertEquals("Event rank", 4000, context.getRank()); | |
9b635e61 FC |
482 | |
483 | event = fTrace.getNextEvent(context); | |
e31e01e8 FC |
484 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
485 | assertEquals("Event rank", 4001, context.getRank()); | |
75828b1a | 486 | } |
d18dd09b | 487 | |
54d55ced FC |
488 | public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception { |
489 | ||
490 | // Position trace at event rank 1 | |
491 | TmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0)); | |
492 | assertEquals("Event rank", 1, context.getRank()); | |
9b635e61 | 493 | |
72f1e62a | 494 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
495 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
496 | assertEquals("Event rank", 1, context.getRank()); | |
9b635e61 FC |
497 | |
498 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
499 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
500 | assertEquals("Event rank", 2, context.getRank()); | |
d18dd09b | 501 | |
54d55ced | 502 | // Position trace at event rank 9 |
e31e01e8 | 503 | context = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); |
54d55ced | 504 | assertEquals("Event rank", 9, context.getRank()); |
9b635e61 FC |
505 | |
506 | event = fTrace.parseEvent(context); | |
54d55ced FC |
507 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
508 | assertEquals("Event rank", 9, context.getRank()); | |
9b635e61 FC |
509 | |
510 | event = fTrace.getNextEvent(context); | |
e31e01e8 FC |
511 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
512 | assertEquals("Event rank", 10, context.getRank()); | |
d18dd09b | 513 | |
54d55ced FC |
514 | // Position trace at event rank 999 |
515 | context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); | |
516 | assertEquals("Event rank", 999, context.getRank()); | |
9b635e61 FC |
517 | |
518 | event = fTrace.parseEvent(context); | |
54d55ced | 519 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
e31e01e8 | 520 | assertEquals("Event rank", 999, context.getRank()); |
9b635e61 FC |
521 | |
522 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
523 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
524 | assertEquals("Event rank", 1000, context.getRank()); | |
e31e01e8 | 525 | |
54d55ced FC |
526 | // Position trace at event rank 1001 |
527 | context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); | |
e31e01e8 | 528 | assertEquals("Event rank", 1001, context.getRank()); |
9b635e61 FC |
529 | |
530 | event = fTrace.parseEvent(context); | |
54d55ced FC |
531 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
532 | assertEquals("Event rank", 1001, context.getRank()); | |
9b635e61 FC |
533 | |
534 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
535 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
536 | assertEquals("Event rank", 1002, context.getRank()); | |
537 | ||
538 | // Position trace at event rank 4500 | |
539 | context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); | |
540 | assertEquals("Event rank", 4500, context.getRank()); | |
9b635e61 FC |
541 | |
542 | event = fTrace.parseEvent(context); | |
54d55ced FC |
543 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
544 | assertEquals("Event rank", 4500, context.getRank()); | |
9b635e61 FC |
545 | |
546 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
547 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
548 | assertEquals("Event rank", 4501, context.getRank()); | |
75828b1a | 549 | } |
d18dd09b | 550 | |
54d55ced | 551 | public void testSeekEventOnTimestampOutOfScope() throws Exception { |
d18dd09b | 552 | |
54d55ced FC |
553 | // Position trace at beginning |
554 | TmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0)); | |
555 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 | 556 | |
72f1e62a | 557 | ITmfEvent event = fTrace.parseEvent(context); |
75828b1a | 558 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
54d55ced | 559 | assertEquals("Event rank", 0, context.getRank()); |
9b635e61 FC |
560 | |
561 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
562 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
563 | assertEquals("Event rank", 1, context.getRank()); | |
75828b1a | 564 | |
54d55ced FC |
565 | // Position trace at event passed the end |
566 | context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0)); | |
567 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
9b635e61 FC |
568 | |
569 | event = fTrace.parseEvent(context); | |
75828b1a | 570 | assertEquals("Event timestamp", null, event); |
54d55ced | 571 | assertEquals("Event rank", NB_EVENTS, context.getRank()); |
9b635e61 FC |
572 | |
573 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
574 | assertEquals("Event timestamp", null, event); |
575 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
d18dd09b ASL |
576 | } |
577 | ||
54d55ced FC |
578 | // ------------------------------------------------------------------------ |
579 | // seekEvent on rank | |
580 | // ------------------------------------------------------------------------ | |
581 | ||
582 | public void testSeekOnRankOnCacheBoundary() throws Exception { | |
e31e01e8 FC |
583 | |
584 | // On lower bound, returns the first event (ts = 1) | |
54d55ced FC |
585 | TmfContext context = fTrace.seekEvent(0); |
586 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 | 587 | |
72f1e62a | 588 | ITmfEvent event = fTrace.parseEvent(context); |
e31e01e8 | 589 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
54d55ced | 590 | assertEquals("Event rank", 0, context.getRank()); |
9b635e61 FC |
591 | |
592 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
593 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
594 | assertEquals("Event rank", 1, context.getRank()); | |
e31e01e8 | 595 | |
54d55ced FC |
596 | // Position trace at event rank 1000 |
597 | context = fTrace.seekEvent(1000); | |
598 | assertEquals("Event rank", 1000, context.getRank()); | |
9b635e61 FC |
599 | |
600 | event = fTrace.parseEvent(context); | |
54d55ced FC |
601 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
602 | assertEquals("Event rank", 1000, context.getRank()); | |
9b635e61 FC |
603 | |
604 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
605 | assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); |
606 | assertEquals("Event rank", 1001, context.getRank()); | |
e31e01e8 | 607 | |
54d55ced FC |
608 | // Position trace at event rank 4000 |
609 | context = fTrace.seekEvent(4000); | |
610 | assertEquals("Event rank", 4000, context.getRank()); | |
9b635e61 FC |
611 | |
612 | event = fTrace.parseEvent(context); | |
54d55ced FC |
613 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
614 | assertEquals("Event rank", 4000, context.getRank()); | |
9b635e61 FC |
615 | |
616 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
617 | assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); |
618 | assertEquals("Event rank", 4001, context.getRank()); | |
e31e01e8 FC |
619 | } |
620 | ||
54d55ced | 621 | public void testSeekOnRankNotOnCacheBoundary() throws Exception { |
d18dd09b | 622 | |
54d55ced FC |
623 | // Position trace at event rank 9 |
624 | TmfContext context = fTrace.seekEvent(9); | |
625 | assertEquals("Event rank", 9, context.getRank()); | |
9b635e61 | 626 | |
72f1e62a | 627 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
628 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
629 | assertEquals("Event rank", 9, context.getRank()); | |
9b635e61 FC |
630 | |
631 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
632 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
633 | assertEquals("Event rank", 10, context.getRank()); | |
d18dd09b | 634 | |
54d55ced FC |
635 | // Position trace at event rank 999 |
636 | context = fTrace.seekEvent(999); | |
637 | assertEquals("Event rank", 999, context.getRank()); | |
9b635e61 FC |
638 | |
639 | event = fTrace.parseEvent(context); | |
54d55ced FC |
640 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
641 | assertEquals("Event rank", 999, context.getRank()); | |
9b635e61 FC |
642 | |
643 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
644 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
645 | assertEquals("Event rank", 1000, context.getRank()); | |
d18dd09b | 646 | |
54d55ced FC |
647 | // Position trace at event rank 1001 |
648 | context = fTrace.seekEvent(1001); | |
649 | assertEquals("Event rank", 1001, context.getRank()); | |
9b635e61 FC |
650 | |
651 | event = fTrace.parseEvent(context); | |
54d55ced FC |
652 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
653 | assertEquals("Event rank", 1001, context.getRank()); | |
9b635e61 FC |
654 | |
655 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
656 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
657 | assertEquals("Event rank", 1002, context.getRank()); | |
658 | ||
659 | // Position trace at event rank 4500 | |
660 | context = fTrace.seekEvent(4500); | |
661 | assertEquals("Event rank", 4500, context.getRank()); | |
9b635e61 FC |
662 | |
663 | event = fTrace.parseEvent(context); | |
54d55ced FC |
664 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
665 | assertEquals("Event rank", 4500, context.getRank()); | |
9b635e61 FC |
666 | |
667 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
668 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
669 | assertEquals("Event rank", 4501, context.getRank()); | |
d18dd09b ASL |
670 | } |
671 | ||
54d55ced FC |
672 | public void testSeekEventOnRankOfScope() throws Exception { |
673 | ||
674 | // Position trace at beginning | |
675 | TmfContext context = fTrace.seekEvent(-1); | |
676 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 | 677 | |
72f1e62a | 678 | ITmfEvent event = fTrace.parseEvent(context); |
54d55ced FC |
679 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
680 | assertEquals("Event rank", 0, context.getRank()); | |
9b635e61 FC |
681 | |
682 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
683 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
684 | assertEquals("Event rank", 1, context.getRank()); | |
685 | ||
686 | // Position trace at event passed the end | |
687 | context = fTrace.seekEvent(NB_EVENTS); | |
688 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
9b635e61 FC |
689 | |
690 | event = fTrace.parseEvent(context); | |
54d55ced FC |
691 | assertEquals("Event timestamp", null, event); |
692 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
9b635e61 FC |
693 | |
694 | event = fTrace.getNextEvent(context); | |
54d55ced FC |
695 | assertEquals("Event timestamp", null, event); |
696 | assertEquals("Event rank", NB_EVENTS, context.getRank()); | |
697 | } | |
698 | ||
e31e01e8 | 699 | // ------------------------------------------------------------------------ |
d18dd09b | 700 | // processRequest |
e31e01e8 | 701 | // ------------------------------------------------------------------------ |
d18dd09b | 702 | |
e31e01e8 FC |
703 | @SuppressWarnings("unchecked") |
704 | public void testProcessRequestForNbEvents() throws Exception { | |
d18dd09b ASL |
705 | final int BLOCK_SIZE = 100; |
706 | final int NB_EVENTS = 1000; | |
707 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
708 | ||
709 | TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch); | |
e31e01e8 | 710 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f9673903 FC |
711 | @Override |
712 | public void handleData(TmfEvent event) { | |
713 | super.handleData(event); | |
714 | requestedEvents.add(event); | |
715 | } | |
d18dd09b | 716 | }; |
951d134a FC |
717 | ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
718 | providers[0].sendRequest(request); | |
719 | request.waitForCompletion(); | |
d18dd09b ASL |
720 | |
721 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
722 | assertTrue("isCompleted", request.isCompleted()); | |
723 | assertFalse("isCancelled", request.isCancelled()); | |
724 | ||
725 | // Ensure that we have distinct events. | |
726 | // Don't go overboard: we are not validating the stub! | |
727 | for (int i = 0; i < NB_EVENTS; i++) { | |
728 | assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); | |
729 | } | |
730 | } | |
731 | ||
e31e01e8 FC |
732 | @SuppressWarnings("unchecked") |
733 | public void testProcessRequestForAllEvents() throws Exception { | |
d18dd09b ASL |
734 | final int BLOCK_SIZE = 1; |
735 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); | |
736 | ||
737 | TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch); | |
e31e01e8 | 738 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f9673903 FC |
739 | @Override |
740 | public void handleData(TmfEvent event) { | |
741 | super.handleData(event); | |
742 | requestedEvents.add(event); | |
743 | } | |
d18dd09b | 744 | }; |
951d134a FC |
745 | ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
746 | providers[0].sendRequest(request); | |
747 | request.waitForCompletion(); | |
d18dd09b ASL |
748 | |
749 | assertEquals("nbEvents", NB_EVENTS, requestedEvents.size()); | |
750 | assertTrue("isCompleted", request.isCompleted()); | |
751 | assertFalse("isCancelled", request.isCancelled()); | |
752 | ||
753 | // Ensure that we have distinct events. | |
754 | // Don't go overboard: we are not validating the stub! | |
755 | for (int i = 0; i < NB_EVENTS; i++) { | |
756 | assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); | |
757 | } | |
758 | } | |
759 | ||
e31e01e8 | 760 | // ------------------------------------------------------------------------ |
d18dd09b | 761 | // cancel |
e31e01e8 | 762 | // ------------------------------------------------------------------------ |
d18dd09b | 763 | |
e31e01e8 FC |
764 | @SuppressWarnings("unchecked") |
765 | public void testCancel() throws Exception { | |
d18dd09b ASL |
766 | final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>(); |
767 | ||
768 | TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch); | |
cb866e08 | 769 | final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { |
f9673903 FC |
770 | int nbRead = 0; |
771 | @Override | |
772 | public void handleData(TmfEvent event) { | |
773 | super.handleData(event); | |
774 | requestedEvents.add(event); | |
775 | if (++nbRead == BLOCK_SIZE) | |
776 | cancel(); | |
777 | } | |
d18dd09b | 778 | }; |
951d134a FC |
779 | ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); |
780 | providers[0].sendRequest(request); | |
781 | request.waitForCompletion(); | |
d18dd09b | 782 | |
cb866e08 | 783 | assertEquals("nbEvents", BLOCK_SIZE, requestedEvents.size()); |
d18dd09b ASL |
784 | assertTrue("isCompleted", request.isCompleted()); |
785 | assertTrue("isCancelled", request.isCancelled()); | |
786 | } | |
e31e01e8 FC |
787 | |
788 | } |