/*******************************************************************************
* Copyright (c) 2009, 2010, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adjusted for new Trace Model
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
/**
* Test suite for the TmfExperiment class (multiple traces).
*/
-@SuppressWarnings("nls")
+@SuppressWarnings({"nls","javadoc"})
public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+ private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM1 = "O-Test-10K";
private static final String TEST_STREAM2 = "E-Test-10K";
private static int NB_EVENTS = 20000;
private static int BLOCK_SIZE = 1000;
- private static ITmfTrace<?>[] fTraces;
+ private static ITmfTrace[] fTraces;
private static TmfExperimentStub fExperiment;
private static byte SCALE = (byte) -3;
// Housekeeping
// ------------------------------------------------------------------------
- private synchronized static ITmfTrace<?>[] setupTrace(final String path1, final String path2) {
+ private synchronized static ITmfTrace[] setupTrace(final String path1, final String path2) {
if (fTraces == null) {
fTraces = new ITmfTrace[2];
try {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+ trace1.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
+
fTraces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
test = new File(FileLocator.toFileURL(location).toURI());
final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+ trace2.setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE));
fTraces[1] = trace2;
} catch (final TmfTraceException e) {
e.printStackTrace();
return fTraces;
}
- public TmfMultiTraceExperimentTest(final String name) throws Exception {
+ /**
+ * @param name the test name
+ */
+ public TmfMultiTraceExperimentTest(final String name) {
super(name);
}
- @SuppressWarnings("unchecked")
@Override
- protected void setUp() throws Exception {
+ protected synchronized void setUp() throws Exception {
super.setUp();
setupTrace(DIRECTORY + File.separator + TEST_STREAM1, DIRECTORY + File.separator + TEST_STREAM2);
if (fExperiment == null) {
- fExperiment = new TmfExperimentStub(EXPERIMENT, (ITmfTrace<TmfEvent>[]) fTraces, BLOCK_SIZE);
+ fExperiment = new TmfExperimentStub(EXPERIMENT, fTraces, BLOCK_SIZE);
fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
}
}
final TmfTimeRange timeRange = fExperiment.getTimeRange();
assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
+
+ TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset());
+ assertEquals("getCurrentTime", fExperiment.getTimeRange().getStartTime(), fExperiment.getCurrentTime());
+
+ ITmfTimestamp startTimestamp = fExperiment.getTimeRange().getStartTime();
+ long endValue = startTimestamp.getValue() + initRange.normalize(0, startTimestamp.getScale()).getValue();
+ ITmfTimestamp endTimestamp = new TmfTimestamp(endValue, startTimestamp.getScale());
+ TmfTimeRange expectedRange = new TmfTimeRange(startTimestamp, endTimestamp);
+ assertEquals("getCurrentRange", expectedRange, fExperiment.getCurrentRange());
}
// ------------------------------------------------------------------------
// seekEvent on rank
// ------------------------------------------------------------------------
- public void testSeekRankOnCacheBoundary() throws Exception {
+ public void testSeekRankOnCacheBoundary() {
long cacheSize = fExperiment.getCacheSize();
assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
}
- public void testSeekRankNotOnCacheBoundary() throws Exception {
+ public void testSeekRankNotOnCacheBoundary() {
long cacheSize = fExperiment.getCacheSize();
assertEquals("Context rank", 4501, context.getRank());
}
- public void testSeekRankOutOfScope() throws Exception {
+ public void testSeekRankOutOfScope() {
// Position trace at beginning
ITmfContext context = fExperiment.seekEvent(-1);
// seekEvent on timestamp
// ------------------------------------------------------------------------
- public void testSeekTimestampOnCacheBoundary() throws Exception {
+ public void testSeekTimestampOnCacheBoundary() {
long cacheSize = fExperiment.getCacheSize();
assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
}
- public void testSeekTimestampNotOnCacheBoundary() throws Exception {
+ public void testSeekTimestampNotOnCacheBoundary() {
// Position trace at event rank 1 (TS = 2)
ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
assertEquals("Context rank", 4501, context.getRank());
}
- public void testSeekTimestampOutOfScope() throws Exception {
+ public void testSeekTimestampOutOfScope() {
// Position trace at beginning
ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
// seekEvent by location (context rank is undefined)
// ------------------------------------------------------------------------
- public void testSeekLocationOnCacheBoundary() throws Exception {
-
+ public void testSeekLocationOnCacheBoundary() {
+
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 0
assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
}
- public void testSeekLocationNotOnCacheBoundary() throws Exception {
+ public void testSeekLocationNotOnCacheBoundary() {
long cacheSize = fExperiment.getCacheSize();
assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
}
- public void testSeekLocationOutOfScope() throws Exception {
+ public void testSeekLocationOutOfScope() {
// Position trace at beginning
- ITmfContext context = fExperiment.seekEvent((ITmfLocation<?>) null);
+ ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
}
// ------------------------------------------------------------------------
- // readtNextEvent - updates the context
+ // getNext - updates the context
// ------------------------------------------------------------------------
- public void testReadNextEvent() throws Exception {
+ private static void validateContextRanks(ITmfContext context) {
+ assertTrue("Experiment context type", context instanceof TmfExperimentContext);
+ TmfExperimentContext ctx = (TmfExperimentContext) context;
- // On lower bound, returns the first event (ts = 0)
- final ITmfContext context = fExperiment.seekEvent(0);
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ int nbTraces = ctx.getContexts().length;
+
+ // expRank = sum(trace ranks) - nbTraces + 1 (if lastTraceRead != NO_TRACE)
+ long expRank = -nbTraces + ((ctx.getLastTrace() != TmfExperimentContext.NO_TRACE) ? 1 : 0);
+ for (int i = 0; i < nbTraces; i++) {
+ long rank = ctx.getContexts()[i].getRank();
+ if (rank == -1) {
+ expRank = -1;
+ break;
+ }
+ expRank += rank;
+ }
+ assertEquals("Experiment context rank", expRank, ctx.getRank());
+ }
+
+ public void testGetNextAfteSeekingOnTS_1() {
+
+ final long INITIAL_TS = 1;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 1)
+ final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
- for (int i = 2; i < 20; i++) {
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfteSeekingOnTS_2() {
+
+ final long INITIAL_TS = 2;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 2)
+ final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
event = fExperiment.getNext(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
}
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfteSeekingOnTS_3() {
+
+ final long INITIAL_TS = 500;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 500)
+ final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnRank_1() {
+
+ final long INITIAL_RANK = 0L;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (rank = 0)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnRank_2() {
+
+ final long INITIAL_RANK = 1L;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (rank = 0)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnRank_3() {
+
+ final long INITIAL_RANK = 500L;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (rank = 0)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnLocation_1() {
+
+ final ITmfLocation INITIAL_LOC = null;
+ final long INITIAL_TS = 1;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 1)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + i, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnLocation_2() {
+
+ final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(1L).getLocation();
+ final long INITIAL_TS = 2;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 2)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextAfterSeekingOnLocation_3() {
+
+ final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(500L).getLocation();
+ final long INITIAL_TS = 501;
+ final int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 501)
+ final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC);
+
+ validateContextRanks(context);
+
+ // Read NB_EVENTS
+ ITmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNext(context);
+ assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
+
+ validateContextRanks(context);
+ }
+
+ public void testGetNextLocation() {
+ ITmfContext context1 = fExperiment.seekEvent(0);
+ fExperiment.getNext(context1);
+ ITmfLocation location = context1.getLocation();
+ ITmfEvent event1 = fExperiment.getNext(context1);
+ ITmfContext context2 = fExperiment.seekEvent(location);
+ ITmfEvent event2 = fExperiment.getNext(context2);
+ assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue());
+ }
+
+ public void testGetNextEndLocation() {
+ ITmfContext context1 = fExperiment.seekEvent(fExperiment.getNbEvents() - 1);
+ fExperiment.getNext(context1);
+ ITmfLocation location = context1.getLocation();
+ ITmfContext context2 = fExperiment.seekEvent(location);
+ ITmfEvent event = fExperiment.getNext(context2);
+ assertNull("Event", event);
}
// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
- public void testProcessRequestForNbEvents() throws Exception {
+ public void testProcessRequestForNbEvents() throws InterruptedException {
final int blockSize = 100;
final int nbEvents = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
}
}
- public void testProcessRequestForNbEvents2() throws Exception {
+ public void testProcessRequestForNbEvents2() throws InterruptedException {
final int blockSize = 2 * NB_EVENTS;
final int nbEvents = 1000;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
}
}
- public void testProcessRequestForAllEvents() throws Exception {
+ public void testProcessRequestForAllEvents() throws InterruptedException {
- final int nbEvents = TmfEventRequest.ALL_DATA;
+ final int nbEvents = TmfDataRequest.ALL_DATA;
final int blockSize = 1;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) {
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
// cancel
// ------------------------------------------------------------------------
- public void testCancel() throws Exception {
+ public void testCancel() throws InterruptedException {
final int nbEvents = NB_EVENTS;
final int blockSize = BLOCK_SIZE;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) {
int nbRead = 0;
@Override
- public void handleData(final TmfEvent event) {
+ public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
if (++nbRead == blockSize) {
// getTimestamp
// ------------------------------------------------------------------------
- public void testGetTimestamp() throws Exception {
-
- assertTrue("getTimestamp", fExperiment.getTimestamp( 0).equals(new TmfTimestamp( 1, (byte) -3)));
- assertTrue("getTimestamp", fExperiment.getTimestamp( 10).equals(new TmfTimestamp( 11, (byte) -3)));
- assertTrue("getTimestamp", fExperiment.getTimestamp( 100).equals(new TmfTimestamp( 101, (byte) -3)));
- assertTrue("getTimestamp", fExperiment.getTimestamp(1000).equals(new TmfTimestamp(1001, (byte) -3)));
- assertTrue("getTimestamp", fExperiment.getTimestamp(2000).equals(new TmfTimestamp(2001, (byte) -3)));
- assertTrue("getTimestamp", fExperiment.getTimestamp(2500).equals(new TmfTimestamp(2501, (byte) -3)));
+ public void testGetTimestamp() {
+ assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0));
+ assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1));
+ assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10));
+ assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100));
+ assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp( 1000));
+ assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp( 2000));
+ assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp( 2500));
+ assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp( 9999));
+ assertEquals("getTimestamp", new TmfTimestamp(20000, (byte) -3), fExperiment.getTimestamp(19999));
+ assertNull("getTimestamp", fExperiment.getTimestamp(20000));
}
-}
\ No newline at end of file
+ // ------------------------------------------------------------------------
+ // getInitialRangeOffset, getCurrentRange, getCurrentTime
+ // ------------------------------------------------------------------------
+ public void testDefaultCurrentTimeValues() {
+ // reset to default initial range offset
+ ((TmfTraceStub)fTraces[0]).setInitialRangeOffset(null);
+ ((TmfTraceStub)fTraces[1]).setInitialRangeOffset(null);
+
+ TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, fTraces, BLOCK_SIZE);
+
+ // verify initial values
+ TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
+ assertEquals("getCurrentTime", TmfTimestamp.ZERO, exp.getCurrentTime());
+ assertEquals("getCurrentRange", TmfTimeRange.NULL_RANGE, exp.getCurrentRange());
+
+ }
+}