Commit | Line | Data |
---|---|---|
d18dd09b | 1 | /******************************************************************************* |
0316808c | 2 | * Copyright (c) 2009, 2010, 2012 Ericsson |
9b749023 | 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 | |
9b749023 | 8 | * |
d18dd09b ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
0316808c | 11 | * Francois Chouinard - Adjusted for new Trace Model |
d18dd09b ASL |
12 | *******************************************************************************/ |
13 | ||
9e0640dc | 14 | package org.eclipse.linuxtools.tmf.core.tests.trace; |
d18dd09b ASL |
15 | |
16 | import java.io.File; | |
17 | import java.io.IOException; | |
18 | import java.net.URISyntaxException; | |
19 | import java.net.URL; | |
20 | import java.util.Vector; | |
21 | ||
22 | import junit.framework.TestCase; | |
23 | ||
24 | import org.eclipse.core.runtime.FileLocator; | |
25 | import org.eclipse.core.runtime.Path; | |
17324c9a | 26 | import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext; |
72f1e62a | 27 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
66262ad8 | 28 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
6c13869b FC |
29 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
30 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; | |
31 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; | |
b4f71e4a | 32 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; |
9b749023 | 33 | import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; |
6c13869b FC |
34 | import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; |
35 | import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; | |
36 | import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; | |
0316808c | 37 | import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; |
6c13869b | 38 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
9e0640dc | 39 | import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub; |
4918b8f2 | 40 | import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; |
d18dd09b ASL |
41 | |
42 | /** | |
0316808c | 43 | * Test suite for the TmfExperiment class (multiple traces). |
d18dd09b | 44 | */ |
5419a136 | 45 | @SuppressWarnings({"nls","javadoc"}) |
d18dd09b ASL |
46 | public class TmfMultiTraceExperimentTest extends TestCase { |
47 | ||
0316808c FC |
48 | // ------------------------------------------------------------------------ |
49 | // Attributes | |
50 | // ------------------------------------------------------------------------ | |
66262ad8 | 51 | private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec |
d18dd09b ASL |
52 | private static final String DIRECTORY = "testfiles"; |
53 | private static final String TEST_STREAM1 = "O-Test-10K"; | |
54 | private static final String TEST_STREAM2 = "E-Test-10K"; | |
55 | private static final String EXPERIMENT = "MyExperiment"; | |
56 | private static int NB_EVENTS = 20000; | |
9b635e61 | 57 | private static int BLOCK_SIZE = 1000; |
d18dd09b | 58 | |
6256d8ad AM |
59 | private static ITmfTrace[] fTraces; |
60 | private static TmfExperimentStub fExperiment; | |
d18dd09b ASL |
61 | |
62 | private static byte SCALE = (byte) -3; | |
63 | ||
64 | // ------------------------------------------------------------------------ | |
65 | // Housekeeping | |
66 | // ------------------------------------------------------------------------ | |
67 | ||
6256d8ad | 68 | private synchronized static ITmfTrace[] setupTrace(final String path1, final String path2) { |
25e48683 FC |
69 | if (fTraces == null) { |
70 | fTraces = new ITmfTrace[2]; | |
71 | try { | |
72 | URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null); | |
73 | File test = new File(FileLocator.toFileURL(location).toURI()); | |
20658947 | 74 | final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true); |
66262ad8 BH |
75 | trace1.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE)); |
76 | ||
25e48683 FC |
77 | fTraces[0] = trace1; |
78 | location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null); | |
79 | test = new File(FileLocator.toFileURL(location).toURI()); | |
20658947 | 80 | final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true); |
66262ad8 | 81 | trace2.setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE)); |
25e48683 | 82 | fTraces[1] = trace2; |
b4f71e4a FC |
83 | } catch (final TmfTraceException e) { |
84 | e.printStackTrace(); | |
25e48683 FC |
85 | } catch (final URISyntaxException e) { |
86 | e.printStackTrace(); | |
87 | } catch (final IOException e) { | |
88 | e.printStackTrace(); | |
89 | } | |
90 | } | |
91 | return fTraces; | |
d18dd09b ASL |
92 | } |
93 | ||
54a7a54c FC |
94 | /** |
95 | * @param name the test name | |
96 | */ | |
97 | public TmfMultiTraceExperimentTest(final String name) { | |
25e48683 FC |
98 | super(name); |
99 | } | |
d18dd09b | 100 | |
25e48683 | 101 | @Override |
0879b6b9 | 102 | protected synchronized void setUp() throws Exception { |
25e48683 FC |
103 | super.setUp(); |
104 | setupTrace(DIRECTORY + File.separator + TEST_STREAM1, DIRECTORY + File.separator + TEST_STREAM2); | |
07671572 | 105 | if (fExperiment == null) { |
6256d8ad | 106 | fExperiment = new TmfExperimentStub(EXPERIMENT, fTraces, BLOCK_SIZE); |
9e0640dc | 107 | fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true); |
07671572 | 108 | } |
25e48683 | 109 | } |
d18dd09b | 110 | |
25e48683 FC |
111 | @Override |
112 | protected void tearDown() throws Exception { | |
113 | super.tearDown(); | |
114 | } | |
d18dd09b ASL |
115 | |
116 | // ------------------------------------------------------------------------ | |
117 | // Constructor | |
118 | // ------------------------------------------------------------------------ | |
119 | ||
25e48683 | 120 | public void testBasicTmfExperimentConstructor() { |
9b635e61 | 121 | |
25e48683 | 122 | assertEquals("GetId", EXPERIMENT, fExperiment.getName()); |
d18dd09b ASL |
123 | assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents()); |
124 | ||
25e48683 | 125 | final TmfTimeRange timeRange = fExperiment.getTimeRange(); |
d18dd09b ASL |
126 | assertEquals("getStartTime", 1, timeRange.getStartTime().getValue()); |
127 | assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue()); | |
66262ad8 BH |
128 | |
129 | TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE); | |
130 | assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset()); | |
131 | assertEquals("getCurrentTime", fExperiment.getTimeRange().getStartTime(), fExperiment.getCurrentTime()); | |
132 | ||
133 | ITmfTimestamp startTimestamp = fExperiment.getTimeRange().getStartTime(); | |
134 | long endValue = startTimestamp.getValue() + initRange.normalize(0, startTimestamp.getScale()).getValue(); | |
135 | ITmfTimestamp endTimestamp = new TmfTimestamp(endValue, startTimestamp.getScale()); | |
136 | TmfTimeRange expectedRange = new TmfTimeRange(startTimestamp, endTimestamp); | |
137 | assertEquals("getCurrentRange", expectedRange, fExperiment.getCurrentRange()); | |
25e48683 | 138 | } |
d18dd09b | 139 | |
d18dd09b | 140 | // ------------------------------------------------------------------------ |
0316808c | 141 | // seekEvent on rank |
d18dd09b ASL |
142 | // ------------------------------------------------------------------------ |
143 | ||
54a7a54c | 144 | public void testSeekRankOnCacheBoundary() { |
d18dd09b | 145 | |
0316808c | 146 | long cacheSize = fExperiment.getCacheSize(); |
9b635e61 | 147 | |
0316808c FC |
148 | // On lower bound, returns the first event (TS = 1) |
149 | ITmfContext context = fExperiment.seekEvent(0); | |
150 | assertEquals("Context rank", 0, context.getRank()); | |
25e48683 | 151 | |
c32744d6 | 152 | ITmfEvent event = fExperiment.getNext(context); |
d18dd09b | 153 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
0316808c | 154 | assertEquals("Context rank", 1, context.getRank()); |
25e48683 | 155 | |
0316808c FC |
156 | // Position trace at event rank [cacheSize] |
157 | context = fExperiment.seekEvent(cacheSize); | |
158 | assertEquals("Context rank", cacheSize, context.getRank()); | |
25e48683 | 159 | |
c32744d6 | 160 | event = fExperiment.getNext(context); |
0316808c FC |
161 | assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue()); |
162 | assertEquals("Context rank", cacheSize + 1, context.getRank()); | |
d18dd09b | 163 | |
0316808c FC |
164 | // Position trace at event rank [4 * cacheSize] |
165 | context = fExperiment.seekEvent(4 * cacheSize); | |
166 | assertEquals("Context rank", 4 * cacheSize, context.getRank()); | |
25e48683 | 167 | |
c32744d6 | 168 | event = fExperiment.getNext(context); |
0316808c FC |
169 | assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue()); |
170 | assertEquals("Context rank", 4 * cacheSize + 1, context.getRank()); | |
d18dd09b ASL |
171 | } |
172 | ||
54a7a54c | 173 | public void testSeekRankNotOnCacheBoundary() { |
d18dd09b | 174 | |
0316808c | 175 | long cacheSize = fExperiment.getCacheSize(); |
25e48683 | 176 | |
0316808c FC |
177 | // Position trace at event rank 9 |
178 | ITmfContext context = fExperiment.seekEvent(9); | |
179 | assertEquals("Context rank", 9, context.getRank()); | |
25e48683 | 180 | |
c32744d6 | 181 | ITmfEvent event = fExperiment.getNext(context); |
d18dd09b | 182 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
0316808c | 183 | assertEquals("Context rank", 10, context.getRank()); |
d18dd09b | 184 | |
0316808c FC |
185 | // Position trace at event rank [cacheSize - 1] |
186 | context = fExperiment.seekEvent(cacheSize - 1); | |
187 | assertEquals("Context rank", cacheSize - 1, context.getRank()); | |
25e48683 | 188 | |
c32744d6 | 189 | event = fExperiment.getNext(context); |
0316808c FC |
190 | assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue()); |
191 | assertEquals("Context rank", cacheSize, context.getRank()); | |
d18dd09b | 192 | |
0316808c FC |
193 | // Position trace at event rank [cacheSize + 1] |
194 | context = fExperiment.seekEvent(cacheSize + 1); | |
195 | assertEquals("Context rank", cacheSize + 1, context.getRank()); | |
25e48683 | 196 | |
c32744d6 | 197 | event = fExperiment.getNext(context); |
0316808c FC |
198 | assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue()); |
199 | assertEquals("Context rank", cacheSize + 2, context.getRank()); | |
d18dd09b | 200 | |
25e48683 | 201 | // Position trace at event rank 4500 |
0316808c FC |
202 | context = fExperiment.seekEvent(4500); |
203 | assertEquals("Context rank", 4500, context.getRank()); | |
25e48683 | 204 | |
c32744d6 | 205 | event = fExperiment.getNext(context); |
d18dd09b | 206 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
0316808c | 207 | assertEquals("Context rank", 4501, context.getRank()); |
d18dd09b ASL |
208 | } |
209 | ||
54a7a54c | 210 | public void testSeekRankOutOfScope() { |
d18dd09b | 211 | |
25e48683 | 212 | // Position trace at beginning |
0316808c | 213 | ITmfContext context = fExperiment.seekEvent(-1); |
d18dd09b | 214 | assertEquals("Event rank", 0, context.getRank()); |
25e48683 | 215 | |
c32744d6 | 216 | ITmfEvent event = fExperiment.getNext(context); |
d18dd09b | 217 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
0316808c | 218 | assertEquals("Context rank", 1, context.getRank()); |
d18dd09b | 219 | |
25e48683 | 220 | // Position trace at event passed the end |
0316808c FC |
221 | context = fExperiment.seekEvent(NB_EVENTS); |
222 | assertEquals("Context rank", NB_EVENTS, context.getRank()); | |
223 | ||
c32744d6 | 224 | event = fExperiment.getNext(context); |
0316808c FC |
225 | assertNull("Event", event); |
226 | assertEquals("Context rank", NB_EVENTS, context.getRank()); | |
d18dd09b ASL |
227 | } |
228 | ||
25e48683 FC |
229 | // ------------------------------------------------------------------------ |
230 | // seekEvent on timestamp | |
231 | // ------------------------------------------------------------------------ | |
232 | ||
54a7a54c | 233 | public void testSeekTimestampOnCacheBoundary() { |
25e48683 | 234 | |
0316808c | 235 | long cacheSize = fExperiment.getCacheSize(); |
25e48683 | 236 | |
0316808c FC |
237 | // Position trace at event rank 0 |
238 | ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0)); | |
239 | assertEquals("Context rank", 0, context.getRank()); | |
25e48683 | 240 | |
c32744d6 | 241 | ITmfEvent event = fExperiment.getNext(context); |
25e48683 | 242 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
0316808c | 243 | assertEquals("Context rank", 1, context.getRank()); |
25e48683 | 244 | |
0316808c FC |
245 | // Position trace at event rank [cacheSize] |
246 | context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE, 0)); | |
247 | assertEquals("Event rank", cacheSize, context.getRank()); | |
25e48683 | 248 | |
c32744d6 | 249 | event = fExperiment.getNext(context); |
0316808c FC |
250 | assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue()); |
251 | assertEquals("Context rank", cacheSize + 1, context.getRank()); | |
25e48683 | 252 | |
0316808c FC |
253 | // Position trace at event rank [4 * cacheSize] |
254 | context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE, 0)); | |
255 | assertEquals("Context rank", 4 * cacheSize, context.getRank()); | |
25e48683 | 256 | |
c32744d6 | 257 | event = fExperiment.getNext(context); |
0316808c FC |
258 | assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue()); |
259 | assertEquals("Context rank", 4 * cacheSize + 1, context.getRank()); | |
25e48683 FC |
260 | } |
261 | ||
54a7a54c | 262 | public void testSeekTimestampNotOnCacheBoundary() { |
25e48683 | 263 | |
0316808c FC |
264 | // Position trace at event rank 1 (TS = 2) |
265 | ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0)); | |
266 | assertEquals("Context rank", 1, context.getRank()); | |
25e48683 | 267 | |
c32744d6 | 268 | ITmfEvent event = fExperiment.getNext(context); |
25e48683 | 269 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
0316808c | 270 | assertEquals("Context rank", 2, context.getRank()); |
25e48683 | 271 | |
0316808c | 272 | // Position trace at event rank 9 (TS = 10) |
25e48683 | 273 | context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0)); |
0316808c | 274 | assertEquals("Context rank", 9, context.getRank()); |
25e48683 | 275 | |
c32744d6 | 276 | event = fExperiment.getNext(context); |
25e48683 | 277 | assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); |
0316808c | 278 | assertEquals("Context rank", 10, context.getRank()); |
25e48683 | 279 | |
0316808c | 280 | // Position trace at event rank 999 (TS = 1000) |
25e48683 | 281 | context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0)); |
0316808c | 282 | assertEquals("Context rank", 999, context.getRank()); |
25e48683 | 283 | |
c32744d6 | 284 | event = fExperiment.getNext(context); |
25e48683 | 285 | assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); |
0316808c | 286 | assertEquals("Context rank", 1000, context.getRank()); |
25e48683 | 287 | |
0316808c | 288 | // Position trace at event rank 1001 (TS = 1002) |
25e48683 | 289 | context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0)); |
0316808c | 290 | assertEquals("Context rank", 1001, context.getRank()); |
25e48683 | 291 | |
c32744d6 | 292 | event = fExperiment.getNext(context); |
25e48683 | 293 | assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); |
0316808c | 294 | assertEquals("Context rank", 1002, context.getRank()); |
25e48683 | 295 | |
0316808c | 296 | // Position trace at event rank 4500 (TS = 4501) |
25e48683 | 297 | context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0)); |
0316808c | 298 | assertEquals("Context rank", 4500, context.getRank()); |
25e48683 | 299 | |
c32744d6 | 300 | event = fExperiment.getNext(context); |
25e48683 | 301 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
0316808c | 302 | assertEquals("Context rank", 4501, context.getRank()); |
25e48683 FC |
303 | } |
304 | ||
54a7a54c | 305 | public void testSeekTimestampOutOfScope() { |
25e48683 FC |
306 | |
307 | // Position trace at beginning | |
0316808c | 308 | ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0)); |
25e48683 FC |
309 | assertEquals("Event rank", 0, context.getRank()); |
310 | ||
c32744d6 | 311 | ITmfEvent event = fExperiment.getNext(context); |
25e48683 FC |
312 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
313 | assertEquals("Event rank", 1, context.getRank()); | |
314 | ||
315 | // Position trace at event passed the end | |
316 | context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0)); | |
c32744d6 | 317 | event = fExperiment.getNext(context); |
0316808c | 318 | assertNull("Event location", event); |
9b635e61 | 319 | assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); |
25e48683 FC |
320 | } |
321 | ||
322 | // ------------------------------------------------------------------------ | |
0316808c | 323 | // seekEvent by location (context rank is undefined) |
25e48683 FC |
324 | // ------------------------------------------------------------------------ |
325 | ||
54a7a54c | 326 | public void testSeekLocationOnCacheBoundary() { |
9b749023 | 327 | |
0316808c | 328 | long cacheSize = fExperiment.getCacheSize(); |
25e48683 | 329 | |
0316808c FC |
330 | // Position trace at event rank 0 |
331 | ITmfContext tmpContext = fExperiment.seekEvent(0); | |
332 | ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation()); | |
25e48683 | 333 | |
c32744d6 | 334 | ITmfEvent event = fExperiment.getNext(context); |
25e48683 | 335 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
25e48683 | 336 | |
c32744d6 | 337 | event = fExperiment.getNext(context); |
0316808c | 338 | assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); |
25e48683 | 339 | |
0316808c FC |
340 | // Position trace at event rank 'cacheSize' |
341 | tmpContext = fExperiment.seekEvent(cacheSize); | |
342 | context = fExperiment.seekEvent(tmpContext.getLocation()); | |
25e48683 | 343 | |
c32744d6 | 344 | event = fExperiment.getNext(context); |
0316808c | 345 | assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue()); |
25e48683 | 346 | |
c32744d6 | 347 | event = fExperiment.getNext(context); |
0316808c | 348 | assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue()); |
25e48683 | 349 | |
0316808c FC |
350 | // Position trace at event rank 4 * 'cacheSize' |
351 | tmpContext = fExperiment.seekEvent(4 * cacheSize); | |
352 | context = fExperiment.seekEvent(tmpContext.getLocation()); | |
25e48683 | 353 | |
c32744d6 | 354 | event = fExperiment.getNext(context); |
0316808c | 355 | assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue()); |
25e48683 | 356 | |
c32744d6 | 357 | event = fExperiment.getNext(context); |
0316808c | 358 | assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue()); |
25e48683 FC |
359 | } |
360 | ||
54a7a54c | 361 | public void testSeekLocationNotOnCacheBoundary() { |
25e48683 | 362 | |
0316808c | 363 | long cacheSize = fExperiment.getCacheSize(); |
25e48683 | 364 | |
0316808c FC |
365 | // Position trace at event 'cacheSize' - 1 |
366 | ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1); | |
367 | ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation()); | |
25e48683 | 368 | |
c32744d6 | 369 | ITmfEvent event = fExperiment.getNext(context); |
0316808c | 370 | assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue()); |
25e48683 | 371 | |
c32744d6 | 372 | event = fExperiment.getNext(context); |
0316808c | 373 | assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue()); |
25e48683 | 374 | |
0316808c FC |
375 | // Position trace at event rank 2 * 'cacheSize' - 1 |
376 | tmpContext = fExperiment.seekEvent(2 * cacheSize - 1); | |
377 | context = fExperiment.seekEvent(tmpContext.getLocation()); | |
378 | context = fExperiment.seekEvent(2 * cacheSize - 1); | |
25e48683 | 379 | |
c32744d6 | 380 | event = fExperiment.getNext(context); |
0316808c | 381 | assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue()); |
25e48683 | 382 | |
c32744d6 | 383 | event = fExperiment.getNext(context); |
0316808c | 384 | assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue()); |
25e48683 FC |
385 | |
386 | // Position trace at event rank 4500 | |
0316808c FC |
387 | tmpContext = fExperiment.seekEvent(4500); |
388 | context = fExperiment.seekEvent(tmpContext.getLocation()); | |
25e48683 | 389 | |
c32744d6 | 390 | event = fExperiment.getNext(context); |
25e48683 | 391 | assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); |
25e48683 | 392 | |
c32744d6 | 393 | event = fExperiment.getNext(context); |
0316808c | 394 | assertEquals("Event timestamp", 4502, event.getTimestamp().getValue()); |
25e48683 FC |
395 | } |
396 | ||
54a7a54c | 397 | public void testSeekLocationOutOfScope() { |
25e48683 FC |
398 | |
399 | // Position trace at beginning | |
1e1bef82 | 400 | ITmfContext context = fExperiment.seekEvent((ITmfLocation) null); |
25e48683 | 401 | |
c32744d6 | 402 | ITmfEvent event = fExperiment.getNext(context); |
25e48683 | 403 | assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); |
25e48683 | 404 | } |
d18dd09b | 405 | |
9b635e61 | 406 | // ------------------------------------------------------------------------ |
17324c9a | 407 | // getNext - updates the context |
9b635e61 | 408 | // ------------------------------------------------------------------------ |
d18dd09b | 409 | |
54a7a54c | 410 | private static void validateContextRanks(ITmfContext context) { |
17324c9a FC |
411 | assertTrue("Experiment context type", context instanceof TmfExperimentContext); |
412 | TmfExperimentContext ctx = (TmfExperimentContext) context; | |
9b635e61 | 413 | |
17324c9a FC |
414 | int nbTraces = ctx.getContexts().length; |
415 | ||
416 | // expRank = sum(trace ranks) - nbTraces + 1 (if lastTraceRead != NO_TRACE) | |
417 | long expRank = -nbTraces + ((ctx.getLastTrace() != TmfExperimentContext.NO_TRACE) ? 1 : 0); | |
418 | for (int i = 0; i < nbTraces; i++) { | |
419 | long rank = ctx.getContexts()[i].getRank(); | |
420 | if (rank == -1) { | |
421 | expRank = -1; | |
422 | break; | |
423 | } | |
424 | expRank += rank; | |
425 | } | |
426 | assertEquals("Experiment context rank", expRank, ctx.getRank()); | |
427 | } | |
428 | ||
54a7a54c | 429 | public void testGetNextAfteSeekingOnTS_1() { |
17324c9a FC |
430 | |
431 | final long INITIAL_TS = 1; | |
432 | final int NB_READS = 20; | |
433 | ||
434 | // On lower bound, returns the first event (ts = 1) | |
435 | final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0)); | |
436 | ||
437 | validateContextRanks(context); | |
438 | ||
439 | // Read NB_EVENTS | |
440 | ITmfEvent event; | |
441 | for (int i = 0; i < NB_READS; i++) { | |
442 | event = fExperiment.getNext(context); | |
443 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
444 | assertEquals("Event rank", INITIAL_TS + i, context.getRank()); | |
445 | } | |
446 | ||
447 | // Make sure we stay positioned | |
448 | event = fExperiment.parseEvent(context); | |
449 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
450 | assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank()); | |
451 | ||
452 | validateContextRanks(context); | |
453 | } | |
454 | ||
54a7a54c | 455 | public void testGetNextAfteSeekingOnTS_2() { |
17324c9a FC |
456 | |
457 | final long INITIAL_TS = 2; | |
458 | final int NB_READS = 20; | |
459 | ||
460 | // On lower bound, returns the first event (ts = 2) | |
461 | final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0)); | |
462 | ||
463 | validateContextRanks(context); | |
464 | ||
465 | // Read NB_EVENTS | |
466 | ITmfEvent event; | |
467 | for (int i = 0; i < NB_READS; i++) { | |
468 | event = fExperiment.getNext(context); | |
469 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
470 | assertEquals("Event rank", INITIAL_TS + i, context.getRank()); | |
471 | } | |
472 | ||
473 | // Make sure we stay positioned | |
474 | event = fExperiment.parseEvent(context); | |
475 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
476 | assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank()); | |
477 | ||
478 | validateContextRanks(context); | |
479 | } | |
480 | ||
54a7a54c | 481 | public void testGetNextAfteSeekingOnTS_3() { |
17324c9a FC |
482 | |
483 | final long INITIAL_TS = 500; | |
484 | final int NB_READS = 20; | |
485 | ||
486 | // On lower bound, returns the first event (ts = 500) | |
487 | final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0)); | |
488 | ||
489 | validateContextRanks(context); | |
490 | ||
491 | // Read NB_EVENTS | |
492 | ITmfEvent event; | |
493 | for (int i = 0; i < NB_READS; i++) { | |
494 | event = fExperiment.getNext(context); | |
495 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
496 | assertEquals("Event rank", INITIAL_TS + i, context.getRank()); | |
497 | } | |
498 | ||
499 | // Make sure we stay positioned | |
500 | event = fExperiment.parseEvent(context); | |
501 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
502 | assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank()); | |
503 | ||
504 | validateContextRanks(context); | |
505 | } | |
506 | ||
54a7a54c | 507 | public void testGetNextAfterSeekingOnRank_1() { |
17324c9a FC |
508 | |
509 | final long INITIAL_RANK = 0L; | |
510 | final int NB_READS = 20; | |
511 | ||
512 | // On lower bound, returns the first event (rank = 0) | |
513 | final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK); | |
514 | ||
515 | validateContextRanks(context); | |
516 | ||
517 | // Read NB_EVENTS | |
518 | ITmfEvent event; | |
519 | for (int i = 0; i < NB_READS; i++) { | |
520 | event = fExperiment.getNext(context); | |
521 | assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue()); | |
522 | assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank()); | |
523 | } | |
524 | ||
525 | // Make sure we stay positioned | |
526 | event = fExperiment.parseEvent(context); | |
527 | assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue()); | |
528 | assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank()); | |
529 | ||
530 | validateContextRanks(context); | |
531 | } | |
532 | ||
54a7a54c | 533 | public void testGetNextAfterSeekingOnRank_2() { |
17324c9a FC |
534 | |
535 | final long INITIAL_RANK = 1L; | |
536 | final int NB_READS = 20; | |
537 | ||
538 | // On lower bound, returns the first event (rank = 0) | |
539 | final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK); | |
d18dd09b | 540 | |
17324c9a FC |
541 | validateContextRanks(context); |
542 | ||
543 | // Read NB_EVENTS | |
544 | ITmfEvent event; | |
545 | for (int i = 0; i < NB_READS; i++) { | |
c32744d6 | 546 | event = fExperiment.getNext(context); |
17324c9a FC |
547 | assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue()); |
548 | assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank()); | |
9b635e61 | 549 | } |
17324c9a FC |
550 | |
551 | // Make sure we stay positioned | |
552 | event = fExperiment.parseEvent(context); | |
553 | assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue()); | |
554 | assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank()); | |
555 | ||
556 | validateContextRanks(context); | |
557 | } | |
558 | ||
54a7a54c | 559 | public void testGetNextAfterSeekingOnRank_3() { |
17324c9a FC |
560 | |
561 | final long INITIAL_RANK = 500L; | |
562 | final int NB_READS = 20; | |
563 | ||
564 | // On lower bound, returns the first event (rank = 0) | |
565 | final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK); | |
566 | ||
567 | validateContextRanks(context); | |
568 | ||
569 | // Read NB_EVENTS | |
570 | ITmfEvent event; | |
571 | for (int i = 0; i < NB_READS; i++) { | |
572 | event = fExperiment.getNext(context); | |
573 | assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue()); | |
574 | assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank()); | |
575 | } | |
576 | ||
577 | // Make sure we stay positioned | |
578 | event = fExperiment.parseEvent(context); | |
579 | assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue()); | |
580 | assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank()); | |
581 | ||
582 | validateContextRanks(context); | |
583 | } | |
584 | ||
54a7a54c | 585 | public void testGetNextAfterSeekingOnLocation_1() { |
17324c9a | 586 | |
1e1bef82 | 587 | final ITmfLocation INITIAL_LOC = null; |
17324c9a FC |
588 | final long INITIAL_TS = 1; |
589 | final int NB_READS = 20; | |
590 | ||
591 | // On lower bound, returns the first event (ts = 1) | |
592 | final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC); | |
593 | ||
594 | validateContextRanks(context); | |
595 | ||
596 | // Read NB_EVENTS | |
597 | ITmfEvent event; | |
598 | for (int i = 0; i < NB_READS; i++) { | |
599 | event = fExperiment.getNext(context); | |
600 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
601 | assertEquals("Event rank", INITIAL_TS + i, context.getRank()); | |
602 | } | |
603 | ||
604 | // Make sure we stay positioned | |
605 | event = fExperiment.parseEvent(context); | |
606 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
607 | assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank()); | |
608 | ||
609 | validateContextRanks(context); | |
610 | } | |
611 | ||
54a7a54c | 612 | public void testGetNextAfterSeekingOnLocation_2() { |
17324c9a | 613 | |
1e1bef82 | 614 | final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(1L).getLocation(); |
17324c9a FC |
615 | final long INITIAL_TS = 2; |
616 | final int NB_READS = 20; | |
617 | ||
618 | // On lower bound, returns the first event (ts = 2) | |
619 | final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC); | |
620 | ||
621 | validateContextRanks(context); | |
622 | ||
623 | // Read NB_EVENTS | |
624 | ITmfEvent event; | |
625 | for (int i = 0; i < NB_READS; i++) { | |
626 | event = fExperiment.getNext(context); | |
627 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
628 | } | |
629 | ||
630 | // Make sure we stay positioned | |
631 | event = fExperiment.parseEvent(context); | |
632 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
633 | ||
634 | validateContextRanks(context); | |
635 | } | |
636 | ||
54a7a54c | 637 | public void testGetNextAfterSeekingOnLocation_3() { |
17324c9a | 638 | |
1e1bef82 | 639 | final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(500L).getLocation(); |
17324c9a FC |
640 | final long INITIAL_TS = 501; |
641 | final int NB_READS = 20; | |
642 | ||
643 | // On lower bound, returns the first event (ts = 501) | |
644 | final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC); | |
645 | ||
646 | validateContextRanks(context); | |
647 | ||
648 | // Read NB_EVENTS | |
649 | ITmfEvent event; | |
650 | for (int i = 0; i < NB_READS; i++) { | |
651 | event = fExperiment.getNext(context); | |
652 | assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue()); | |
653 | } | |
654 | ||
655 | // Make sure we stay positioned | |
656 | event = fExperiment.parseEvent(context); | |
657 | assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue()); | |
658 | ||
659 | validateContextRanks(context); | |
660 | } | |
661 | ||
54a7a54c | 662 | public void testGetNextLocation() { |
17324c9a FC |
663 | ITmfContext context1 = fExperiment.seekEvent(0); |
664 | fExperiment.getNext(context1); | |
d62bb185 | 665 | ITmfLocation location = context1.getLocation(); |
17324c9a FC |
666 | ITmfEvent event1 = fExperiment.getNext(context1); |
667 | ITmfContext context2 = fExperiment.seekEvent(location); | |
668 | ITmfEvent event2 = fExperiment.getNext(context2); | |
669 | assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue()); | |
670 | } | |
671 | ||
54a7a54c | 672 | public void testGetNextEndLocation() { |
17324c9a FC |
673 | ITmfContext context1 = fExperiment.seekEvent(fExperiment.getNbEvents() - 1); |
674 | fExperiment.getNext(context1); | |
d62bb185 | 675 | ITmfLocation location = context1.getLocation(); |
17324c9a FC |
676 | ITmfContext context2 = fExperiment.seekEvent(location); |
677 | ITmfEvent event = fExperiment.getNext(context2); | |
678 | assertNull("Event", event); | |
d18dd09b | 679 | } |
9b635e61 | 680 | |
d18dd09b ASL |
681 | // ------------------------------------------------------------------------ |
682 | // processRequest | |
683 | // ------------------------------------------------------------------------ | |
684 | ||
54a7a54c | 685 | public void testProcessRequestForNbEvents() throws InterruptedException { |
9b635e61 | 686 | |
25e48683 | 687 | final int blockSize = 100; |
d18dd09b | 688 | final int nbEvents = 1000; |
6256d8ad | 689 | final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>(); |
d18dd09b | 690 | |
25e48683 | 691 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
6256d8ad | 692 | final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { |
25e48683 | 693 | @Override |
6256d8ad | 694 | public void handleData(final ITmfEvent event) { |
25e48683 FC |
695 | super.handleData(event); |
696 | requestedEvents.add(event); | |
697 | } | |
d18dd09b ASL |
698 | }; |
699 | fExperiment.sendRequest(request); | |
700 | request.waitForCompletion(); | |
701 | ||
702 | assertEquals("nbEvents", nbEvents, requestedEvents.size()); | |
703 | assertTrue("isCompleted", request.isCompleted()); | |
704 | assertFalse("isCancelled", request.isCancelled()); | |
705 | ||
706 | // Ensure that we have distinct events. | |
25e48683 | 707 | // Don't go overboard: we are not validating the stub! |
20658947 | 708 | for (int i = 0; i < nbEvents; i++) { |
d18dd09b | 709 | assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); |
20658947 | 710 | } |
d18dd09b | 711 | } |
25e48683 | 712 | |
54a7a54c | 713 | public void testProcessRequestForNbEvents2() throws InterruptedException { |
9b635e61 | 714 | |
25e48683 | 715 | final int blockSize = 2 * NB_EVENTS; |
d18dd09b | 716 | final int nbEvents = 1000; |
6256d8ad | 717 | final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>(); |
d18dd09b | 718 | |
25e48683 | 719 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
6256d8ad | 720 | final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { |
25e48683 | 721 | @Override |
6256d8ad | 722 | public void handleData(final ITmfEvent event) { |
25e48683 FC |
723 | super.handleData(event); |
724 | requestedEvents.add(event); | |
725 | } | |
d18dd09b ASL |
726 | }; |
727 | fExperiment.sendRequest(request); | |
728 | request.waitForCompletion(); | |
729 | ||
730 | assertEquals("nbEvents", nbEvents, requestedEvents.size()); | |
731 | assertTrue("isCompleted", request.isCompleted()); | |
732 | assertFalse("isCancelled", request.isCancelled()); | |
733 | ||
734 | // Ensure that we have distinct events. | |
25e48683 | 735 | // Don't go overboard: we are not validating the stub! |
20658947 | 736 | for (int i = 0; i < nbEvents; i++) { |
d18dd09b | 737 | assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); |
20658947 | 738 | } |
d18dd09b | 739 | } |
25e48683 | 740 | |
54a7a54c | 741 | public void testProcessRequestForAllEvents() throws InterruptedException { |
9b635e61 | 742 | |
9b749023 | 743 | final int nbEvents = TmfDataRequest.ALL_DATA; |
d18dd09b | 744 | final int blockSize = 1; |
6256d8ad | 745 | final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>(); |
25e48683 | 746 | final long nbExpectedEvents = NB_EVENTS; |
d18dd09b | 747 | |
25e48683 | 748 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
6256d8ad | 749 | final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { |
25e48683 | 750 | @Override |
6256d8ad | 751 | public void handleData(final ITmfEvent event) { |
25e48683 FC |
752 | super.handleData(event); |
753 | requestedEvents.add(event); | |
754 | } | |
d18dd09b ASL |
755 | }; |
756 | fExperiment.sendRequest(request); | |
757 | request.waitForCompletion(); | |
758 | ||
9b635e61 | 759 | assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size()); |
d18dd09b ASL |
760 | assertTrue("isCompleted", request.isCompleted()); |
761 | assertFalse("isCancelled", request.isCancelled()); | |
762 | ||
763 | // Ensure that we have distinct events. | |
25e48683 | 764 | // Don't go overboard: we are not validating the stub! |
20658947 | 765 | for (int i = 0; i < nbExpectedEvents; i++) { |
d18dd09b | 766 | assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); |
20658947 | 767 | } |
d18dd09b | 768 | } |
25e48683 | 769 | |
d18dd09b ASL |
770 | // ------------------------------------------------------------------------ |
771 | // cancel | |
772 | // ------------------------------------------------------------------------ | |
773 | ||
54a7a54c | 774 | public void testCancel() throws InterruptedException { |
9b635e61 | 775 | |
25e48683 | 776 | final int nbEvents = NB_EVENTS; |
9b635e61 | 777 | final int blockSize = BLOCK_SIZE; |
6256d8ad | 778 | final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>(); |
d18dd09b | 779 | |
25e48683 | 780 | final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); |
6256d8ad | 781 | final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { |
25e48683 FC |
782 | int nbRead = 0; |
783 | @Override | |
6256d8ad | 784 | public void handleData(final ITmfEvent event) { |
25e48683 FC |
785 | super.handleData(event); |
786 | requestedEvents.add(event); | |
20658947 | 787 | if (++nbRead == blockSize) { |
25e48683 | 788 | cancel(); |
20658947 | 789 | } |
25e48683 | 790 | } |
9b635e61 FC |
791 | @Override |
792 | public void handleCancel() { | |
20658947 | 793 | if (requestedEvents.size() < blockSize) { |
25e48683 | 794 | System.out.println("aie"); |
20658947 | 795 | } |
9b635e61 | 796 | } |
d18dd09b ASL |
797 | }; |
798 | fExperiment.sendRequest(request); | |
799 | request.waitForCompletion(); | |
800 | ||
801 | assertEquals("nbEvents", blockSize, requestedEvents.size()); | |
802 | assertTrue("isCompleted", request.isCompleted()); | |
803 | assertTrue("isCancelled", request.isCancelled()); | |
804 | } | |
25e48683 | 805 | |
d18dd09b ASL |
806 | // ------------------------------------------------------------------------ |
807 | // getTimestamp | |
808 | // ------------------------------------------------------------------------ | |
809 | ||
54a7a54c | 810 | public void testGetTimestamp() { |
17324c9a FC |
811 | assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0)); |
812 | assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1)); | |
813 | assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10)); | |
814 | assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100)); | |
815 | assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp( 1000)); | |
816 | assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp( 2000)); | |
817 | assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp( 2500)); | |
818 | assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp( 9999)); | |
819 | assertEquals("getTimestamp", new TmfTimestamp(20000, (byte) -3), fExperiment.getTimestamp(19999)); | |
820 | assertNull("getTimestamp", fExperiment.getTimestamp(20000)); | |
d18dd09b ASL |
821 | } |
822 | ||
66262ad8 BH |
823 | // ------------------------------------------------------------------------ |
824 | // getInitialRangeOffset, getCurrentRange, getCurrentTime | |
825 | // ------------------------------------------------------------------------ | |
826 | public void testDefaultCurrentTimeValues() { | |
827 | // reset to default initial range offset | |
828 | ((TmfTraceStub)fTraces[0]).setInitialRangeOffset(null); | |
829 | ((TmfTraceStub)fTraces[1]).setInitialRangeOffset(null); | |
830 | ||
831 | TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, fTraces, BLOCK_SIZE); | |
832 | ||
833 | // verify initial values | |
834 | TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE); | |
835 | assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset()); | |
836 | assertEquals("getCurrentTime", TmfTimestamp.ZERO, exp.getCurrentTime()); | |
837 | assertEquals("getCurrentRange", TmfTimeRange.NULL_RANGE, exp.getCurrentRange()); | |
838 | ||
839 | } | |
17324c9a | 840 | } |