import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
// Variables
// ------------------------------------------------------------------------
+ private static final TmfTestTrace TEST_TRACE = TmfTestTrace.A_TEST_10K;
private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "A-Test-10K";
private static final int NB_EVENTS = 10000;
private static TmfTraceStub fTrace = null;
@Before
public void setUp() {
- fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ fTrace = setupTrace(TEST_TRACE.getFullPath());
}
@After
@Test
public void testFullConstructor() throws TmfTraceException {
try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
trace.indexTrace(true);
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
+ assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
public void testLiveTraceConstructor() throws TmfTraceException {
final long interval = 100;
try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, interval);
trace.indexTrace(true);
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
+ assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
@Test
public void testCopyConstructor() throws TmfTraceException {
try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
TmfTraceStub original = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, new TmfCheckpointIndexer(null), null);
TmfTraceStub trace = new TmfTraceStub(original);
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
+ assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
// Validate
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
final File testfile = new File(FileLocator.toFileURL(location).toURI());
assertTrue("validate", trace.validate(null, testfile.getPath()).isOK());
assertNull ("getResource", trace.getResource());
assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
+ assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
assertEquals("getType", ITmfEvent.class, fTrace.getType());
assertNull ("getResource", fTrace.getResource());
assertEquals("getStreamingInterval", 0, fTrace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, fTrace.getName());
+ assertEquals("getName", TEST_TRACE.getPath(), fTrace.getName());
assertEquals("getNbEvents", NB_EVENTS, fTrace.getNbEvents());
assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
TmfTraceStub trace = null;
File testfile = null;
try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
// verify initial values
assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset());
trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
trace.indexTrace(true);
+
+ TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
+
} catch (final URISyntaxException e) {
fail("URISyntaxException");
} catch (final IOException e) {
fail("IOException");
}
- assertFalse ("Open trace", trace == null);
-
- TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
}
/**