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