Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2015-03-05 23:01:30 +0000
committerAlexander Kurtakov2015-03-06 07:15:11 +0000
commit9c69e0d701f29b841fb52aff378b74b5267a5bdd (patch)
treeebd67565063682e060ec11cc1fa1b3110bff7e25 /lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core
parentea6ea585fe1fc68f842db9c3584d4cc5c3909acd (diff)
downloadorg.eclipse.linuxtools-9c69e0d701f29b841fb52aff378b74b5267a5bdd.tar.gz
org.eclipse.linuxtools-9c69e0d701f29b841fb52aff378b74b5267a5bdd.tar.xz
org.eclipse.linuxtools-9c69e0d701f29b841fb52aff378b74b5267a5bdd.zip
Remove content of the lttng folder and corresponding target dependencies
The LTTng component (also known as TMF) of Linux Tools has moved to the Trace Compass project. A README file was added to explain that the code moved. Change-Id: I939275594beccc78155f37671d1765539764eabc Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/43270 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core')
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/AllTmfCoreTests.java46
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCorePluginTest.java54
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCoreTestPlugin.java84
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AllTests.java32
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisManagerTest.java130
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java270
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java257
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisParameterProviderTest.java81
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementHelperTest.java182
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementTest.java243
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfEventProviderTest.java362
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfProviderManagerTest.java330
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java40
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java365
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java417
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeManagerTest.java242
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java233
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfNanoTimestampTest.java293
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java293
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java112
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java373
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampDeltaTest.java131
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java394
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java670
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java179
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/TmfCollapseFilterTest.java168
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/AllTests.java29
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java594
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfEventRequestTest.java313
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalManagerTest.java558
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalThrottlerTest.java224
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java119
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/StateSystemAnalysisModuleTest.java97
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/AllTests.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java116
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderTest.java541
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java311
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/SyncTest.java247
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TimeOffsetTest.java166
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformFactoryTest.java127
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformTest.java144
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java255
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java941
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java814
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java1389
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java374
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllBench.java251
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllTests.java31
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/BTreeTest.java118
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/FlatArrayTest.java87
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java84
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AbstractIndexTest.java283
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AllTests.java29
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfBTreeIndexTest.java69
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest.java23
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java236
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java243
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java192
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/TmfLocationTest.java252
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/XmlStubTraceTest.java191
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceContextTest.java238
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceEventContentTest.java232
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceTest.java259
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java125
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java108
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/PairTest.java127
78 files changed, 0 insertions, 16881 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/AllTmfCoreTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/AllTmfCoreTests.java
deleted file mode 100644
index 691ac6022e..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/AllTmfCoreTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 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
- * Alexandre Montplaisir - Port to JUnit4, enable CTF and statistics tests
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Master test suite for TMF Core.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfCorePluginTest.class,
- org.eclipse.linuxtools.tmf.core.tests.analysis.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.component.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.event.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.event.lookup.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.filter.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.request.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.signal.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.statesystem.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.synchronization.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.indexer.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.location.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.stub.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.trace.text.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.uml2sd.AllTests.class,
- org.eclipse.linuxtools.tmf.core.tests.util.AllTests.class
-})
-public class AllTmfCoreTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCorePluginTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCorePluginTest.java
deleted file mode 100644
index 4e09e75cc2..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCorePluginTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests;
-
-import static org.junit.Assert.assertEquals;
-
-import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.junit.Test;
-
-/**
- * Test the TMF core plug-in activator
- */
-public class TmfCorePluginTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // Plug-in instantiation
- static final Activator fPlugin = new Activator();
-
- // ------------------------------------------------------------------------
- // Test cases
- // ------------------------------------------------------------------------
-
- /**
- * Test the plugin ID.
- */
- @Test
- public void testTmfCorePluginId() {
- assertEquals("Plugin ID", "org.eclipse.linuxtools.tmf.core", Activator.PLUGIN_ID);
- }
-
- /**
- * Test the getDefault() static method.
- */
- @Test
- public void testGetDefault() {
- Activator plugin = Activator.getDefault();
- assertEquals("getDefault()", plugin, fPlugin);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCoreTestPlugin.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCoreTestPlugin.java
deleted file mode 100644
index 4d6ec364fb..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCoreTestPlugin.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
-import org.osgi.framework.BundleContext;
-
-/**
- * <b><u>TmfTestPlugin</u></b>
- * <p>
- * The activator class controls the plug-in life cycle
- */
-public class TmfCoreTestPlugin extends Plugin {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // The plug-in ID
- @SuppressWarnings("javadoc")
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.tests";
-
- // The shared instance
- private static TmfCoreTestPlugin fPlugin;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * The constructor
- */
- public TmfCoreTestPlugin() {
- setDefault(this);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return the shared instance
- */
- public static TmfCoreTestPlugin getDefault() {
- return fPlugin;
- }
-
- /**
- * @param plugin the shared instance
- */
- private static void setDefault(TmfCoreTestPlugin plugin) {
- fPlugin = plugin;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- setDefault(this);
- TmfCoreTracer.init();
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- TmfCoreTracer.stop();
- setDefault(null);
- super.stop(context);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AllTests.java
deleted file mode 100644
index a97a023406..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AllTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Unit tests for the analysis package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- AnalysisManagerTest.class,
- AnalysisModuleTest.class,
- AnalysisModuleHelperTest.class,
- AnalysisParameterProviderTest.class,
- AnalysisRequirementTest.class,
- AnalysisRequirementHelperTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisManagerTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisManagerTest.java
deleted file mode 100644
index da3af39495..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisManagerTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleSource;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.AnalysisModuleSourceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.AnalysisModuleTestHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfAnalysisModule class
- */
-public class AnalysisManagerTest {
-
- /** Id of analysis module with parameter */
- public static final String MODULE_PARAM = "org.eclipse.linuxtools.tmf.core.tests.analysis.test";
- /** ID of analysis module with parameter and default value */
- public static final String MODULE_PARAM_DEFAULT = "org.eclipse.linuxtools.tmf.core.tests.analysis.test2";
- /** ID of analysis module for trace 2 classes only */
- public static final String MODULE_SECOND = "org.eclipse.linuxtools.tmf.core.tests.analysis.testother";
- /** Id of analysis module with requirements */
- public static final String MODULE_REQ = "org.eclipse.linuxtools.tmf.core.tests.analysis.reqtest";
-
- private ITmfTrace fTrace;
-
- /**
- * Set up some trace code
- */
- @Before
- public void setupTraces() {
- fTrace = TmfTestTrace.A_TEST_10K2.getTraceAsStub2();
- }
-
- /**
- * Some tests use traces, let's clean them here
- */
- @After
- public void cleanupTraces() {
- TmfTestTrace.A_TEST_10K.dispose();
- fTrace.dispose();
- }
-
- /**
- * Test suite for the {@link TmfAnalysisManager#getAnalysisModules()} method
- */
- @Test
- public void testGetAnalysisModules() {
- Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules();
- /* At least 3 modules should be found */
- assertTrue(modules.size() >= 3);
-
- IAnalysisModuleHelper module = modules.get(MODULE_PARAM_DEFAULT);
- assertTrue(module.isAutomatic());
-
- module = modules.get(MODULE_PARAM);
- assertFalse(module.isAutomatic());
- }
-
- /**
- * Test suite for {@link TmfAnalysisManager#getAnalysisModules(Class)} Use
- * the test TMF trace and test trace2 stubs as sample traces
- */
- @Test
- public void testListForTraces() {
- /* Generic TmfTrace */
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
- Map<String, IAnalysisModuleHelper> map = TmfAnalysisManager.getAnalysisModules(trace.getClass());
-
- assertTrue(map.containsKey(MODULE_PARAM));
- assertTrue(map.containsKey(MODULE_PARAM_DEFAULT));
- assertFalse(map.containsKey(MODULE_SECOND));
-
- /* TmfTraceStub2 class */
- map = TmfAnalysisManager.getAnalysisModules(fTrace.getClass());
-
- assertTrue(map.containsKey(MODULE_PARAM));
- assertTrue(map.containsKey(MODULE_PARAM_DEFAULT));
- assertTrue(map.containsKey(MODULE_SECOND));
- }
-
- /**
- * Test suite to test refresh of analysis module when adding a {@link IAnalysisModuleSource}
- */
- @Test
- public void testSources() {
- /* Make sure that modules in the new source are not in the list already */
- /* Generic TmfTrace */
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
- Map<String, IAnalysisModuleHelper> map = TmfAnalysisManager.getAnalysisModules(trace.getClass());
-
- assertFalse(map.containsKey(AnalysisModuleTestHelper.moduleStubEnum.TEST.name()));
-
- /* TmfTraceStub2 class */
- map = TmfAnalysisManager.getAnalysisModules(fTrace.getClass());
-
- assertFalse(map.containsKey(AnalysisModuleTestHelper.moduleStubEnum.TEST2.name()));
-
- /* Add new source */
- TmfAnalysisManager.registerModuleSource(new AnalysisModuleSourceStub());
-
- /* Now make sure the modules are present */
- map = TmfAnalysisManager.getAnalysisModules(trace.getClass());
- assertTrue(map.containsKey(AnalysisModuleTestHelper.moduleStubEnum.TEST.name()));
-
- map = TmfAnalysisManager.getAnalysisModules(fTrace.getClass());
- assertTrue(map.containsKey(AnalysisModuleTestHelper.moduleStubEnum.TEST2.name()));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java
deleted file mode 100644
index 1c9ff0b8da..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- * Mathieu Rail - Added tests for getting a module's requirements
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
-import org.eclipse.linuxtools.tmf.core.analysis.Messages;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisModuleHelperConfigElement;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis2;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestRequirementAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub2;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub3;
-import org.eclipse.osgi.util.NLS;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Test suite for the {@link TmfAnalysisModuleHelperConfigElement} class
- *
- * @author Geneviève Bastien
- */
-public class AnalysisModuleHelperTest {
-
- private IAnalysisModuleHelper fModule;
- private IAnalysisModuleHelper fModuleOther;
- private IAnalysisModuleHelper fReqModule;
- private ITmfTrace fTrace;
-
- /**
- * Gets the module helpers for 2 test modules
- */
- @Before
- public void getModules() {
- fModule = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_PARAM);
- assertNotNull(fModule);
- assertTrue(fModule instanceof TmfAnalysisModuleHelperConfigElement);
- fModuleOther = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_SECOND);
- assertNotNull(fModuleOther);
- assertTrue(fModuleOther instanceof TmfAnalysisModuleHelperConfigElement);
- fReqModule = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_REQ);
- assertNotNull(fReqModule);
- assertTrue(fReqModule instanceof TmfAnalysisModuleHelperConfigElement);
- fTrace = TmfTestTrace.A_TEST_10K2.getTraceAsStub2();
- }
-
- /**
- * Some tests use traces, let's clean them here
- */
- @After
- public void cleanupTraces() {
- TmfTestTrace.A_TEST_10K.dispose();
- fTrace.dispose();
- }
-
- /**
- * Test the helper's getters and setters
- */
- @Test
- public void testHelperGetters() {
- /* With first module */
- assertEquals(AnalysisManagerTest.MODULE_PARAM, fModule.getId());
- assertEquals("Test analysis", fModule.getName());
- assertFalse(fModule.isAutomatic());
-
- Bundle helperbundle = fModule.getBundle();
- Bundle thisbundle = Platform.getBundle("org.eclipse.linuxtools.tmf.core.tests");
- assertNotNull(helperbundle);
- assertEquals(thisbundle, helperbundle);
-
- /* With other module */
- assertEquals(AnalysisManagerTest.MODULE_SECOND, fModuleOther.getId());
- assertEquals("Test other analysis", fModuleOther.getName());
- assertTrue(fModuleOther.isAutomatic());
- }
-
- /**
- * Test the
- * {@link TmfAnalysisModuleHelperConfigElement#appliesToTraceType(Class)}
- * method for the 2 modules
- */
- @Test
- public void testAppliesToTrace() {
- /* stub module */
- assertFalse(fModule.appliesToTraceType(TmfTrace.class));
- assertTrue(fModule.appliesToTraceType(TmfTraceStub.class));
- assertTrue(fModule.appliesToTraceType(TmfTraceStub2.class));
- assertFalse(fModule.appliesToTraceType(TmfTraceStub3.class));
-
- /* stub module 2 */
- assertFalse(fModuleOther.appliesToTraceType(TmfTrace.class));
- assertFalse(fModuleOther.appliesToTraceType(TmfTraceStub.class));
- assertTrue(fModuleOther.appliesToTraceType(TmfTraceStub2.class));
- assertTrue(fModuleOther.appliesToTraceType(TmfTraceStub3.class));
- }
-
- /**
- * Test the
- * {@link TmfAnalysisModuleHelperConfigElement#newModule(ITmfTrace)} method
- * for the 2 modules
- */
- @Test
- public void testNewModule() {
- /* Test analysis module with traceStub */
- Exception exception = null;
- try (IAnalysisModule module = fModule.newModule(TmfTestTrace.A_TEST_10K.getTrace());) {
- assertNotNull(module);
- assertTrue(module instanceof TestAnalysis);
- } catch (TmfAnalysisException e) {
- exception = e;
- }
- assertNull(exception);
-
- /* TestAnalysis2 module with trace, should return an exception */
- try (IAnalysisModule module = fModuleOther.newModule(TmfTestTrace.A_TEST_10K.getTrace());) {
- } catch (TmfAnalysisException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals(NLS.bind(Messages.TmfAnalysisModuleHelper_AnalysisDoesNotApply, fModuleOther.getName()), exception.getMessage());
-
- /* TestAnalysis2 module with a TraceStub2 */
- exception = null;
- try (IAnalysisModule module = fModuleOther.newModule(fTrace);) {
- assertNotNull(module);
- assertTrue(module instanceof TestAnalysis2);
- } catch (TmfAnalysisException e) {
- exception = e;
- }
- assertNull(exception);
- }
-
- /**
- * Test for the initialization of parameters from the extension points
- */
- @Test
- public void testParameters() {
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
-
- /*
- * This analysis has a parameter, but no default value. we should be
- * able to set the parameter
- */
- IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_PARAM);
- try (IAnalysisModule module = helper.newModule(trace);) {
- assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
-
- } catch (TmfAnalysisException e1) {
- fail(e1.getMessage());
- return;
- }
-
- /* This module has a parameter with default value */
- helper = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_PARAM_DEFAULT);
- try (IAnalysisModule module = helper.newModule(trace);) {
- assertEquals(3, module.getParameter(TestAnalysis.PARAM_TEST));
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
-
- } catch (TmfAnalysisException e1) {
- fail(e1.getMessage());
- return;
- }
-
- /*
- * This module does not have a parameter so setting it should throw an
- * error
- */
- helper = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_SECOND);
- Exception exception = null;
- try (IAnalysisModule module = helper.newModule(fTrace);) {
-
- assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
-
- try {
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- } catch (RuntimeException e) {
- exception = e;
- }
- } catch (TmfAnalysisException e1) {
- fail(e1.getMessage());
- return;
- }
- assertNotNull(exception);
- }
-
- /**
- * Test for the
- * {@link TmfAnalysisModuleHelperConfigElement#getValidTraceTypes} method
- */
- @Test
- public void testGetValidTraceTypes() {
- Set<Class<? extends ITmfTrace>> expected = ImmutableSet.of((Class<? extends ITmfTrace>) TmfTraceStub.class, TmfTraceStub2.class, TmfTraceStub3.class);
- Iterable<Class<? extends ITmfTrace>> traceTypes = fReqModule.getValidTraceTypes();
- assertEquals(expected, traceTypes);
- }
-
- /**
- * Test for the
- * {@link TmfAnalysisModuleHelperConfigElement#getAnalysisRequirements}
- * method
- */
- @Test
- public void testGetRequirements() {
- Iterable<TmfAnalysisRequirement> requirements = fReqModule.getAnalysisRequirements();
- assertNotNull(requirements);
-
- Map<String, TmfAnalysisRequirement> rMap = new HashMap<>();
-
- for (TmfAnalysisRequirement req : requirements) {
- assertFalse(rMap.containsKey(req.getType()));
- rMap.put(req.getType(), req);
- }
- assertEquals(2, rMap.size());
-
- /* Test if all types and values have been obtained */
- TmfAnalysisRequirement req = rMap.get(TestRequirementAnalysis.EVENT_TYPE);
- assertNotNull(req);
-
- Set<String> values = req.getValues();
- assertEquals(3, values.size());
- assertTrue(values.contains(TestRequirementAnalysis.EXIT_SYSCALL));
- assertTrue(values.contains(TestRequirementAnalysis.SCHED_SWITCH));
- assertTrue(values.contains(TestRequirementAnalysis.SCHED_WAKEUP));
-
- req = rMap.get(TestRequirementAnalysis.FIELD_TYPE);
- assertNotNull(req);
-
- values = req.getValues();
- assertEquals(2, values.size());
- assertTrue(values.contains(TestRequirementAnalysis.PID));
- assertTrue(values.contains(TestRequirementAnalysis.TID));
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java
deleted file mode 100644
index fbeac78c63..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.analysis.Messages;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAbstractAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestHelper;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis2;
-import org.eclipse.osgi.util.NLS;
-import org.junit.After;
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TmfAbstractAnalysisModule} class
- */
-public class AnalysisModuleTest {
-
- private static String MODULE_GENERIC_ID = "test.id";
- private static String MODULE_GENERIC_NAME = "Test analysis";
-
- /**
- * Some tests use traces, let's clean them here
- */
- @After
- public void cleanupTraces() {
- TmfTestTrace.A_TEST_10K.dispose();
- }
-
- /**
- * Test suite for analysis module getters and setters
- */
- @Test
- public void testGettersSetters() {
- try (IAnalysisModule module = new TestAnalysis();) {
-
- module.setName(MODULE_GENERIC_NAME);
- module.setId(MODULE_GENERIC_ID);
- assertEquals(MODULE_GENERIC_ID, module.getId());
- assertEquals(MODULE_GENERIC_NAME, module.getName());
-
- module.setAutomatic(false);
- assertFalse(module.isAutomatic());
- module.setAutomatic(true);
- assertTrue(module.isAutomatic());
- module.addParameter(TestAnalysis.PARAM_TEST);
- assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
-
- /* Try to set and get wrong parameter */
- String wrongParam = "abc";
- Exception exception = null;
- try {
- module.setParameter(wrongParam, 1);
- } catch (RuntimeException e) {
- exception = e;
- assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_InvalidParameter, wrongParam, module.getName()), e.getMessage());
- }
- assertNotNull(exception);
- assertNull(module.getParameter(wrongParam));
- }
- }
-
- private static TestAnalysis setUpAnalysis() {
- TestAnalysis module = new TestAnalysis();
-
- module.setName(MODULE_GENERIC_NAME);
- module.setId(MODULE_GENERIC_ID);
- module.addParameter(TestAnalysis.PARAM_TEST);
-
- return module;
- }
-
- /**
- * Test suite for analysis module
- * {@link TmfAbstractAnalysisModule#waitForCompletion} with successful
- * execution
- */
- @Test
- public void testWaitForCompletionSuccess() {
- try (TestAnalysis module = setUpAnalysis();) {
-
- IStatus status = module.schedule();
- assertEquals(IStatus.ERROR, status.getSeverity());
-
- /* Set a stub trace for analysis */
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- }
-
- /* Default execution, with output 1 */
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- status = module.schedule();
- assertEquals(Status.OK_STATUS, status);
- boolean completed = module.waitForCompletion();
-
- assertTrue(completed);
- assertEquals(1, module.getAnalysisOutput());
- }
- }
-
- /**
- * Test suite for {@link TmfAbstractAnalysisModule#waitForCompletion} with cancellation
- */
- @Test
- public void testWaitForCompletionCancelled() {
- try (TestAnalysis module = setUpAnalysis();) {
-
- /* Set a stub trace for analysis */
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
- try {
- module.setTrace(trace);
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- }
-
- module.setParameter(TestAnalysis.PARAM_TEST, 0);
- IStatus status = module.schedule();
- assertEquals(Status.OK_STATUS, status);
- boolean completed = module.waitForCompletion();
-
- assertFalse(completed);
- assertEquals(0, module.getAnalysisOutput());
- }
- }
-
- /**
- * Test the {@link TmfAbstractAnalysisModule#setTrace(ITmfTrace)} method with wrong trace
- */
- @Test
- public void testSetWrongTrace() {
- try (IAnalysisModule module = new TestAnalysis2();) {
-
- module.setName(MODULE_GENERIC_NAME);
- module.setId(MODULE_GENERIC_ID);
- assertEquals(MODULE_GENERIC_ID, module.getId());
- assertEquals(MODULE_GENERIC_NAME, module.getName());
-
- Exception exception = null;
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute, module.getName()), exception.getMessage());
- }
- }
-
- /**
- * Test suite for the {@link TmfAbstractAnalysisModule#cancel()} method
- */
- @Test
- public void testCancel() {
- try (TestAnalysis module = setUpAnalysis();) {
-
- module.setParameter(TestAnalysis.PARAM_TEST, 999);
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- }
-
- assertEquals(Status.OK_STATUS, module.schedule());
-
- /* Give the job a chance to start */
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail(e.getMessage());
- }
-
- module.cancel();
- assertFalse(module.waitForCompletion());
- assertEquals(-1, module.getAnalysisOutput());
- }
- }
-
- /**
- * Test suite for the {@link IAnalysisModule#notifyParameterChanged(String)}
- * method
- */
- @Test
- public void testParameterChanged() {
- try (TestAnalysis module = setUpAnalysis();) {
-
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- }
-
- /* Check exception if no wrong parameter name */
- Exception exception = null;
- try {
- module.notifyParameterChanged("aaa");
- } catch (RuntimeException e) {
- exception = e;
- }
- assertNotNull(exception);
-
- /*
- * Cannot test anymore of this method, need a parameter provider to
- * do this
- */
- }
- }
-
- /**
- * Test the {@link TmfTestHelper#executeAnalysis(IAnalysisModule)} method
- */
- @Test
- public void testHelper() {
- try (TestAnalysis module = setUpAnalysis();) {
-
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- }
-
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- boolean res = TmfTestHelper.executeAnalysis(module);
- assertTrue(res);
-
- module.setParameter(TestAnalysis.PARAM_TEST, 0);
- res = TmfTestHelper.executeAnalysis(module);
- assertFalse(res);
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisParameterProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisParameterProviderTest.java
deleted file mode 100644
index 51e6c15e49..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisParameterProviderTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisParameterProvider;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysisParameterProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test the TmfAbstractParameterProvider class
- *
- * @author Geneviève Bastien
- */
-public class AnalysisParameterProviderTest {
-
- /**
- * Registers the parameter provider
- */
- @Before
- public void setup() {
- TmfAnalysisManager.registerParameterProvider(AnalysisManagerTest.MODULE_PARAM, TestAnalysisParameterProvider.class);
- }
-
- /**
- * Cleanup the trace after testing
- */
- @After
- public void cleanupTrace() {
- TmfTestTrace.A_TEST_10K.dispose();
- }
-
- /**
- * Test that the provider's value is used
- */
- @Test
- public void testProviderTmfTrace() {
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
- /* Make sure the value is set to null */
- IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_PARAM);
- try (IAnalysisModule module = helper.newModule(trace);) {
-
- assertEquals(10, module.getParameter(TestAnalysis.PARAM_TEST));
-
- /* Change the value of the parameter in the provider */
- List<IAnalysisParameterProvider> providers = TmfAnalysisManager.getParameterProviders(module, trace);
- assertEquals(1, providers.size());
- TestAnalysisParameterProvider provider = (TestAnalysisParameterProvider) providers.get(0);
- provider.setValue(5);
- assertEquals(5, module.getParameter(TestAnalysis.PARAM_TEST));
-
- } catch (TmfAnalysisException e) {
- fail(e.getMessage());
- return;
- }
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementHelperTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementHelperTest.java
deleted file mode 100644
index 65f1366113..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementHelperTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * 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:
- * Guilliano Molaire - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisRequirementProvider;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirementHelper;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.AnalysisModuleTestHelper;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.AnalysisModuleTestHelper.moduleStubEnum;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.AnalysisRequirementFactory;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Multimap;
-
-/**
- * Test suite for the {@link TmfAnalysisRequirementHelper} class
- */
-public class AnalysisRequirementHelperTest {
-
- private AnalysisModuleTestHelper fTestModuleHelper;
- private AnalysisModuleTestHelper fTestModuleHelper2;
-
- /**
- * Set up analysis modules
- */
- @Before
- public void setUpTest() {
- fTestModuleHelper = new AnalysisModuleTestHelper(moduleStubEnum.TEST);
- fTestModuleHelper2 = new AnalysisModuleTestHelper(moduleStubEnum.TEST2);
- }
-
- /**
- * Test suite for the
- * {@link TmfAnalysisRequirementHelper#getRequirementValues(IAnalysisRequirementProvider, String)}
- * method
- */
- @Test
- public void testGetRequirementValues() {
- /* Test with a supported type */
- String type = AnalysisRequirementFactory.REQUIREMENT_TYPE_1;
- Set<String> values = TmfAnalysisRequirementHelper.getRequirementValues(fTestModuleHelper, type);
- assertEquals(AnalysisRequirementFactory.REQUIREMENT_VALUES_1.size(), values.size());
-
- /* Test with a type not supported */
- type = AnalysisRequirementFactory.REQUIREMENT_TYPE_2;
- values = TmfAnalysisRequirementHelper.getRequirementValues(fTestModuleHelper, type);
- assertTrue(values.isEmpty());
- }
-
- /**
- * Test suite for the
- * {@link TmfAnalysisRequirementHelper#getRequirementValues(IAnalysisRequirementProvider, String, ValuePriorityLevel)}
- * method
- */
- @Test
- public void testGetRequirementValuesWithLevel() {
- /* Test with a supported type */
- String type = AnalysisRequirementFactory.REQUIREMENT_TYPE_2;
- Set<String> values = TmfAnalysisRequirementHelper.getRequirementValues(fTestModuleHelper2, type, ValuePriorityLevel.MANDATORY);
- assertEquals(3, values.size());
-
- /* Test with another value level */
- values = TmfAnalysisRequirementHelper.getRequirementValues(fTestModuleHelper2, type, ValuePriorityLevel.OPTIONAL);
- assertEquals(2, values.size());
-
- /* Test with a type not supported */
- type = AnalysisRequirementFactory.REQUIREMENT_TYPE_1;
- values = TmfAnalysisRequirementHelper.getRequirementValues(fTestModuleHelper2, type, ValuePriorityLevel.MANDATORY);
- assertTrue(values.isEmpty());
- }
-
- /**
- * Test suite for the
- * {@link TmfAnalysisRequirementHelper#getRequirementValuesMap(Iterable)}
- * method
- */
- @Test
- public void testGetRequirementValuesMap() {
- Set<IAnalysisRequirementProvider> providers = new HashSet<>();
- providers.add(fTestModuleHelper2);
- providers.add(fTestModuleHelper);
-
- Multimap<String, String> valuesByType = TmfAnalysisRequirementHelper.getRequirementValuesMap(providers);
- assertFalse(valuesByType.isEmpty());
-
- /* There should be 3 types */
- assertEquals(3, valuesByType.keySet().size());
-
- Collection<String> values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_1);
- assertEquals(4, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_1));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_2));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_2);
- assertEquals(5, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_1));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_2));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_4));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_3);
- assertEquals(3, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_4));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
- }
-
- /**
- * Test suite for the
- * {@link TmfAnalysisRequirementHelper#getRequirementValuesMap(Iterable, ValuePriorityLevel)}
- * method
- */
- @Test
- public void testGetRequirementValuesMapWithLevel() {
- Set<IAnalysisRequirementProvider> providers = new HashSet<>();
- providers.add(fTestModuleHelper2);
- providers.add(fTestModuleHelper);
-
- /* There should be 3 optional requirements types */
- Multimap<String, String> valuesByType = TmfAnalysisRequirementHelper.getRequirementValuesMap(providers, ValuePriorityLevel.OPTIONAL);
- assertTrue(!valuesByType.isEmpty());
- assertEquals(1, valuesByType.keySet().size());
-
- Collection<String> values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_1);
- assertTrue(values.isEmpty());
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_2);
- assertEquals(2, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_2));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_4));
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_3);
- assertTrue(values.isEmpty());
-
- /* And 3 types with mandatory requirements */
- valuesByType = TmfAnalysisRequirementHelper.getRequirementValuesMap(providers, ValuePriorityLevel.MANDATORY);
- assertTrue(!valuesByType.isEmpty());
- assertEquals(3, valuesByType.keySet().size());
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_1);
- assertEquals(4, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_1));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_2));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_2);
- assertEquals(3, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_1));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
-
- values = valuesByType.get(AnalysisRequirementFactory.REQUIREMENT_TYPE_3);
- assertEquals(3, values.size());
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_3));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_4));
- assertTrue(values.contains(AnalysisRequirementFactory.REQUIREMENT_VALUE_5));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementTest.java
deleted file mode 100644
index 502d270105..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisRequirementTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * 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:
- * Guilliano Molaire - Initial API and implementation
- * Mathieu Rail - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.analysis;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
-import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TmfAnalysisRequirement} class.
- *
- * @author Guilliano Molaire
- * @author Mathieu Rail
- */
-public class AnalysisRequirementTest {
-
- /* Requirements used in the tests */
- private TmfAnalysisRequirement fRequirement;
- private TmfAnalysisRequirement fSubRequirement;
-
- /* Types of requirement type strings */
- private static final String TYPE_A = "Test Type A";
- private static final String TYPE_B = "Test Type B";
-
- /* Requirement value name strings */
- private static final String VALUE_A = "Test Value A";
- private static final String VALUE_B = "Test Value B";
- private static final String VALUE_C = "Test Value C";
- private static final String VALUE_D = "Test Value D";
- private static final String VALUE_E = "Test Value E";
- private static final String VALUE_F = "Test Value F";
-
- /* Requirement information strings */
- private static final String INFO_A = "This is an information.";
- private static final String INFO_B = "This is another information.";
- private static final String INFO_C = "This is the last information.";
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#addInformation} and the
- * {@link TmfAnalysisRequirement#getInformation} methods.
- */
- @Test
- public void testAddAndGetInformation() {
- fRequirement = new TmfAnalysisRequirement(TYPE_A);
-
- fRequirement.addInformation(INFO_A);
- fRequirement.addInformation(INFO_B);
- fRequirement.addInformation(INFO_B);
-
- Set<String> information = fRequirement.getInformation();
-
- assertEquals(2, information.size());
-
- assertTrue(information.contains(INFO_A));
- assertTrue(information.contains(INFO_B));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#addValues} and the
- * {@link TmfAnalysisRequirement#addValue} methods.
- */
- @Test
- public void testAddValuesToRequirement() {
- fRequirement = new TmfAnalysisRequirement(TYPE_A);
-
- assertEquals(0, fRequirement.getValues().size());
-
- List<String> values = new ArrayList<>();
- values.add(VALUE_A);
- values.add(VALUE_B);
- values.add(VALUE_C);
- values.add(VALUE_C);
-
- /*
- * Add values to the requirement with the same level, Value C should
- * only exist once
- */
- fRequirement.addValues(values, ValuePriorityLevel.MANDATORY);
- assertEquals(3, fRequirement.getValues().size());
-
- /*
- * The new value should only exist once and its level should be
- * mandatory
- */
- fRequirement.addValue(VALUE_D, ValuePriorityLevel.OPTIONAL);
- fRequirement.addValue(VALUE_D, ValuePriorityLevel.MANDATORY);
-
- assertEquals(4, fRequirement.getValues().size());
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_D));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#getValueLevel} method.
- */
- @Test
- public void testGetValueLevel() {
- fRequirement = new TmfAnalysisRequirement(TYPE_A);
- fRequirement.addValue(VALUE_A, ValuePriorityLevel.OPTIONAL);
-
- /* Try to get the level of a value */
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_A));
-
- /* Try to get the level of a value that doesn't exist */
- assertNull(fRequirement.getValueLevel(VALUE_B));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#merge} method with the
- * parameter value MANDATORY.
- */
- @Test
- public void testMergeMandatory() {
- initMergeRequirements(TYPE_A, TYPE_A);
-
- assertTrue(fRequirement.merge(fSubRequirement, ValuePriorityLevel.MANDATORY));
-
- assertEquals(fRequirement.getValues().size(), 6);
-
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_A));
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_B));
-
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_C));
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_D));
-
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_E));
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_F));
-
- Set<String> information = fRequirement.getInformation();
-
- assertEquals(3, information.size());
-
- assertTrue(information.contains(INFO_A));
- assertTrue(information.contains(INFO_B));
- assertTrue(information.contains(INFO_C));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#merge} method with the
- * parameter value OPTIONAL.
- */
- @Test
- public void testMergeOptional() {
- initMergeRequirements(TYPE_A, TYPE_A);
-
- assertTrue(fRequirement.merge(fSubRequirement, ValuePriorityLevel.OPTIONAL));
-
- assertEquals(6, fRequirement.getValues().size());
-
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_A));
- assertEquals(ValuePriorityLevel.MANDATORY, fRequirement.getValueLevel(VALUE_B));
-
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_C));
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_D));
-
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_E));
- assertEquals(ValuePriorityLevel.OPTIONAL, fRequirement.getValueLevel(VALUE_F));
-
- Set<String> information = fRequirement.getInformation();
-
- assertEquals(3, information.size());
-
- assertTrue(information.contains(INFO_A));
- assertTrue(information.contains(INFO_B));
- assertTrue(information.contains(INFO_C));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#merge} method with
- * different requirement types.
- */
- @Test
- public void testMergeDifferentTypes() {
- initMergeRequirements(TYPE_A, TYPE_B);
-
- assertFalse(fRequirement.merge(fSubRequirement, ValuePriorityLevel.OPTIONAL));
- }
-
- /**
- * Test suite for the {@link TmfAnalysisRequirement#isSameType} method.
- */
- @Test
- public void testIsSameRequirementType() {
- fRequirement = new TmfAnalysisRequirement(TYPE_A);
-
- assertTrue(fRequirement.isSameType(new TmfAnalysisRequirement(TYPE_A)));
- assertFalse(fRequirement.isSameType(new TmfAnalysisRequirement(TYPE_B)));
- }
-
- /**
- * Initialize the requirement and sub-requirement for the merge tests.
- *
- * @param typeA
- * The type of the first requirement
- * @param typeB
- * The type of the second requirement
- */
- private void initMergeRequirements(String typeA, String typeB) {
- fRequirement = new TmfAnalysisRequirement(typeA);
- fRequirement.addValue(VALUE_A, ValuePriorityLevel.MANDATORY);
- fRequirement.addValue(VALUE_B, ValuePriorityLevel.MANDATORY);
-
- fRequirement.addValue(VALUE_C, ValuePriorityLevel.OPTIONAL);
- fRequirement.addValue(VALUE_D, ValuePriorityLevel.OPTIONAL);
-
- fRequirement.addInformation(INFO_A);
- fRequirement.addInformation(INFO_B);
-
- /* This sub-requirement will be merged into requirement */
- fSubRequirement = new TmfAnalysisRequirement(typeB);
- fSubRequirement.addValue(VALUE_A, ValuePriorityLevel.MANDATORY);
- fSubRequirement.addValue(VALUE_B, ValuePriorityLevel.OPTIONAL);
-
- fSubRequirement.addValue(VALUE_C, ValuePriorityLevel.MANDATORY);
- fSubRequirement.addValue(VALUE_D, ValuePriorityLevel.OPTIONAL);
-
- fSubRequirement.addValue(VALUE_E, ValuePriorityLevel.MANDATORY);
- fSubRequirement.addValue(VALUE_F, ValuePriorityLevel.OPTIONAL);
-
- fSubRequirement.addInformation(INFO_B);
- fSubRequirement.addInformation(INFO_C);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/AllTests.java
deleted file mode 100644
index d8b309f66b..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.component;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Unit tests for the component package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfEventProviderTest.class,
- TmfProviderManagerTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfEventProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfEventProviderTest.java
deleted file mode 100644
index 703888dfb4..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfEventProviderTest.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.component;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.Vector;
-
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.tests.stubs.component.TmfEventProviderStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.component.TmfSyntheticEventProviderStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.event.TmfSyntheticEventStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventProvider class.
- */
-public class TmfEventProviderTest {
-
- private TmfEventProviderStub fEventProvider;
- private TmfSyntheticEventProviderStub fSyntheticEventProvider;
-
- /**
- * Initialization
- *
- * @throws IOException
- * If we can't find the test trace (they are committed in the
- * tree, so it shouldn't happen).
- */
- @Before
- public void setUp() throws IOException {
- fEventProvider = new TmfEventProviderStub();
- fSyntheticEventProvider = new TmfSyntheticEventProviderStub();
- }
-
- /**
- * Clean-up
- */
- @After
- public void tearDown() {
- fEventProvider.dispose();
- fSyntheticEventProvider.dispose();
- }
-
- // ------------------------------------------------------------------------
- // getProviders (more a sanity check than a test)
- // ------------------------------------------------------------------------
-
- /**
- * Test getProviders
- */
- @Test
- public void testGetProviders() {
- // There should be 2 TmfEvent providers: a TmfTraceStub and a
- // TmfEventProviderStub
- ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 2, eventProviders.length);
-
- eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
-
- eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfEventProviderStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
-
- // There should be 1 TmfSyntheticEventStub provider
- eventProviders = TmfProviderManager.getProviders(TmfSyntheticEventStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
- }
-
- // ------------------------------------------------------------------------
- // getSyntheticEvent
- // ------------------------------------------------------------------------
-
- /**
- * Test getPlainEvents
- */
- @Test
- public void testGetPlainEvents() {
- final int NB_EVENTS = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- // Get the TmfSyntheticEventStub provider
- ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
- TmfEventProviderStub.class);
- ITmfEventProvider provider = eventProviders[0];
-
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
-
- provider.sendRequest(request);
- try {
- request.waitForCompletion();
- assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Make that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
- }
- } catch (InterruptedException e) {
- fail();
- }
- }
-
- /**
- * Test canceling requests.
- */
- @Test
- public void testCancelRequests() {
- final int NB_EVENTS = 1000;
- final int NUMBER_EVENTS_BEFORE_CANCEL_REQ1 = 10;
- final int NUMBER_EVENTS_BEFORE_CANCEL_REQ2 = 800;
-
- final Vector<ITmfEvent> requestedEventsReq1 = new Vector<>();
- final Vector<ITmfEvent> requestedEventsReq2 = new Vector<>();
-
- // Get the TmfSyntheticEventStub provider
- ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
- TmfEventProviderStub.class);
- ITmfEventProvider provider = eventProviders[0];
-
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-
- // Create first request
- final TmfEventRequest request1 = new TmfEventRequest(ITmfEvent.class,
- range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- requestedEventsReq1.add(event);
-
- // cancel sub request
- if (getNbRead() == NUMBER_EVENTS_BEFORE_CANCEL_REQ1) {
- cancel();
- }
- }
- };
-
- // Synchronize requests
- ((TmfEventProviderStub) provider).startSynch(new TmfStartSynchSignal(0));
-
- // Additionally, notify provider for up-coming requests
- provider.notifyPendingRequest(true);
-
- // Call sendRequest, which will create a coalescing request, but it
- // doesn't send request1 yet
- provider.sendRequest(request1);
-
- // Check if request1 is not running yet.
- assertFalse("isRunning", request1.isRunning());
-
- // Create second request
- final TmfEventRequest request2 = new TmfEventRequest(ITmfEvent.class,
- range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- requestedEventsReq2.add(event);
-
- // cancel sub request which will cancel also main request
- if (getNbRead() == NUMBER_EVENTS_BEFORE_CANCEL_REQ2) {
- cancel();
- }
- }
- };
-
- // Call sendRequest, which will create a coalescing request, but it
- // doesn't send request2 yet
- provider.sendRequest(request2);
-
- // Check if request1/2 is not running yet.
- assertFalse("isRunning", request1.isRunning());
- assertFalse("isRunning", request2.isRunning());
-
- // Send end synch signal, however requests won't be sent
- ((TmfEventProviderStub) provider).endSynch(new TmfEndSynchSignal(0));
-
- // Check if request1/2 is not running yet.
- assertFalse("isRunning", request1.isRunning());
- assertFalse("isRunning", request2.isRunning());
-
- // Finally, trigger sending of requests
- provider.notifyPendingRequest(false);
-
- try {
-
- // Wait until requests start
- request1.waitForStart();
- request2.waitForStart();
-
-// // Verify that the requests are running
-// assertTrue("isRunning", request1.isRunning());
-// assertTrue("isRunning", request2.isRunning());
-
- request1.waitForCompletion();
-
-// // Check if request2 is still running
-// assertTrue("isRunning", request2.isRunning());
-
- // Verify result (request1)
- assertEquals("nbEvents", NUMBER_EVENTS_BEFORE_CANCEL_REQ1, requestedEventsReq1.size());
- assertTrue("isCompleted", request1.isCompleted());
- assertTrue("isCancelled", request1.isCancelled());
-
- request2.waitForCompletion();
-
- // Verify result (request2)
- assertEquals("nbEvents", NUMBER_EVENTS_BEFORE_CANCEL_REQ2, requestedEventsReq2.size());
- assertTrue("isCompleted", request2.isCompleted());
- assertTrue("isCancelled", request2.isCancelled());
-
- } catch (InterruptedException e) {
- fail();
- }
- }
-
- private static void getSyntheticData(final TmfTimeRange range,
- final int nbEvents) throws InterruptedException {
-
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- // Get the event provider
- ITmfEventProvider[] eventProviders = TmfProviderManager
- .getProviders(TmfSyntheticEventStub.class);
- ITmfEventProvider provider = eventProviders[0];
-
- final TmfEventRequest request = new TmfEventRequest(TmfSyntheticEventStub.class, range,
- 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- provider.sendRequest(request);
-
- request.waitForCompletion();
- if (nbEvents != -1) {
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- }
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // For each base event, the stub will queue 2 identical synthetic events
- // Ensure that the events are queued properly.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < (nbEvents / 2); i++) {
- assertEquals("Distinct events", i + 1, requestedEvents.get(2 * i + 0).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1, requestedEvents.get(2 * i + 1).getTimestamp().getValue());
- }
- }
-
- /**
- * Test getSyntheticEvents for equal block sizes.
- */
- @Test
- public void testGetSyntheticEvents_EqualBlockSizes() {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- try {
- getSyntheticData(range, 1000);
- } catch (InterruptedException e) {
- fail();
- }
- }
-
- /**
- * Test getSyntheticEvents
- */
- @Test
- public void testGetSyntheticEvents_TimeRange() {
- TmfTimestamp start = new TmfTimestamp(1, (byte) -3, 0);
- TmfTimestamp end = new TmfTimestamp(1000, (byte) -3, 0);
- TmfTimeRange range = new TmfTimeRange(start, end);
- try {
- getSyntheticData(range, -1);
- } catch (InterruptedException e) {
- fail();
- }
- }
-
-// public void testGetSyntheticEvents_WeirdTimeRange1() {
-// TmfTimestamp start = TmfTimestamp.BigBang;
-// TmfTimestamp end = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) -3,
-// // 0);
-// TmfTimeRange range = new TmfTimeRange(start, end);
-// try {
-// getSyntheticData(range, -1, TmfSyntheticEventProviderStub.BLOCK_SIZE);
-// } catch (InterruptedException e) {
-// fail();
-// }
-// }
-
-// public void testGetSyntheticEvents_WeirdTimeRange2() {
-// TmfTimestamp start = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte)
-// // -3, 0);
-// TmfTimestamp end = TmfTimestamp.BigCrunch;
-// TmfTimeRange range = new TmfTimeRange(start, end);
-// try {
-// getSyntheticData(range, -1, TmfSyntheticEventProviderStub.BLOCK_SIZE);
-// } catch (InterruptedException e) {
-// fail();
-// }
-// }
-
- /**
- * Test getProviders (more a sanity check than a test)
- */
- @Test
- public void testGetProviders2() {
-
- // There should be 2 TmfEvent providers: a TmfTraceStub and a
- // TmfEventProviderStub
- ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 2, eventProviders.length);
-
- eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
-
- eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfEventProviderStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
-
- // There should be 1 TmfSyntheticEventStub provider
- eventProviders = TmfProviderManager.getProviders(TmfSyntheticEventStub.class);
- assertEquals("getProviders", 1, eventProviders.length);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfProviderManagerTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfProviderManagerTest.java
deleted file mode 100644
index b12ea0e1d3..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfProviderManagerTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.component;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfProviderManager class.
- */
-public class TmfProviderManagerTest {
-
- // ------------------------------------------------------------------------
- // Dummy Providers
- // ------------------------------------------------------------------------
-
- private class TestProvider1 extends TmfEventProvider {
- public TestProvider1(Class<ITmfEvent> type) {
- super("TestProvider1", type);
- }
-
- @Override
- public ITmfContext armRequest(ITmfEventRequest request) {
- return null;
- }
-
- @Override
- public ITmfEvent getNext(ITmfContext context) {
- return null;
- }
-
- @Override
- public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
- return false;
- }
- }
-
- private class TestProvider2 extends TmfEventProvider {
- public TestProvider2(Class<ITmfEvent> type) {
- super("TestProvider2", type);
- }
-
- @Override
- public ITmfContext armRequest(ITmfEventRequest request) {
- return null;
- }
-
- @Override
- public ITmfEvent getNext(ITmfContext context) {
- return null;
- }
-
- @Override
- public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
- return false;
- }
- }
-
- private class TmfEvent3 extends TmfEvent {
- }
-
- private class TestProvider3 extends TmfEventProvider {
- public TestProvider3(Class<TmfEvent3> type) {
- super("TestProvider3", type);
- }
-
- @Override
- public ITmfContext armRequest(ITmfEventRequest request) {
- return null;
- }
-
- @Override
- public TmfEvent3 getNext(ITmfContext context) {
- return null;
- }
-
- @Override
- public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
- return false;
- }
- }
-
- // ------------------------------------------------------------------------
- // register/dispose
- // ------------------------------------------------------------------------
-
- /**
- * Test registering
- */
- @Test
- public void testRegister_0() {
- TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
- }
-
- /**
- * Test unregistering
- */
- @Test
- public void testRegister_Unregister_1() {
-
- // Register a single provider
- TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
-
- TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider1, providers[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider1, providers[0]);
-
- // Unregister it
- testProvider1.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
- }
-
- /**
- * Test unregistering
- */
- @Test
- public void testRegister_Unregister_2() {
-
- // Register 2 providers, same data type
- TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
- TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
-
- TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 2, providers.length);
- assertTrue(providers.length == 2);
- if (providers[0] == testProvider1) {
- assertEquals("getProviders", testProvider2, providers[1]);
- }
- else {
- assertEquals("getProviders", testProvider2, providers[0]);
- assertEquals("getProviders", testProvider1, providers[1]);
- }
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider1, providers[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- // Remove one
- testProvider1.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- // Remove the other
- testProvider2.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 0, providers.length);
- }
-
- /**
- * Test unregistering
- */
- @Test
- public void testRegister_Unregister_3() {
-
- // Register 3 providers, mixed data types
- TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
- TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
- TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);
-
- TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 2, providers.length);
- if (providers[0] == testProvider1) {
- assertEquals("getProviders", testProvider2, providers[1]);
- }
- else {
- assertEquals("getProviders", testProvider2, providers[0]);
- assertEquals("getProviders", testProvider1, providers[1]);
- }
-
- TmfEventProvider[] providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
- assertEquals("getProviders", 1, providers3.length);
- assertEquals("getProviders", testProvider3, providers3[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider1, providers[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
- assertEquals("getProviders", 1, providers3.length);
- assertEquals("getProviders", testProvider3, providers3[0]);
-
- // Remove one
- testProvider1.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider2, providers[0]);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
- assertEquals("getProviders", 1, providers3.length);
- assertEquals("getProviders", testProvider3, providers3[0]);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
- assertEquals("getProviders", 1, providers3.length);
- assertEquals("getProviders", testProvider3, providers3[0]);
-
- // Remove another one
- testProvider2.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
- assertTrue(providers3.length == 1);
- assertTrue(providers3[0] == testProvider3);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
- assertEquals("getProviders", 1, providers3.length);
- assertEquals("getProviders", testProvider3, providers3[0]);
-
- // Remove the last one
- testProvider3.dispose();
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
- assertEquals("getProviders", 0, providers.length);
-
- providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
- assertEquals("getProviders", 0, providers.length);
- }
-
- /**
- * Test getProviders method
- */
- @Test
- public void testGetProvider() {
-
- // Register 3 providers, mixed data types
- TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
- TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
- TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);
-
- TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, null);
- assertEquals("getProviders", 2, providers.length);
- if (providers[0] == testProvider1) {
- assertEquals("getProviders", testProvider2, providers[1]);
- }
- else {
- assertEquals("getProviders", testProvider2, providers[0]);
- assertEquals("getProviders", testProvider1, providers[1]);
- }
-
- providers = TmfProviderManager.getProviders(TmfEvent3.class, null);
- assertEquals("getProviders", 1, providers.length);
- assertEquals("getProviders", testProvider3, providers[0]);
-
- // Remove the providers
- testProvider1.dispose();
- testProvider2.dispose();
- testProvider3.dispose();
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
deleted file mode 100644
index bf91caf493..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Added TmfNanoTimestampTest
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.event
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfEventFieldTest.class,
- TmfEventTest.class,
- TmfEventTypeManagerTest.class,
- TmfEventTypeTest.class,
- TmfNanoTimestampTest.class,
- TmfSimpleTimestampTest.class,
- TmfTimePreferencesTest.class,
- TmfTimeRangeTest.class,
- TmfTimestampDeltaTest.class,
- TmfTimestampTest.class,
- TmfTimestampFormatTest.class,
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java
deleted file mode 100644
index e69f31e3c1..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Collection;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventField class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventFieldTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final String fFieldName1 = "Field-1";
- private final String fFieldName2 = "Field-2";
-
- private final Object fValue1 = "Value";
- private final Object fValue2 = Integer.valueOf(10);
-
- private final TmfEventField fField1 = new TmfEventField(fFieldName1, fValue1, null);
- private final TmfEventField fField2 = new TmfEventField(fFieldName2, fValue2, null);
- private final TmfEventField fField3 = new TmfEventField(fFieldName1, fValue2, null);
-
- private final String fStructRootFieldName = "Root-S";
- private final String[] fStructFieldNames = new String[] { fFieldName1, fFieldName2 };
- private final TmfEventField fStructTerminalField1 = new TmfEventField(fFieldName1, null, null);
- private final TmfEventField fStructTerminalField2 = new TmfEventField(fFieldName2, null, null);
- private final TmfEventField fStructTerminalField3 = new TmfEventField(fFieldName1, null, null);
- private final TmfEventField fStructRootField = new TmfEventField(fStructRootFieldName, null,
- new ITmfEventField[] { fStructTerminalField1, fStructTerminalField2 });
-
- private final String fRootFieldName = "Root";
- private final String[] fFieldNames = new String[] { fFieldName1, fFieldName2 };
- private final TmfEventField fRootField = new TmfEventField(fRootFieldName, null,
- new ITmfEventField[] { fField1, fField2 });
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTerminalStructConstructor() {
- assertSame("getName", fFieldName1, fStructTerminalField1.getName());
- assertNull("getValue", fStructTerminalField1.getValue());
- assertEquals("getFields", 0, fStructTerminalField1.getFields().size());
- assertNull("getField(name)", fStructTerminalField1.getField(fFieldName1));
- assertEquals("getFieldNames", 0, fStructTerminalField1.getFieldNames().size());
- }
-
- @Test
- public void testNonTerminalStructConstructor() {
- assertSame("getName", fStructRootFieldName, fStructRootField.getName());
- assertNull("getValue", fStructRootField.getValue());
- assertEquals("getFields", 2, fStructRootField.getFields().size());
- assertSame("getField(name)", fStructTerminalField1, fStructRootField.getField(fFieldName1));
- assertSame("getField(name)", fStructTerminalField2, fStructRootField.getField(fFieldName2));
-
- final Collection<String> names = fStructRootField.getFieldNames();
- assertEquals("getFieldNames length", 2, names.size());
- assertArrayEquals(fStructFieldNames, names.toArray(new String[names.size()]));
- }
-
- @Test
- public void testTerminalConstructor() {
- assertSame("getName", fFieldName1, fField1.getName());
- assertSame("getValue", fValue1, fField1.getValue());
- assertEquals("getFields", 0, fField1.getFields().size());
- assertNull("getField(name)", fField1.getField(fFieldName1));
- assertEquals("getFieldNames", 0, fField1.getFieldNames().size());
-
- assertSame("getName", fFieldName2, fField2.getName());
- assertSame("getValue", fValue2, fField2.getValue());
- assertEquals("getFields", 0, fField2.getFields().size());
- assertNull("getField(name)", fField2.getField(fFieldName2));
- }
-
- @Test
- public void testNonTerminalConstructor() {
- assertSame("getName", fRootFieldName, fRootField.getName());
- assertNull("getValue", fRootField.getValue());
- assertEquals("getFields", 2, fRootField.getFields().size());
- assertSame("getField(name)", fField1, fRootField.getField(fFieldName1));
- assertSame("getField(name)", fField2, fRootField.getField(fFieldName2));
-
- final Collection<String> names = fRootField.getFieldNames();
- assertEquals("getFieldNames length", 2, names.size());
- assertArrayEquals(fFieldNames, names.toArray(new String[names.size()]));
- }
-
- @Test
- public void testConstructorBadArg() {
- try {
- new TmfEventField(null, fValue1, null);
- fail("Invalid (null) field name");
- } catch (final IllegalArgumentException e) {
- }
- }
-
- @Test
- public void testTerminalCopyConstructor() {
- final TmfEventField copy = new TmfEventField(fField1);
- assertSame("getName", fFieldName1, copy.getName());
- assertSame("getValue", fValue1, copy.getValue());
- assertEquals("getFields", 0, copy.getFields().size());
- assertNull("getField(name)", copy.getField(fFieldName1));
- assertEquals("getFieldNames", 0, copy.getFieldNames().size());
- }
-
- @Test
- public void testNonTerminalCopyConstructor() {
- assertSame("getName", fRootFieldName, fRootField.getName());
- assertNull("getValue", fRootField.getValue());
- assertEquals("getFields", 2, fRootField.getFields().size());
- assertSame("getField(name)", fField1, fRootField.getField(fFieldName1));
- assertSame("getField(name)", fField2, fRootField.getField(fFieldName2));
-
- final Collection<String> names = fRootField.getFieldNames();
- assertEquals("getFieldNames length", 2, names.size());
- assertArrayEquals(fFieldNames, names.toArray(new String[names.size()]));
- }
-
- @Test
- public void testCopyConstructorBadArg() {
- try {
- new TmfEventField(null);
- fail("TmfEventField: null arguemnt");
- } catch (final IllegalArgumentException e) {
- }
- }
-
- /**
- * Test that we correctly fail to create a field with subfields having the
- * same name.
- */
- @Test
- public void testDuplicateFieldNames() {
- ITmfEventField[] fields = {
- new TmfEventField("samename", null, null),
- new TmfEventField("samename", null, null)
- };
-
- try {
- new TmfEventField("field", null, fields);
- fail("TmfEventField: Duplicate field names");
- } catch (IllegalArgumentException e) {
- /* Expected exception */
- }
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- TmfEventField copy = new TmfEventField(fField1);
- assertTrue("hashCode", fField1.hashCode() == copy.hashCode());
- assertTrue("hashCode", fField1.hashCode() != fField2.hashCode());
-
- copy = new TmfEventField(fStructTerminalField1);
- assertTrue("hashCode", fStructTerminalField1.hashCode() == copy.hashCode());
- assertTrue("hashCode", fStructTerminalField1.hashCode() != fStructTerminalField2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fField1.equals(fField1));
- assertTrue("equals", fField2.equals(fField2));
-
- assertFalse("equals", fField1.equals(fField2));
- assertFalse("equals", fField2.equals(fField1));
-
- assertTrue("equals", fStructTerminalField1.equals(fStructTerminalField1));
- assertTrue("equals", fStructTerminalField2.equals(fStructTerminalField2));
-
- assertFalse("equals", fStructTerminalField1.equals(fStructTerminalField2));
- assertFalse("equals", fStructTerminalField2.equals(fStructTerminalField1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfEventField copy0 = new TmfEventField(fField1);
- assertTrue("equals", fField1.equals(copy0));
- assertTrue("equals", copy0.equals(fField1));
-
- final TmfEventField copy3 = new TmfEventField(fField2);
- assertTrue("equals", fField2.equals(copy3));
- assertTrue("equals", copy3.equals(fField2));
- }
-
- @Test
- public void testEqualsTransivity() {
- TmfEventField copy1 = new TmfEventField(fField1);
- TmfEventField copy2 = new TmfEventField(copy1);
- assertTrue("equals", fField1.equals(copy1));
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", fField1.equals(copy2));
-
- copy1 = new TmfEventField(fField2);
- copy2 = new TmfEventField(copy1);
- assertTrue("equals", fField2.equals(copy1));
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", fField2.equals(copy2));
- }
-
- @Test
- public void testEquals() {
- assertTrue("equals", fStructTerminalField1.equals(fStructTerminalField3));
- assertTrue("equals", fStructTerminalField3.equals(fStructTerminalField1));
-
- assertFalse("equals", fStructTerminalField1.equals(fField3));
- assertFalse("equals", fField3.equals(fStructTerminalField1));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fField1.equals(null));
- assertFalse("equals", fField2.equals(null));
- }
-
- @Test
- public void testNonEqualClasses() {
- assertFalse("equals", fField1.equals(fStructTerminalField1));
- assertFalse("equals", fField1.equals(fValue1));
- }
-
- @Test
- public void testNonEqualValues() {
- final TmfEventField copy1 = new TmfEventField(fFieldName1, fValue1, null);
- TmfEventField copy2 = new TmfEventField(fFieldName1, fValue1, null);
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", copy2.equals(copy1));
-
- copy2 = new TmfEventField(fFieldName1, fValue2, null);
- assertFalse("equals", copy1.equals(copy2));
- assertFalse("equals", copy2.equals(copy1));
-
- copy2 = new TmfEventField(fFieldName1, null, null);
- assertFalse("equals", copy1.equals(copy2));
- assertFalse("equals", copy2.equals(copy1));
- }
-
- @Test
- public void testNonEquals() {
- assertFalse("equals", fField1.equals(fField2));
- assertFalse("equals", fField2.equals(fField1));
-
- assertFalse("equals", fField1.equals(fStructTerminalField1));
- }
-
- /**
- * Test with same fields, but different values (should not be equal)
- */
- @Test
- public void testNonEqualsValue() {
- final String fieldName = "myfield";
- final Object value1 = new String("test-string");
- final Object value2 = new TmfEvent();
- final TmfEventField[] fields = { fField1, fField2 };
-
- final TmfEventField field1 = new TmfEventField(fieldName, value1, fields);
- final TmfEventField field2 = new TmfEventField(fieldName, value2, fields);
-
- assertNotEquals(field1, field2);
- assertNotEquals(field2, field1);
- }
-
- /**
- * Test with same value, but different fields (should not be equal)
- */
- @Test
- public void testNonEqualsFields() {
- final String fieldName = "myfield";
- final Object value = new String("test-string");
- final TmfEventField[] fields1 = { fField1, fField2 };
- final TmfEventField[] fields2 = { fField2, fField3 };
-
- final TmfEventField field1 = new TmfEventField(fieldName, value, fields1);
- final TmfEventField field2 = new TmfEventField(fieldName, value, fields2);
-
- assertNotEquals(field1, field2);
- assertNotEquals(field2, field1);
- }
-
- /**
- * Test with same field and values (should be equals)
- */
- @Test
- public void testEqualsEverything() {
- final String fieldName = "myfield";
- final Object value = new String("test-string");
- final TmfEventField[] fields = { fField1, fField2 };
-
- final TmfEventField field1 = new TmfEventField(fieldName, value, fields);
- final TmfEventField field2 = new TmfEventField(fieldName, value, fields);
-
- assertEquals(field1, field2);
- assertEquals(field2, field1);
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = fFieldName1 + "=" + fValue1.toString();
- TmfEventField field = new TmfEventField(fFieldName1, fValue1, null);
- assertEquals("toString", expected1, field.toString());
-
- final String expected2 = fFieldName1 + "=" + fValue2.toString();
- field = new TmfEventField(fFieldName1, fValue2, null);
- assertEquals("toString", expected2, field.toString());
- }
-
- // ------------------------------------------------------------------------
- // makeRoot
- // ------------------------------------------------------------------------
-
- @Test
- public void testMakeRoot() {
- ITmfEventField root = TmfEventField.makeRoot(fStructFieldNames);
- Collection<String> names = root.getFieldNames();
- assertEquals("getFieldNames length", 2, names.size());
- assertArrayEquals(fStructFieldNames, names.toArray(new String[names.size()]));
-
- root = TmfEventField.makeRoot(fFieldNames);
- names = root.getFieldNames();
- assertEquals("getFieldNames length", 2, names.size());
- assertArrayEquals(fFieldNames, names.toArray(new String[names.size()]));
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java
deleted file mode 100644
index 40cefa1deb..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEvent class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final String fSource = "Source";
-
- private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
- private final String fTypeId = "TestType";
- private final String fLabel1 = "AString";
- private final String fLabel2 = "AnInteger";
- private final String[] fLabels = new String[] { fLabel1, fLabel2 };
- private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
-
- private final Object fValue1a = "Some string";
- private final Object fValue1b = Integer.valueOf(10);
- private final ITmfEventField fField1a = new TmfEventField(fLabel1, fValue1a, null);
- private final ITmfEventField fField1b = new TmfEventField(fLabel2, fValue1b, null);
- private final ITmfEventField[] fFields1 = new ITmfEventField[] { fField1a, fField1b };
- private final String fRawContent1 = fField1a.toString() + fField1b.toString();
- private final ITmfEventField fContent1 = new TmfEventField(fRawContent1, null, fFields1);
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, 2, 5);
- private final String fReference1 = "Some reference";
- private final ITmfEvent fEvent1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
-
- private final Object fValue2a = "Another string";
- private final Object fValue2b = Integer.valueOf(-4);
- private final ITmfEventField fField2a = new TmfEventField(fLabel1, fValue2a, null);
- private final ITmfEventField fField2b = new TmfEventField(fLabel2, fValue2b, null);
- private final ITmfEventField[] fFields2 = new ITmfEventField[] { fField2a, fField2b };
- private final String fRawContent2 = fField2a.toString() + fField2b.toString();
- private final ITmfEventField fContent2 = new TmfEventField(fRawContent2, null, fFields2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, 2, 5);
- private final String fReference2 = "Some other reference";
- private final ITmfEvent fEvent2 = new TmfEvent(null, 1, fTimestamp2, fSource, fType, fContent2, fReference2);
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private static TmfTraceStub openTrace() {
- TmfTraceStub trace = null;
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TmfTestTrace.A_TEST_10K.getFullPath()), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(test.toURI().getPath(), 500, false, null);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- return trace;
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- final ITmfEvent event = new TmfEvent();
- assertNull("getTrace", event.getTrace());
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
- assertNull("getTimestamp", event.getTimestamp());
- assertNull("getSource", event.getSource());
- assertNull("getType", event.getType());
- assertNull("getContent", event.getContent());
- assertNull("getReference", event.getReference());
- }
-
- @Test
- public void testFullConstructor() {
- assertNull("getTrace", fEvent1.getTrace());
- assertEquals("getRank", 0, fEvent1.getRank());
- assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp());
- assertEquals("getSource", fSource, fEvent1.getSource());
- assertEquals("getType", fType, fEvent1.getType());
- assertEquals("getContent", fContent1, fEvent1.getContent());
- assertEquals("getReference", fReference1, fEvent1.getReference());
-
- assertNull("getTrace", fEvent2.getTrace());
- assertEquals("getRank", 1, fEvent2.getRank());
- assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp());
- assertEquals("getSource", fSource, fEvent2.getSource());
- assertEquals("getType", fType, fEvent2.getType());
- assertEquals("getContent", fContent2, fEvent2.getContent());
- assertEquals("getReference", fReference2, fEvent2.getReference());
- }
-
- @Test
- public void testNoRankConstructor() {
- final ITmfEvent event = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertNull("getTrace", event.getTrace());
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
- assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
- assertEquals("getSource", fSource, event.getSource());
- assertEquals("getType", fType, event.getType());
- assertEquals("getContent", fContent1, event.getContent());
- assertEquals("getReference", fReference1, event.getReference());
- }
-
- @Test
- public void testConstructorWithTrace() {
- final ITmfTrace trace = openTrace();
- final ITmfEvent event = new TmfEvent(trace, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertNotNull("getTrace", event.getTrace());
- assertEquals("getRank", 0, event.getRank());
- assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
- assertEquals("getSource", fSource, event.getSource());
- assertEquals("getType", fType, event.getType());
- assertEquals("getContent", fContent1, event.getContent());
- assertEquals("getReference", fReference1, event.getReference());
- trace.dispose();
- }
-
- @Test
- public void testTmfEventCopy() {
- final ITmfEvent event = new TmfEvent(fEvent1);
- assertNull("getTrace", event.getTrace());
- assertEquals("getRank", 0, event.getRank());
- assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
- assertEquals("getSource", fSource, event.getSource());
- assertEquals("getType", fType, event.getType());
- assertEquals("getContent", fContent1, event.getContent());
- assertEquals("getReference", fReference1, event.getReference());
- }
-
- @Test
- public void testEventCopy2() {
- try {
- new TmfEvent(null);
- fail("null copy");
- } catch (final IllegalArgumentException e) {
- // Success
- }
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- ITmfEvent event1 = new TmfEvent();
- ITmfEvent event2 = new TmfEvent();
-
- assertTrue("hashCode", event1.hashCode() == event2.hashCode());
-
- final ITmfTrace trace = openTrace();
- event1 = new TmfEvent(trace, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- event2 = new TmfEvent(trace, 1, fTimestamp2, fSource, fType, fContent2, fReference2);
- final ITmfEvent event1b = new TmfEvent(event1);
- final ITmfEvent event2b = new TmfEvent(event2);
-
- assertTrue("hashCode", event1.hashCode() == event1b.hashCode());
- assertTrue("hashCode", event2.hashCode() == event2b.hashCode());
-
- assertTrue("hashCode", event1.hashCode() != event2.hashCode());
- assertTrue("hashCode", event2.hashCode() != event1.hashCode());
-
- trace.dispose();
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fEvent1.equals(fEvent1));
- assertTrue("equals", fEvent2.equals(fEvent2));
-
- assertFalse("equals", fEvent1.equals(fEvent2));
- assertFalse("equals", fEvent2.equals(fEvent1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfEvent event1 = new TmfEvent(fEvent1);
- final ITmfEvent event2 = new TmfEvent(fEvent2);
-
- assertTrue("equals", event1.equals(fEvent1));
- assertTrue("equals", fEvent1.equals(event1));
-
- assertTrue("equals", event2.equals(fEvent2));
- assertTrue("equals", fEvent2.equals(event2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfEvent event1 = new TmfEvent(fEvent1);
- final ITmfEvent event2 = new TmfEvent(fEvent1);
- final ITmfEvent event3 = new TmfEvent(fEvent1);
-
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event3));
- assertTrue("equals", event1.equals(event3));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fEvent1.equals(null));
- assertFalse("equals", fEvent2.equals(null));
- }
-
- @Test
- public void testNonEqualClasses() {
- assertFalse("equals", fEvent1.equals(fEvent1.getType()));
- assertFalse("equals", fEvent1.equals(null));
- }
-
- @Test
- public void testNonEqualTraces() {
- final ITmfTrace trace1 = openTrace();
- final ITmfTrace trace2 = openTrace();
-
- final ITmfEvent event1 = new TmfEvent(trace1, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(trace1, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(trace2, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- trace1.dispose();
- trace2.dispose();
- }
-
- @Test
- public void testNonEqualRanks() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 1, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- @Test
- public void testNonEqualTimestamps() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp2, fSource, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, null, fSource, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- @Test
- public void testNonEqualSources() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource + "x", fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, null, fType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- @Test
- public void testNonEqualTypes() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- final String typeId = "OtherTestType";
- final String[] labels = new String[] { fLabel2, fLabel1 };
- final TmfEventType newType = new TmfEventType(fContext, typeId, TmfEventField.makeRoot(labels));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, newType, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, null, fContent1, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- @Test
- public void testNonEqualContents() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent2, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, null, fReference1);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- @Test
- public void testNonEqualReferences() {
- final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1);
- assertTrue("equals", event1.equals(event2));
- assertTrue("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference2);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
-
- event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, null);
- assertFalse("equals", event1.equals(event2));
- assertFalse("equals", event2.equals(event1));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfEvent [fTimestamp=" + fTimestamp1 + ", fTrace=null, fRank=0, fSource=" + fSource
- + ", fType=" + fType + ", fContent=" + fContent1 + ", fReference=" + fReference1 + "]";
- assertEquals("toString", expected1, fEvent1.toString());
-
- final String expected2 = "TmfEvent [fTimestamp=" + fTimestamp2 + ", fTrace=null, fRank=1, fSource=" + fSource
- + ", fType=" + fType + ", fContent=" + fContent2 + ", fReference=" + fReference2 + "]";
- assertEquals("toString", expected2, fEvent2.toString());
- }
-
- /**
- * Test the .toString() with extended classes.
- * It should print the correct class name.
- */
- @Test
- public void testToStringExtended() {
- class ExtendedEvent extends TmfEvent {
- ExtendedEvent(ITmfEvent event) {
- super(event);
- }
- }
- ExtendedEvent event = new ExtendedEvent(fEvent1);
- String expected = "ExtendedEvent [fTimestamp=" + fTimestamp1
- + ", fTrace=null, fRank=0, fSource=" + fSource
- + ", fType=" + fType + ", fContent=" + fContent1
- + ", fReference=" + fReference1 + "]";
-
- assertEquals(expected, event.toString());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeManagerTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeManagerTest.java
deleted file mode 100644
index 13bdc3c38f..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeManagerTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Set;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventTypeManager class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventTypeManagerTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final TmfEventTypeManager fInstance = TmfEventTypeManager.getInstance();
-
- private final String fContext1 = "JUnit context 1";
- private final String fContext2 = "JUnit context 2";
-
- private final String fTypeId1 = "Some type";
- private final String fTypeId2 = "Some other type";
- private final String fTypeId3 = "Yet another type";
- private final String fTypeId4 = "A final type";
-
- private final String fLabel0 = "label1";
- private final String fLabel1 = "label2";
- private final String fLabel2 = "label3";
-
- private final String[] fLabels0 = new String[] { };
- private final String[] fLabels1 = new String[] { fLabel0, fLabel1 };
- private final String[] fLabels2 = new String[] { fLabel1, fLabel0, fLabel2 };
-
- private final TmfEventType fType0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
- private final TmfEventType fType1 = new TmfEventType(fContext1, fTypeId2, TmfEventField.makeRoot(fLabels1));
- private final TmfEventType fType2 = new TmfEventType(fContext2, fTypeId3, TmfEventField.makeRoot(fLabels2));
- private final TmfEventType fType3 = new TmfEventType(fContext2, fTypeId4, TmfEventField.makeRoot(fLabels1));
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- @Test
- public void testGetContexts() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
- fInstance.add(fContext1, fType1);
- fInstance.add(fContext2, fType2);
- fInstance.add(fContext2, fType3);
-
- final String[] contexts = fInstance.getContexts();
- Arrays.sort(contexts);
- assertEquals("getContexts", 2, contexts.length);
- assertEquals("getContexts", fContext1, contexts[0]);
- assertEquals("getContexts", fContext2, contexts[1]);
- }
-
- @Test
- public void testGetTypes() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
- fInstance.add(fContext1, fType1);
- fInstance.add(fContext2, fType2);
- fInstance.add(fContext2, fType3);
-
- Set<ITmfEventType> types = fInstance.getTypes(fContext1);
- assertEquals("getTypes", 2, types.size());
- assertTrue(types.contains(fType1));
- assertTrue(types.contains(fType0));
-
- types = fInstance.getTypes(fContext2);
- assertEquals("getTypes", 2, types.size());
- assertTrue(types.contains(fType2));
- assertTrue(types.contains(fType3));
- }
-
- @Test
- public void testGetType() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
- fInstance.add(fContext1, fType1);
- fInstance.add(fContext2, fType2);
- fInstance.add(fContext2, fType3);
-
- ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
- assertSame("getType", fType0, type);
- type = fInstance.getType(fContext1, fType1.getName());
- assertSame("getType", fType1, type);
- type = fInstance.getType(fContext1, fType2.getName());
- assertNull("getType", type);
- type = fInstance.getType(fContext1, fType3.getName());
- assertNull("getType", type);
-
- type = fInstance.getType(fContext2, fType2.getName());
- assertSame("getType", fType2, type);
- type = fInstance.getType(fContext2, fType3.getName());
- assertSame("getType", fType3, type);
- type = fInstance.getType(fContext2, fType0.getName());
- assertNull("getType", type);
- type = fInstance.getType(fContext2, fType1.getName());
- assertNull("getType", type);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Test
- public void testClear() {
- fInstance.clear();
- assertEquals("clear", 0, fInstance.getContexts().length);
- assertEquals("clear", 0, fInstance.getTypes(null).size());
- assertNull("clear", fInstance.getType(null, null));
- assertEquals("clear", "TmfEventTypeManager [fEventTypes={}]", fInstance.toString());
- }
-
- @Test
- public void testClearContext() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
- fInstance.add(fContext1, fType1);
- fInstance.add(fContext2, fType2);
- fInstance.add(fContext2, fType3);
-
- fInstance.clear(fContext1);
-
- final String[] contexts = fInstance.getContexts();
- assertEquals("clear context", 1, contexts.length);
- assertEquals("clear context", fContext2, contexts[0]);
-
- Set<ITmfEventType> types = fInstance.getTypes(fContext1);
- assertEquals("clear context", 0, types.size());
-
- ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
- assertNull("clear context", type);
- type = fInstance.getType(fContext1, fType1.getName());
- assertNull("clear context", type);
-
- types = fInstance.getTypes(fContext2);
- assertEquals("clear context", 2, types.size());
- assertTrue(types.contains(fType2));
- assertTrue(types.contains(fType3));
- }
-
- @Test
- public void testBasicAdd() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
-
- final String[] contexts = fInstance.getContexts();
- assertEquals("add", 1, contexts.length);
- assertEquals("add", fContext1, contexts[0]);
-
- final Set<ITmfEventType> types = fInstance.getTypes(contexts[0]);
- assertEquals("add", 1, types.size());
- assertTrue(types.contains(fType0));
-
- ITmfEventType type = fInstance.getType(contexts[0], fType0.getName());
- assertSame("add", fType0, type);
-
- type = fInstance.getType(contexts[0], fType1.getName());
- assertNotSame("add", fType0, type);
- }
-
- @Test
- public void testAdd() {
- fInstance.clear();
- fInstance.add(fContext1, fType0);
- fInstance.add(fContext1, fType1);
- fInstance.add(fContext2, fType2);
- fInstance.add(fContext2, fType3);
-
- final String[] contexts = fInstance.getContexts();
- Arrays.sort(contexts);
- assertEquals("add", 2, contexts.length);
- assertEquals("add", fContext1, contexts[0]);
- assertEquals("add", fContext2, contexts[1]);
-
- Set<ITmfEventType> types = fInstance.getTypes(fContext1);
- assertEquals("add", 2, types.size());
- assertTrue(types.contains(fType0));
- assertTrue(types.contains(fType1));
-
- types = fInstance.getTypes(fContext2);
- assertEquals("add", 2, types.size());
- assertTrue(types.contains(fType2));
- assertTrue(types.contains(fType3));
-
- ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
- assertSame("add", fType0, type);
- type = fInstance.getType(fContext1, fType1.getName());
- assertSame("add", fType1, type);
- type = fInstance.getType(fContext2, fType2.getName());
- assertSame("add", fType2, type);
- type = fInstance.getType(fContext2, fType3.getName());
- assertSame("add", fType3, type);
-
- type = fInstance.getType(fContext1, fType2.getName());
- assertNull("add", type);
- type = fInstance.getType(fContext2, fType0.getName());
- assertNull("add", type);
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- fInstance.clear();
- assertEquals("toString", "TmfEventTypeManager [fEventTypes={}]", fInstance.toString());
-
- fInstance.add(fContext1, fType0);
- assertEquals("toString", "TmfEventTypeManager [fEventTypes={" + fContext1 + "={" + fTypeId1 + "=" + fType0 + "}}]", fInstance.toString());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java
deleted file mode 100644
index 4dbbb8b1e9..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Collection;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventType class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventTypeTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final String fContext1 = "JUnit context 1";
- private final String fContext2 = "JUnit context 2";
-
- private final String fTypeId1 = "Some type";
- private final String fTypeId2 = "Some other type";
-
- private final String fLabel0 = "label1";
- private final String fLabel1 = "label2";
- private final String fLabel2 = "label3";
-
- private final String[] fLabels0 = new String[] { };
- private final String[] fLabels1 = new String[] { fLabel0, fLabel1 };
- private final String[] fLabels2 = new String[] { fLabel1, fLabel0, fLabel2 };
-
- private final ITmfEventType fType0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
- private final ITmfEventType fType1 = new TmfEventType(fContext1, fTypeId2, TmfEventField.makeRoot(fLabels1));
- private final ITmfEventType fType2 = new TmfEventType(fContext2, fTypeId1, TmfEventField.makeRoot(fLabels2));
- private final ITmfEventType fType3 = new TmfEventType(fContext2, fTypeId2, TmfEventField.makeRoot(fLabels1));
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- final ITmfEventType type = new TmfEventType();
- assertEquals("getContext", ITmfEventType.DEFAULT_CONTEXT_ID, type.getContext());
- assertEquals("getName", ITmfEventType.DEFAULT_TYPE_ID, type.getName());
- assertNull("getRootField", type.getRootField());
- assertEquals("getFieldNames", 0, type.getFieldNames().size());
- }
-
- @Test
- public void testFullConstructor() {
- final ITmfEventType type0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
- assertEquals("getContext", fContext1, type0.getContext());
- assertEquals("getName", fTypeId1, type0.getName());
- assertEquals("getRootField", TmfEventField.makeRoot(fLabels0), type0.getRootField());
- final Collection<String> labels0 = type0.getFieldNames();
- assertEquals("getFieldNames length", fLabels0.length, labels0.size());
- assertArrayEquals(fLabels0, labels0.toArray(new String[labels0.size()]));
-
- final ITmfEventType type1 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
- assertEquals("getContext", fContext1, type1.getContext());
- assertEquals("getName", fTypeId1, type1.getName());
- assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), type1.getRootField());
- final Collection<String> labels1 = type1.getFieldNames();
- assertEquals("getFieldNames length", fLabels1.length, labels1.size());
- assertArrayEquals(fLabels1, labels1.toArray(new String[labels1.size()]));
-
- final ITmfEventType type2 = new TmfEventType(fContext2, fTypeId2, TmfEventField.makeRoot(fLabels2));
- assertEquals("getContext", fContext2, type2.getContext());
- assertEquals("getName", fTypeId2, type2.getName());
- assertEquals("getRootField", TmfEventField.makeRoot(fLabels2), type2.getRootField());
- final Collection<String> labels2 = type2.getFieldNames();
- assertEquals("getFieldNames length", fLabels2.length, labels2.size());
- assertArrayEquals(fLabels2, labels2.toArray(new String[labels2.size()]));
- }
-
- @Test
- public void testConstructorCornerCases() {
- try {
- new TmfEventType(null, fTypeId1, null);
- fail("TmfEventType: null context");
- } catch (final IllegalArgumentException e) {
- }
-
- try {
- new TmfEventType(fContext1, null, null);
- fail("TmfEventType: null type");
- } catch (final IllegalArgumentException e) {
- }
- }
-
- @Test
- public void testCopyConstructor() {
- final TmfEventType original = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
- final TmfEventType copy = new TmfEventType(original);
-
- assertEquals("getContext", fContext1, copy.getContext());
- assertEquals("getName", fTypeId1, copy.getName());
- assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), copy.getRootField());
- final Collection<String> labels1 = copy.getFieldNames();
- assertEquals("getFieldNames length", fLabels1.length, labels1.size());
- assertArrayEquals(fLabels1, labels1.toArray(new String[labels1.size()]));
- }
-
- @Test
- public void testCopyConstructorCornerCases() {
- try {
- new TmfEventType(null);
- fail("TmfEventType: null argument");
- } catch (final IllegalArgumentException e) {
- }
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TmfEventType copy1 = new TmfEventType(fType0);
-
- assertTrue("hashCode", fType0.hashCode() == copy1.hashCode());
- assertTrue("hashCode", fType0.hashCode() != fType3.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fType0.equals(fType0));
- assertTrue("equals", fType3.equals(fType3));
-
- assertFalse("equals", fType0.equals(fType3));
- assertFalse("equals", fType3.equals(fType0));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfEventType copy0 = new TmfEventType(fType0);
- assertTrue("equals", fType0.equals(copy0));
- assertTrue("equals", copy0.equals(fType0));
-
- final TmfEventType copy1 = new TmfEventType(fType1);
- assertTrue("equals", fType1.equals(copy1));
- assertTrue("equals", copy1.equals(fType1));
-
- final TmfEventType copy2 = new TmfEventType(fType2);
- assertTrue("equals", fType2.equals(copy2));
- assertTrue("equals", copy2.equals(fType2));
- }
-
- @Test
- public void testEqualsTransivity() {
- TmfEventType copy1 = new TmfEventType(fType1);
- TmfEventType copy2 = new TmfEventType(copy1);
- assertTrue("equals", fType1.equals(copy1));
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", fType1.equals(copy2));
-
- copy1 = new TmfEventType(fType2);
- copy2 = new TmfEventType(copy1);
- assertTrue("equals", fType2.equals(copy1));
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", fType2.equals(copy2));
-
- copy1 = new TmfEventType(fType3);
- copy2 = new TmfEventType(copy1);
- assertTrue("equals", fType3.equals(copy1));
- assertTrue("equals", copy1.equals(copy2));
- assertTrue("equals", fType3.equals(copy2));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fType0.equals(null));
- assertFalse("equals", fType3.equals(null));
- }
-
- @Test
- public void testNonEquals() {
- assertFalse("equals", fType0.equals(fType1));
- assertFalse("equals", fType1.equals(fType2));
- assertFalse("equals", fType2.equals(fType3));
- assertFalse("equals", fType3.equals(fType0));
- }
-
- @Test
- public void testNonEqualsClasses() {
- assertFalse("equals", fType1.equals(fLabels1));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfEventType [fContext=" + ITmfEventType.DEFAULT_CONTEXT_ID +
- ", fTypeId=" + ITmfEventType.DEFAULT_TYPE_ID + "]";
- final TmfEventType type1 = new TmfEventType();
- assertEquals("toString", expected1, type1.toString());
-
- final String expected2 = "TmfEventType [fContext=" + fContext1 + ", fTypeId=" + fTypeId1 + "]";
- final TmfEventType type2 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
- assertEquals("toString", expected2, type2.toString());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfNanoTimestampTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfNanoTimestampTest.java
deleted file mode 100644
index 55f040a9be..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfNanoTimestampTest.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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
- * Patrick Tasse - Modified from TmfSimpleTimestamp to use nanosecond scale
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfNanoTimestampTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfNanoTimestampTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final ITmfTimestamp ts0 = new TmfNanoTimestamp();
- private final ITmfTimestamp ts1 = new TmfNanoTimestamp(12345);
- private final ITmfTimestamp ts2 = new TmfNanoTimestamp(-1234);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals("getValue", 0, ts0.getValue());
- assertEquals("getscale", -9, ts0.getScale());
- assertEquals("getPrecision", 0, ts0.getPrecision());
- }
-
- @Test
- public void testFullConstructor() {
- assertEquals("getValue", 12345, ts1.getValue());
- assertEquals("getscale", -9, ts1.getScale());
- assertEquals("getPrecision", 0, ts1.getPrecision());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp copy = new TmfNanoTimestamp(ts1);
-
- assertEquals("getValue", ts1.getValue(), copy.getValue());
- assertEquals("getscale", ts1.getScale(), copy.getScale());
- assertEquals("getPrecision", ts1.getPrecision(), copy.getPrecision());
-
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", -9, copy.getScale());
- assertEquals("getPrecision", 0, copy.getPrecision());
- }
-
- @Test
- public void testCopyBadTimestamp() {
- try {
- new TmfNanoTimestamp(null);
- fail("TmfNanoTimestamp: null argument");
- } catch (final NullPointerException e) {
- }
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", ts0.equals(ts0));
- assertTrue("equals", ts1.equals(ts1));
- assertTrue("equals", ts2.equals(ts2));
-
- assertTrue("equals", !ts0.equals(ts1));
- assertTrue("equals", !ts0.equals(ts2));
-
- assertTrue("equals", !ts1.equals(ts0));
- assertTrue("equals", !ts1.equals(ts2));
-
- assertTrue("equals", !ts2.equals(ts0));
- assertTrue("equals", !ts2.equals(ts1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfNanoTimestamp(ts0);
- assertTrue("equals", ts0.equals(ts0copy));
- assertTrue("equals", ts0copy.equals(ts0));
-
- final ITmfTimestamp ts1copy = new TmfNanoTimestamp(ts1);
- assertTrue("equals", ts1.equals(ts1copy));
- assertTrue("equals", ts1copy.equals(ts1));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfNanoTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfNanoTimestamp(ts0copy1);
- assertTrue("equals", ts0.equals(ts0copy1));
- assertTrue("equals", ts0copy1.equals(ts0copy2));
- assertTrue("equals", ts0.equals(ts0copy2));
-
- final ITmfTimestamp ts1copy1 = new TmfNanoTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfNanoTimestamp(ts1copy1);
- assertTrue("equals", ts1.equals(ts1copy1));
- assertTrue("equals", ts1copy1.equals(ts1copy2));
- assertTrue("equals", ts1.equals(ts1copy2));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !ts0.equals(null));
- assertTrue("equals", !ts1.equals(null));
- assertTrue("equals", !ts2.equals(null));
- }
-
- @Test
- public void testEqualsNonTimestamp() {
- assertFalse("equals", ts0.equals(ts0.toString()));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS");
- Date d0 = new Date(ts0.getValue() / 1000000);
- Date d1 = new Date(ts1.getValue() / 1000000);
- Date d2 = new Date(ts2.getValue() / 1000000 - 1);
- assertEquals("toString", df.format(d0) + " 000 000", ts0.toString());
- assertEquals("toString", df.format(d1) + " 012 345", ts1.toString());
- assertEquals("toString", df.format(d2) + " 998 766", ts2.toString());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
-
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
-
- assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // normalize
- // ------------------------------------------------------------------------
-
- @Test
- public void testNormalizeScale0() {
- ITmfTimestamp ts = ts0.normalize(0, 0);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, 0);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, 0);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, 0);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeScaleNot0() {
- ITmfTimestamp ts = ts0.normalize(0, 1);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, 1);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, 1);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, 1);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testBasicCompareTo() {
- final ITmfTimestamp tstamp1 = new TmfNanoTimestamp(900);
- final ITmfTimestamp tstamp2 = new TmfNanoTimestamp(1000);
- final ITmfTimestamp tstamp3 = new TmfNanoTimestamp(1100);
-
- assertTrue(tstamp1.compareTo(tstamp1) == 0);
-
- assertTrue("CompareTo", tstamp1.compareTo(tstamp2) < 0);
- assertTrue("CompareTo", tstamp1.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp2.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp2.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp3.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp3.compareTo(tstamp2) > 0);
- }
-
- @Test
- public void testCompareTo() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, 2, 0);
- final ITmfTimestamp ts1a = new TmfTimestamp(123450, -10);
- final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -10);
-
- assertTrue(ts1.compareTo(ts1) == 0);
-
- assertTrue("CompareTo", ts0.compareTo(ts0a) == 0);
- assertTrue("CompareTo", ts1.compareTo(ts1a) == 0);
- assertTrue("CompareTo", ts2.compareTo(ts2a) == 0);
- }
-
- // ------------------------------------------------------------------------
- // getDelta
- // ------------------------------------------------------------------------
-
- @Test
- public void testDelta() {
- // Delta for same scale and precision (delta > 0)
- TmfTimestamp tstamp0 = new TmfNanoTimestamp(10);
- TmfTimestamp tstamp1 = new TmfNanoTimestamp(5);
- TmfTimestamp expectd = new TmfNanoTimestamp(5);
-
- ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
-
- // Delta for same scale and precision (delta < 0)
- tstamp0 = new TmfTimestamp(5);
- tstamp1 = new TmfTimestamp(10);
- expectd = new TmfTimestamp(-5);
-
- delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
- }
-
- @Test
- public void testDelta2() {
- // Delta for different scale and same precision (delta > 0)
- final TmfTimestamp tstamp0 = new TmfNanoTimestamp(10);
- final TmfTimestamp tstamp1 = new TmfTimestamp(1, -8);
- final TmfTimestamp expectd = new TmfTimestamp(0, 0);
-
- final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java
deleted file mode 100644
index a2f5604254..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfSimpleTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfSimpleTimestampTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfSimpleTimestampTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final ITmfTimestamp ts0 = new TmfSimpleTimestamp();
- private final ITmfTimestamp ts1 = new TmfSimpleTimestamp(12345);
- private final ITmfTimestamp ts2 = new TmfSimpleTimestamp(-1234);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals("getValue", 0, ts0.getValue());
- assertEquals("getscale", 0, ts0.getScale());
- assertEquals("getPrecision", 0, ts0.getPrecision());
- }
-
- @Test
- public void testFullConstructor() {
- assertEquals("getValue", 12345, ts1.getValue());
- assertEquals("getscale", 0, ts1.getScale());
- assertEquals("getPrecision", 0, ts1.getPrecision());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp copy = new TmfSimpleTimestamp(ts1);
-
- assertEquals("getValue", ts1.getValue(), copy.getValue());
- assertEquals("getscale", ts1.getScale(), copy.getScale());
- assertEquals("getPrecision", ts1.getPrecision(), copy.getPrecision());
-
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", 0, copy.getScale());
- assertEquals("getPrecision", 0, copy.getPrecision());
- }
-
- @Test
- public void testCopyBadTimestamp() {
- try {
- new TmfSimpleTimestamp(null);
- fail("TmfSimpleTimestamp: null argument");
- } catch (final NullPointerException e) {
- }
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", ts0.equals(ts0));
- assertTrue("equals", ts1.equals(ts1));
- assertTrue("equals", ts2.equals(ts2));
-
- assertTrue("equals", !ts0.equals(ts1));
- assertTrue("equals", !ts0.equals(ts2));
-
- assertTrue("equals", !ts1.equals(ts0));
- assertTrue("equals", !ts1.equals(ts2));
-
- assertTrue("equals", !ts2.equals(ts0));
- assertTrue("equals", !ts2.equals(ts1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfSimpleTimestamp(ts0);
- assertTrue("equals", ts0.equals(ts0copy));
- assertTrue("equals", ts0copy.equals(ts0));
-
- final ITmfTimestamp ts1copy = new TmfSimpleTimestamp(ts1);
- assertTrue("equals", ts1.equals(ts1copy));
- assertTrue("equals", ts1copy.equals(ts1));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfSimpleTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfSimpleTimestamp(ts0copy1);
- assertTrue("equals", ts0.equals(ts0copy1));
- assertTrue("equals", ts0copy1.equals(ts0copy2));
- assertTrue("equals", ts0.equals(ts0copy2));
-
- final ITmfTimestamp ts1copy1 = new TmfSimpleTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfSimpleTimestamp(ts1copy1);
- assertTrue("equals", ts1.equals(ts1copy1));
- assertTrue("equals", ts1copy1.equals(ts1copy2));
- assertTrue("equals", ts1.equals(ts1copy2));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !ts0.equals(null));
- assertTrue("equals", !ts1.equals(null));
- assertTrue("equals", !ts2.equals(null));
- }
-
- @Test
- public void testEqualsNonTimestamp() {
- assertFalse("equals", ts0.equals(ts0.toString()));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS");
- Date d0 = new Date(ts0.getValue()*1000);
- Date d1 = new Date(ts1.getValue()*1000);
- Date d2 = new Date(ts2.getValue()*1000);
- assertEquals("toString", df.format(d0) + " 000 000", ts0.toString());
- assertEquals("toString", df.format(d1) + " 000 000", ts1.toString());
- assertEquals("toString", df.format(d2) + " 000 000", ts2.toString());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
-
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
-
- assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // normalize
- // ------------------------------------------------------------------------
-
- @Test
- public void testNormalizeScale0() {
- ITmfTimestamp ts = ts0.normalize(0, 0);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, 0);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, 0);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, 0);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeScaleNot0() {
- ITmfTimestamp ts = ts0.normalize(0, 1);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, 1);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, 1);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, 1);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testBasicCompareTo() {
- final ITmfTimestamp tstamp1 = new TmfSimpleTimestamp(900);
- final ITmfTimestamp tstamp2 = new TmfSimpleTimestamp(1000);
- final ITmfTimestamp tstamp3 = new TmfSimpleTimestamp(1100);
-
- assertTrue(tstamp1.compareTo(tstamp1) == 0);
-
- assertTrue("CompareTo", tstamp1.compareTo(tstamp2) < 0);
- assertTrue("CompareTo", tstamp1.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp2.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp2.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp3.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp3.compareTo(tstamp2) > 0);
- }
-
- @Test
- public void testCompareTo() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, 2, 0);
- final ITmfTimestamp ts1a = new TmfTimestamp(123450, -1);
- final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -1);
-
- assertTrue(ts1.compareTo(ts1) == 0);
-
- assertTrue("CompareTo", ts0.compareTo(ts0a) == 0);
- assertTrue("CompareTo", ts1.compareTo(ts1a) == 0);
- assertTrue("CompareTo", ts2.compareTo(ts2a) == 0);
- }
-
- // ------------------------------------------------------------------------
- // getDelta
- // ------------------------------------------------------------------------
-
- @Test
- public void testDelta() {
- // Delta for same scale and precision (delta > 0)
- TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10);
- TmfTimestamp tstamp1 = new TmfSimpleTimestamp(5);
- TmfTimestamp expectd = new TmfSimpleTimestamp(5);
-
- ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
-
- // Delta for same scale and precision (delta < 0)
- tstamp0 = new TmfTimestamp(5);
- tstamp1 = new TmfTimestamp(10);
- expectd = new TmfTimestamp(-5);
-
- delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
- }
-
- @Test
- public void testDelta2() {
- // Delta for different scale and same precision (delta > 0)
- final TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10);
- final TmfTimestamp tstamp1 = new TmfTimestamp(1, 1);
- final TmfTimestamp expectd = new TmfTimestamp(0, 0);
-
- final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd, false));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java
deleted file mode 100644
index 141bcf9951..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
-import org.junit.Test;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Test suite for the TmfTimePreferences class.
- */
-public class TmfTimePreferencesTest {
-
- private static final String TIME_PATTERN = "HH:mm:ss.SSS SSS SSS";
- private static final String INTERVAL_PATTERN = "TTT.SSS SSS SSS";
-
- /**
- * Test that the preferences get initialized to the default
- */
- @Test
- public void testInit() {
- assertEquals(DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID).get(ITmfTimePreferencesConstants.DATIME, null), ITmfTimePreferencesConstants.TIME_HOUR_FMT);
- }
-
- /**
- * Test that getInstance returns an instance
- */
- @Test
- public void testGetInstance() {
- assertNotNull(TmfTimePreferences.getInstance());
- }
-
- /**
- * Test that getTimePattern returns the appropriate time pattern (from the default)
- */
- @Test
- public void testGetTimePattern() {
- assertEquals(TIME_PATTERN, TmfTimePreferences.getInstance().getTimePattern());
- }
-
- /**
- * Test that getIntervalPattern returns the appropriate interval pattern (from the default)
- */
- @Test
- public void testGetIntervalPattern() {
- assertEquals(INTERVAL_PATTERN, TmfTimePreferences.getInstance().getIntervalPattern());
- }
-
- /**
- * Test that getTimeZone returns the appropriate time zone (from the default)
- */
- @Test
- public void testGetTimeZone() {
- assertEquals(TimeZone.getDefault(), TmfTimePreferences.getInstance().getTimeZone());
- }
-
- /**
- * Test that getPreferenceMap returns the appropriate map even after preferences get modified
- * and make sure it doesn't affect the defaults
- */
- @Test
- public void testGetPreferenceMap() {
- Map<String, String> defaultPreferenceMap = TmfTimePreferences.getInstance().getDefaultPreferenceMap();
- assertEquals(ITmfTimePreferencesConstants.TIME_HOUR_FMT, defaultPreferenceMap.get(ITmfTimePreferencesConstants.DATIME));
-
- // Modify the preferences
- String testValue = ITmfTimePreferencesConstants.TIME_HOUR_FMT + "foo";
- IEclipsePreferences node = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- node.put(ITmfTimePreferencesConstants.DATIME, testValue);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- }
- // Make sure the modification is in the map
- Map<String, String> preferenceMap = TmfTimePreferences.getInstance().getPreferenceMap();
- assertEquals(testValue, preferenceMap.get(ITmfTimePreferencesConstants.DATIME));
-
- // Make sure the default is still the same
- defaultPreferenceMap = TmfTimePreferences.getInstance().getDefaultPreferenceMap();
- assertEquals(ITmfTimePreferencesConstants.TIME_HOUR_FMT, defaultPreferenceMap.get(ITmfTimePreferencesConstants.DATIME));
- }
-
- /**
- * Test that computeTimePattern computes the appropriate time pattern from a preference map (from the default)
- */
- @Test
- public void testComputeTimePattern() {
- assertEquals(TIME_PATTERN, TmfTimePreferences.getInstance().computeTimePattern(TmfTimePreferences.getInstance().getPreferenceMap()));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java
deleted file mode 100644
index ba7a99db46..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfTimeRange class.
- */
-@SuppressWarnings("javadoc")
-public class TmfTimeRangeTest {
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testConstructor() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-
- assertEquals("startTime", ts1, range.getStartTime());
- assertEquals("endTime", ts2, range.getEndTime());
- }
-
- @Test
- public void testBadConstructor() {
- try {
- new TmfTimeRange(TmfTimestamp.BIG_BANG, null);
- fail("TmfTimeRange: bad end time");
- } catch (final IllegalArgumentException e) {
- // Success
- }
-
- try {
- new TmfTimeRange(null, TmfTimestamp.BIG_CRUNCH);
- fail("TmfTimeRange: bad start time");
- } catch (final IllegalArgumentException e) {
- // Success
- }
- }
-
- @Test
- public void testOpenRange1() {
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, ts2);
-
- assertEquals("startTime", TmfTimestamp.BIG_BANG, range.getStartTime());
- assertEquals("endTime", ts2, range.getEndTime());
- }
-
- @Test
- public void testOpenRange2() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
-
- assertEquals("startTime", ts1, range.getStartTime());
- assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
- }
-
- @Test
- public void testOpenRange3() {
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-
- assertEquals("startTime", TmfTimestamp.BIG_BANG, range.getStartTime());
- assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range0 = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range1 = new TmfTimeRange(range0);
-
- assertEquals("startTime", ts1, range1.getStartTime());
- assertEquals("endTime", ts2, range1.getEndTime());
-
- final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfTimeRange range3 = new TmfTimeRange(range2);
-
- assertEquals("startTime", TmfTimestamp.BIG_BANG, range3.getStartTime());
- assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range3.getEndTime());
- }
-
- @Test
- public void testCopyConstructor2() {
- try {
- new TmfTimeRange(null);
- fail("TmfTimeRange: null argument");
- } catch (final IllegalArgumentException e) {
- // Success
- }
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range1b = new TmfTimeRange(range1);
- final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfTimeRange range2b = new TmfTimeRange(range2);
-
- assertTrue("hashCode", range1.hashCode() == range1b.hashCode());
- assertTrue("hashCode", range2.hashCode() == range2b.hashCode());
-
- assertTrue("hashCode", range1.hashCode() != range2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-
- assertTrue("equals", range1.equals(range1));
- assertTrue("equals", range2.equals(range2));
-
- assertTrue("equals", !range1.equals(range2));
- assertTrue("equals", !range2.equals(range1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2);
-
- final TmfTimeRange range2a = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfTimeRange range2b = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-
- assertTrue("equals", range1a.equals(range1b));
- assertTrue("equals", range1b.equals(range1a));
-
- assertTrue("equals", range2a.equals(range2b));
- assertTrue("equals", range2b.equals(range2a));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range1c = new TmfTimeRange(ts1, ts2);
-
- assertTrue("equals", range1a.equals(range1b));
- assertTrue("equals", range1b.equals(range1c));
- assertTrue("equals", range1a.equals(range1c));
- }
-
- @Test
- public void testEqualsNull() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
-
- assertTrue("equals", !range1.equals(null));
- }
-
- @Test
- public void testEqualsBadType() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
-
- assertTrue("equals", !range1.equals(ts1));
- }
-
- @Test
- public void testEqualStartTime() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final ITmfTimestamp ts3 = new TmfTimestamp(12355);
-
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts3);
- final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3);
- final TmfTimeRange range3 = new TmfTimeRange(ts1, ts2);
-
- assertTrue("equals", !range1.equals(range2));
- assertTrue("equals", !range1.equals(range3));
- }
-
- @Test
- public void testEqualsEndTime() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final ITmfTimestamp ts3 = new TmfTimestamp(12355);
-
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range2 = new TmfTimeRange(ts1, ts3);
- final TmfTimeRange range3 = new TmfTimeRange(ts2, ts3);
-
- assertTrue("equals", !range1.equals(range2));
- assertTrue("equals", !range1.equals(range3));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-
- final String expected = "TmfTimeRange [fStartTime=" + ts1 + ", fEndTime=" + ts2 + "]";
- assertEquals("toString", expected, range.toString());
- }
-
- // ------------------------------------------------------------------------
- // contains
- // ------------------------------------------------------------------------
-
- @Test
- public void testContainsTimestamp() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-
- assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345)));
- assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350)));
- assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
-
- assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
- assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
- }
-
- @Test
- public void testContainsRange() {
- final ITmfTimestamp ts1 = new TmfTimestamp(10);
- final ITmfTimestamp ts2 = new TmfTimestamp(20);
- final ITmfTimestamp ts3 = new TmfTimestamp(30);
- final ITmfTimestamp ts4 = new TmfTimestamp(40);
- final ITmfTimestamp ts5 = new TmfTimestamp(50);
- final ITmfTimestamp ts6 = new TmfTimestamp(60);
- final ITmfTimestamp ts7 = new TmfTimestamp(70);
- final ITmfTimestamp ts8 = new TmfTimestamp(80);
-
- // Reference range
- final TmfTimeRange range0 = new TmfTimeRange(ts3, ts6);
-
- // Start time below range
- final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
- final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3);
- final TmfTimeRange range3 = new TmfTimeRange(ts2, ts4);
- final TmfTimeRange range4 = new TmfTimeRange(ts2, ts6);
- final TmfTimeRange range5 = new TmfTimeRange(ts2, ts7);
-
- assertFalse("contains", range0.contains(range1));
- assertFalse("contains", range0.contains(range2));
- assertFalse("contains", range0.contains(range3));
- assertFalse("contains", range0.contains(range4));
- assertFalse("contains", range0.contains(range5));
-
- // End time above range
- final TmfTimeRange range6 = new TmfTimeRange(ts3, ts7);
- final TmfTimeRange range7 = new TmfTimeRange(ts4, ts7);
- final TmfTimeRange range8 = new TmfTimeRange(ts6, ts7);
- final TmfTimeRange range9 = new TmfTimeRange(ts7, ts8);
-
- assertFalse("contains", range0.contains(range6));
- assertFalse("contains", range0.contains(range7));
- assertFalse("contains", range0.contains(range8));
- assertFalse("contains", range0.contains(range9));
-
- // Within range
- final TmfTimeRange range10 = new TmfTimeRange(ts3, ts4);
- final TmfTimeRange range11 = new TmfTimeRange(ts3, ts6);
- final TmfTimeRange range12 = new TmfTimeRange(ts4, ts5);
- final TmfTimeRange range13 = new TmfTimeRange(ts4, ts6);
-
- assertTrue("contains", range0.contains(range10));
- assertTrue("contains", range0.contains(range11));
- assertTrue("contains", range0.contains(range12));
- assertTrue("contains", range0.contains(range13));
- }
-
- // ------------------------------------------------------------------------
- // getIntersection
- // ------------------------------------------------------------------------
-
- @Test
- public void testGetIntersection() {
-
- final ITmfTimestamp ts1a = new TmfTimestamp(1000);
- final ITmfTimestamp ts1b = new TmfTimestamp(2000);
- final TmfTimeRange range1 = new TmfTimeRange(ts1a, ts1b);
-
- final ITmfTimestamp ts2a = new TmfTimestamp(2000);
- final ITmfTimestamp ts2b = new TmfTimestamp(3000);
- final TmfTimeRange range2 = new TmfTimeRange(ts2a, ts2b);
-
- final ITmfTimestamp ts3a = new TmfTimestamp(3000);
- final ITmfTimestamp ts3b = new TmfTimestamp(4000);
- final TmfTimeRange range3 = new TmfTimeRange(ts3a, ts3b);
-
- final ITmfTimestamp ts4a = new TmfTimestamp(1500);
- final ITmfTimestamp ts4b = new TmfTimestamp(2500);
- final TmfTimeRange range4 = new TmfTimeRange(ts4a, ts4b);
-
- final ITmfTimestamp ts5a = new TmfTimestamp(1500);
- final ITmfTimestamp ts5b = new TmfTimestamp(2000);
- final TmfTimeRange range5 = new TmfTimeRange(ts5a, ts5b);
-
- final ITmfTimestamp ts6a = new TmfTimestamp(2000);
- final ITmfTimestamp ts6b = new TmfTimestamp(2500);
- final TmfTimeRange range6 = new TmfTimeRange(ts6a, ts6b);
-
- final ITmfTimestamp ts7a = new TmfTimestamp(1500);
- final ITmfTimestamp ts7b = new TmfTimestamp(3500);
- final TmfTimeRange range7 = new TmfTimeRange(ts7a, ts7b);
-
- final ITmfTimestamp ts8a = new TmfTimestamp(2250);
- final ITmfTimestamp ts8b = new TmfTimestamp(2750);
- final TmfTimeRange range8 = new TmfTimeRange(ts8a, ts8b);
-
- assertEquals("getIntersection (below - not contiguous)", null, range1.getIntersection(range3));
- assertEquals("getIntersection (above - not contiguous)", null, range3.getIntersection(range1));
-
- assertEquals("getIntersection (below - contiguous)", new TmfTimeRange(ts1b, ts1b), range1.getIntersection(range2));
- assertEquals("getIntersection (above - contiguous)", new TmfTimeRange(ts3a, ts3a), range3.getIntersection(range2));
-
- assertEquals("getIntersection (below - overlap)", new TmfTimeRange(ts2a, ts4b), range2.getIntersection(range4));
- assertEquals("getIntersection (above - overlap)", new TmfTimeRange(ts2a, ts4b), range4.getIntersection(range2));
-
- assertEquals("getIntersection (within - overlap1)", range6, range2.getIntersection(range6));
- assertEquals("getIntersection (within - overlap2)", range6, range6.getIntersection(range2));
-
- assertEquals("getIntersection (within - overlap3)", range5, range1.getIntersection(range5));
- assertEquals("getIntersection (within - overlap4)", range5, range5.getIntersection(range1));
-
- assertEquals("getIntersection (within - overlap5)", range8, range2.getIntersection(range8));
- assertEquals("getIntersection (within - overlap6)", range8, range8.getIntersection(range2));
-
- assertEquals("getIntersection (accross1)", range2, range2.getIntersection(range7));
- assertEquals("getIntersection (accross2)", range2, range7.getIntersection(range2));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampDeltaTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampDeltaTest.java
deleted file mode 100644
index 1cc98df698..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampDeltaTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampDelta;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfTimestampDelta class.
- */
-@SuppressWarnings("javadoc")
-public class TmfTimestampDeltaTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final ITmfTimestamp ts0 = new TmfTimestampDelta();
- private final ITmfTimestamp ts1 = new TmfTimestampDelta(12345, 0);
- private final ITmfTimestamp ts2 = new TmfTimestampDelta(12345, -1);
- private final ITmfTimestamp ts3 = new TmfTimestampDelta(12345, 2, 5);
- private final ITmfTimestamp ts4 = new TmfTimestampDelta(-12345, -5);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals("getValue", 0, ts0.getValue());
- assertEquals("getscale", 0, ts0.getScale());
- assertEquals("getPrecision", 0, ts0.getPrecision());
- }
-
- @Test
- public void testValueConstructor() {
- assertEquals("getValue", 12345, ts1.getValue());
- assertEquals("getscale", 0, ts1.getScale());
- assertEquals("getPrecision", 0, ts1.getPrecision());
- }
-
- @Test
- public void testValueScaleConstructor() {
- assertEquals("getValue", 12345, ts2.getValue());
- assertEquals("getscale", -1, ts2.getScale());
- assertEquals("getPrecision", 0, ts2.getPrecision());
- }
-
- @Test
- public void testFullConstructor() {
- assertEquals("getValue", 12345, ts3.getValue());
- assertEquals("getscale", 2, ts3.getScale());
- assertEquals("getPrecision", 5, ts3.getPrecision());
-
- assertEquals("getValue", -12345, ts4.getValue());
- assertEquals("getscale", -5, ts4.getScale());
- assertEquals("getPrecision", 0, ts4.getPrecision());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp ts = new TmfTimestamp(12345, 2, 5);
- final ITmfTimestamp copy = new TmfTimestamp(ts);
-
- assertEquals("getValue", ts.getValue(), copy.getValue());
- assertEquals("getscale", ts.getScale(), copy.getScale());
- assertEquals("getPrecision", ts.getPrecision(), copy.getPrecision());
-
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", 2, copy.getScale());
- assertEquals("getPrecision", 5, copy.getPrecision());
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCopyNullConstructor() {
- new TmfTimestamp((TmfTimestamp) null);
- }
-
- // ------------------------------------------------------------------------
- // normalize
- // ------------------------------------------------------------------------
-
- @Test
- public void testNormalizeOffset() {
- ITmfTimestamp ts = ts0.normalize(12345, 0);
- assertTrue("instance", ts instanceof TmfTimestampDelta);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToStringDefault() {
- assertEquals("toString", "000.000 000 000", ts0.toString());
- assertEquals("toString", "12345.000 000 000", ts1.toString());
- assertEquals("toString", "1234.500 000 000", ts2.toString());
- assertEquals("toString", "1234500.000 000 000", ts3.toString());
- assertEquals("toString", "-000.123 450 000", ts4.toString());
- }
-
- @Test
- public void testToStringFormat() {
- TmfTimestampFormat format = new TmfTimestampFormat("HH:mm:ss.SSS CCC NNN");
- assertEquals("toString", "00:00:00.000 000 000", ts0.toString(format));
- assertEquals("toString", "03:25:45.000 000 000", ts1.toString(format));
- assertEquals("toString", "00:20:34.500 000 000", ts2.toString(format));
- assertEquals("toString", "06:55:00.000 000 000", ts3.toString(format));
- assertEquals("toString", "-00:00:00.123 450 000", ts4.toString(format));
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java
deleted file mode 100644
index 94b08c6561..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2015 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:
- * Marc-Andre Laperle - Initial API and implementation
- * Matthew Khouzam - Added timestamp string tests
- * Patrick Tasse - Updated for fraction of second
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-
-import java.text.ParseException;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
-import org.junit.Test;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Test suite for the TmfTimestampFormat class.
- */
-public class TmfTimestampFormatTest {
-
- private static final String TEST_PATTERN = "HH:mm:ss.SSS";
- private static final TimeZone TEST_TIME_ZONE = TimeZone.getTimeZone(TimeZone.getAvailableIDs(0)[0]);
- private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
- private static final Locale CA = Locale.CANADA;
-
- private static final TmfTimestampFormat tsf = new TmfTimestampFormat("yyyy-MM-dd HH:mm:ss.SSSSSSSSS", GMT, CA);
- private static final TmfTimestampFormat tsf1 = new TmfTimestampFormat(TEST_PATTERN);
- private static final TmfTimestampFormat tsf2 = new TmfTimestampFormat(TEST_PATTERN, TEST_TIME_ZONE);
-
- /**
- * Test that the default value is loaded when using the default constructor
- */
- @Test
- public void testDefaultConstructor() {
- TmfTimestampFormat ts0 = new TmfTimestampFormat();
- assertEquals("HH:mm:ss.SSS SSS SSS", ts0.toPattern());
- }
-
- /**
- * Test that the value constructor properly assigns the value
- */
- @Test
- public void testValueConstructor() {
- assertEquals(TEST_PATTERN, tsf1.toPattern());
- }
-
- /**
- * Test that the value constructor using a time zone properly assigns the
- * pattern and time zone
- */
- @Test
- public void testValueTimeZoneConstructor() {
- assertEquals(TEST_PATTERN, tsf2.toPattern());
- assertEquals(TEST_TIME_ZONE, tsf2.getTimeZone());
- }
-
- /**
- * Make sure that the default formats in TmfTimestampFormat get updated when
- * updateDefaultFormats is called.
- */
- @Test
- public void testUpdateDefaultFormats() {
- IEclipsePreferences node = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
-
- String dateTimeTestValue = ITmfTimePreferencesConstants.TIME_HOUR_FMT + ":";
- node.put(ITmfTimePreferencesConstants.DATIME, dateTimeTestValue);
-
- String subSecTestValue = ITmfTimePreferencesConstants.SUBSEC_NANO_FMT + ":";
- node.put(ITmfTimePreferencesConstants.SUBSEC, subSecTestValue);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- }
- TmfTimestampFormat.updateDefaultFormats();
- String expected = dateTimeTestValue + "." + subSecTestValue;
- String expected2 = "TTT." + subSecTestValue;
- assertEquals(expected, TmfTimestampFormat.getDefaulTimeFormat().toPattern());
- assertEquals(expected2, TmfTimestampFormat.getDefaulIntervalFormat().toPattern());
- // Revert preferences
- node.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
- node.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- }
- TmfTimestampFormat.updateDefaultFormats();
- }
-
- /**
- * Test that getDefaulTimeFormat returns the appropriate value (from the
- * default)
- */
- @Test
- public void testGetDefaulTimeFormat() {
- assertEquals(TmfTimestampFormat.getDefaulTimeFormat().toPattern(), TmfTimePreferences.getInstance().getTimePattern());
- }
-
- /**
- * Test that getDefaulIntervalFormat returns the appropriate value (from the
- * default)
- */
- @Test
- public void testGetDefaulIntervalFormat() {
- assertEquals(TmfTimestampFormat.getDefaulIntervalFormat().toPattern(), TmfTimePreferences.getInstance().getIntervalPattern());
- }
-
- /**
- * Test parsing of seconds and sub-seconds
- *
- * @throws ParseException
- * should not happen, if it does, the test is a failure
- */
- @Test
- public void testParseSeconds() throws ParseException {
- assertEquals(7777777777123456789L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7777777777.123456789"));
- assertEquals(7777777777123456789L, new TmfTimestampFormat("T.SSSSSSSSS").parseValue("7777777777.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("0000000007.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.123456789"));
- assertEquals(7123456780L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.12345678"));
- assertEquals(7123456700L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.1234567"));
- assertEquals(7123456000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.123456"));
- assertEquals(7123450000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.12345"));
- assertEquals(7123400000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.1234"));
- assertEquals(7123000000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.123"));
- assertEquals(7120000000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.12"));
- assertEquals(7100000000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7.1"));
- assertEquals(7000000000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7."));
- assertEquals(7000000000L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue("7"));
- assertEquals(123456789L, new TmfTimestampFormat("TTTTTTTTTT.SSSSSSSSS").parseValue(".123456789"));
- assertEquals(123456789L, new TmfTimestampFormat(".SSSSSSSSS").parseValue(".123456789"));
- assertEquals(123456780L, new TmfTimestampFormat(".SSSSSSSS").parseValue(".123456789"));
- assertEquals(123456700L, new TmfTimestampFormat(".SSSSSSS").parseValue(".123456789"));
- assertEquals(123456000L, new TmfTimestampFormat(".SSSSSS").parseValue(".123456789"));
- assertEquals(123450000L, new TmfTimestampFormat(".SSSSS").parseValue(".123456789"));
- assertEquals(123400000L, new TmfTimestampFormat(".SSSS").parseValue(".123456789"));
- assertEquals(123000000L, new TmfTimestampFormat(".SSS").parseValue(".123456789"));
- assertEquals(120000000L, new TmfTimestampFormat(".SS").parseValue(".123456789"));
- assertEquals(100000000L, new TmfTimestampFormat(".S").parseValue(".123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSSSSSSSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS SSS SSS").parseValue("7.123 456 789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS SSS SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS.SSS.SSS").parseValue("7.123.456.789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS.SSS.SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS,SSS,SSS").parseValue("7.123,456,789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS,SSS,SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS-SSS-SSS").parseValue("7.123-456-789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS-SSS-SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS_SSS_SSS").parseValue("7.123_456_789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS_SSS_SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS:SSS:SSS").parseValue("7.123:456:789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS:SSS:SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS;SSS;SSS").parseValue("7.123;456;789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS;SSS;SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS/SSS/SSS").parseValue("7.123/456/789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS/SSS/SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS''SSS''SSS").parseValue("7.123'456'789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS''SSS''SSS").parseValue("7.123456789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS\"SSS\"SSS").parseValue("7.123\"456\"789"));
- assertEquals(7123456789L, new TmfTimestampFormat("T.SSS\"SSS\"SSS").parseValue("7.123456789"));
- assertEquals(7000000000L, new TmfTimestampFormat("T. SSSSSSSSS").parseValue("7..123456789"));
- assertEquals(7100000000L, new TmfTimestampFormat("T.S SSSSSSSS").parseValue("7.1,23456789"));
- assertEquals(7120000000L, new TmfTimestampFormat("T.SS SSSSSSS").parseValue("7.12-3456789"));
- assertEquals(7123000000L, new TmfTimestampFormat("T.SSS SSSSSS").parseValue("7.123_456789"));
- assertEquals(7123400000L, new TmfTimestampFormat("T.SSSS SSSSS").parseValue("7.1234:56789"));
- assertEquals(7123450000L, new TmfTimestampFormat("T.SSSSS SSSS").parseValue("7.12345;6789"));
- assertEquals(7123456000L, new TmfTimestampFormat("T.SSSSSS SSS").parseValue("7.123456/789"));
- assertEquals(7123456700L, new TmfTimestampFormat("T.SSSSSSS SS").parseValue("7.1234567'89"));
- assertEquals(7123456780L, new TmfTimestampFormat("T.SSSSSSSS S").parseValue("7.12345678\"9"));
- assertEquals(7123456789L, new TmfTimestampFormat("T 's'.SSS ms SSS us SSS ns").parseValue("7 s.123 ms 456 us 789 ns"));
- assertEquals(7123456789L, new TmfTimestampFormat("T 'S'.SSS 'MS' SSS 'US' SSS 'NS'").parseValue("7 S.123 MS 456 US 789 NS"));
- assertEquals(7123000000L, new TmfTimestampFormat("T.SSSSSSSSS").parseValue("7 s.123 ms 456 ns 789"));
- assertEquals(0L, new TmfTimestampFormat("T.").parseValue("0.123456789"));
- assertEquals(0L, new TmfTimestampFormat("T.S").parseValue("."));
- assertEquals(0L, new TmfTimestampFormat(".S").parseValue("7."));
- assertEquals(0L, new TmfTimestampFormat("T.S").parseValue("-."));
- assertEquals(0L, new TmfTimestampFormat("T.S").parseValue("-0"));
- assertEquals(-100000000L, new TmfTimestampFormat("T.S").parseValue("-0.1"));
- assertEquals(-100000000L, new TmfTimestampFormat("T.S").parseValue("-.1"));
- assertEquals(-7000000000L, new TmfTimestampFormat("T.S").parseValue("-7"));
- assertEquals(-7000000000L, new TmfTimestampFormat("T.S").parseValue("-7."));
- assertEquals(-7000000000L, new TmfTimestampFormat("T.S").parseValue("-7.0"));
- assertEquals(-7100000000L, new TmfTimestampFormat("T.S").parseValue("-7.1"));
- }
-
- /**
- * Test parsing of date and time patterns
- *
- * @throws ParseException
- * should not happen, if it does, the test is a failure
- */
- @Test
- public void testParseDateTime() throws ParseException {
- long time;
-
- time = new TmfTimestampFormat("yyyy", GMT, CA).parseValue("2014");
- assertEquals("2014-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("YYYY", GMT, CA).parseValue("2014");
- assertEquals("2013-12-29 00:00:00.000000000", tsf.format(time)); // 1st day of week 1
-
- time = new TmfTimestampFormat("MM", GMT, CA).parseValue("11");
- assertEquals("1970-11-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("ww", GMT, CA).parseValue("01");
- assertEquals("1969-12-28 00:00:00.000000000", tsf.format(time)); // Sunday of week 1
-
- time = new TmfTimestampFormat("DDD", GMT, CA).parseValue("100");
- assertEquals("1970-04-10 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("F", GMT, CA).parseValue("2");
- assertEquals("1970-01-11 00:00:00.000000000", tsf.format(time)); // 2nd Sunday of month
-
- time = new TmfTimestampFormat("EEE", GMT, CA).parseValue("Mon");
- assertEquals("1970-01-05 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("u", GMT, CA).parseValue("1");
- assertEquals("1970-01-05 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("dd", GMT, CA).parseValue("22");
- assertEquals("1970-01-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("HH", GMT, CA).parseValue("12");
- assertEquals("1970-01-01 12:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("kk", GMT, CA).parseValue("24");
- assertEquals("1970-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("KK", GMT, CA).parseValue("12");
- assertEquals("1970-01-01 12:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("hh", GMT, CA).parseValue("12");
- assertEquals("1970-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("mm", GMT, CA).parseValue("34");
- assertEquals("1970-01-01 00:34:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("ss", GMT, CA).parseValue("56");
- assertEquals("1970-01-01 00:00:56.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM", GMT, CA).parseValue("2014-11");
- assertEquals("2014-11-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd", GMT, CA).parseValue("2014-11-22");
- assertEquals("2014-11-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd HH", GMT, CA).parseValue("2014-11-22 12");
- assertEquals("2014-11-22 12:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd HH:mm", GMT, CA).parseValue("2014-11-22 12:34");
- assertEquals("2014-11-22 12:34:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd HH:mm:ss", GMT, CA).parseValue("2014-11-22 12:34:56");
- assertEquals("2014-11-22 12:34:56.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd HH:mm:ss.SSS", GMT, CA).parseValue("2014-11-22 12:34:56.123");
- assertEquals("2014-11-22 12:34:56.123000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-ww", GMT, CA).parseValue("2014-01");
- assertEquals("2013-12-29 00:00:00.000000000", tsf.format(time)); // Sunday of week 1
-
- time = new TmfTimestampFormat("yyyy-DDD", GMT, CA).parseValue("2014-100");
- assertEquals("2014-04-10 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-F", GMT, CA).parseValue("2014-11-2");
- assertEquals("2014-11-09 00:00:00.000000000", tsf.format(time)); // 2nd Sunday of month
-
- time = new TmfTimestampFormat("yyyy-MM-EEE", GMT, CA).parseValue("2014-11-Mon");
- assertEquals("2014-11-03 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-u", GMT, CA).parseValue("2014-11-1");
- assertEquals("2014-11-03 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy MM dd HH mm ss SSS SSS SSS", GMT, CA).parseValue("2014 11 22 12 34 56 123 456 789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy.MM.dd.HH.mm.ss.SSS.SSS.SSS", GMT, CA).parseValue("2014.11.22.12.34.56.123.456.789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy,MM,dd,HH,mm,ss,SSS,SSS,SSS", GMT, CA).parseValue("2014,11,22,12,34,56,123,456,789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy-MM-dd-HH-mm-ss-SSS-SSS-SSS", GMT, CA).parseValue("2014-11-22-12-34-56-123-456-789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy_MM_dd_HH_mm_ss_SSS_SSS_SSS", GMT, CA).parseValue("2014_11_22_12_34_56_123_456_789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy:MM:dd:HH:mm:ss:SSS:SSS:SSS", GMT, CA).parseValue("2014:11:22:12:34:56:123:456:789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy;MM;dd;HH;mm;ss;SSS;SSS;SSS", GMT, CA).parseValue("2014;11;22;12;34;56;123;456;789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy/MM/dd/HH/mm/ss/SSS/SSS/SSS", GMT, CA).parseValue("2014/11/22/12/34/56/123/456/789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy''MM''dd''HH''mm''ss''SSS''SSS''SSS", GMT, CA).parseValue("2014'11'22'12'34'56'123'456'789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy\"MM\"dd\"HH\"mm\"ss\"SSS\"SSS\"SSS", GMT, CA).parseValue("2014\"11\"22\"12\"34\"56\"123\"456\"789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy MM dd HH mm ss SSS SSS SSS", GMT, CA).parseValue("2014 11 22 12 34 56 123 456 789");
- assertEquals("2014-11-22 12:34:56.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy MM dd HH mm ss SSS SSS SSS", GMT, CA).parseValue("2014 1 2 3 4 5 123 456 789");
- assertEquals("2014-01-02 03:04:05.123456789", tsf.format(time));
-
- time = new TmfTimestampFormat("yyyy MM dd HH mm ss SSS SSS SSS", GMT, CA).parseValue("2014 \t 1 \t 2 \t 3 \t 4 \t 5 \t 123 456 789");
- assertEquals("2014-01-02 03:04:05.123456789", tsf.format(time));
- }
-
- /**
- * Test parsing of date and time patterns with reference time
- *
- * @throws ParseException
- * should not happen, if it does, the test is a failure
- */
- @Test
- public void testParseDateTimeWithRef() throws ParseException {
- long ref = tsf.parseValue("2014-11-22 12:34:56.123456789"); // Saturday
- long time;
-
- time = new TmfTimestampFormat("yyyy", GMT, CA).parseValue("1970", ref);
- assertEquals("1970-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("YYYY", GMT, CA).parseValue("1970", ref);
- assertEquals("1969-12-28 00:00:00.000000000", tsf.format(time)); // 1st day of week 1
-
- time = new TmfTimestampFormat("MM", GMT, CA).parseValue("01", ref);
- assertEquals("2014-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("ww", GMT, CA).parseValue("01", ref);
- assertEquals("2014-01-04 00:00:00.000000000", tsf.format(time)); // Saturday of week 1
-
- time = new TmfTimestampFormat("DDD", GMT, CA).parseValue("1", ref);
- assertEquals("2014-01-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("F", GMT, CA).parseValue("2", ref);
- assertEquals("2014-11-08 00:00:00.000000000", tsf.format(time)); // 2nd Saturday of month
-
- time = new TmfTimestampFormat("EEE", GMT, CA).parseValue("Mon", ref);
- assertEquals("2014-11-17 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("u", GMT, CA).parseValue("1", ref);
- assertEquals("2014-11-17 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("dd", GMT, CA).parseValue("01", ref);
- assertEquals("2014-11-01 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("HH", GMT, CA).parseValue("00", ref);
- assertEquals("2014-11-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("kk", GMT, CA).parseValue("24", ref);
- assertEquals("2014-11-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("KK", GMT, CA).parseValue("00", ref);
- assertEquals("2014-11-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("hh", GMT, CA).parseValue("12", ref);
- assertEquals("2014-11-22 00:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("mm", GMT, CA).parseValue("00", ref);
- assertEquals("2014-11-22 12:00:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat("ss", GMT, CA).parseValue("00", ref);
- assertEquals("2014-11-22 12:34:00.000000000", tsf.format(time));
-
- time = new TmfTimestampFormat(".S", GMT, CA).parseValue(".9", ref);
- assertEquals("2014-11-22 12:34:56.900000000", tsf.format(time));
-
- time = new TmfTimestampFormat("T.S", GMT, CA).parseValue("8.9", ref);
- assertEquals("1970-01-01 00:00:08.900000000", tsf.format(time));
-
- time = new TmfTimestampFormat("T.S", GMT, CA).parseValue(".9", ref);
- assertEquals("1970-01-01 00:00:00.900000000", tsf.format(time));
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java
deleted file mode 100644
index 7bf07186b2..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 Event Model
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for negative value formatting
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfTimestamp class.
- */
-@SuppressWarnings("javadoc")
-public class TmfTimestampTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final ITmfTimestamp ts0 = new TmfTimestamp();
- private final ITmfTimestamp ts1 = new TmfTimestamp(12345, 0);
- private final ITmfTimestamp ts2 = new TmfTimestamp(12345, -1);
- private final ITmfTimestamp ts3 = new TmfTimestamp(12345, 2, 5);
- private final ITmfTimestamp ts4 = new TmfTimestamp(12345, -3, 0);
- private final ITmfTimestamp ts5 = new TmfTimestamp(12345, -6, 0);
- private final ITmfTimestamp ts6 = new TmfTimestamp(12345, -9, 0);
- private final ITmfTimestamp ts7 = new TmfTimestamp(-12345, -3, 0);
- private final ITmfTimestamp ts8 = new TmfTimestamp(-12345, -6, 0);
- private final ITmfTimestamp ts9 = new TmfTimestamp(-12345, -9, 0);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals("getValue", 0, ts0.getValue());
- assertEquals("getscale", 0, ts0.getScale());
- assertEquals("getPrecision", 0, ts0.getPrecision());
- }
-
- @Test
- public void testValueConstructor() {
- assertEquals("getValue", 12345, ts1.getValue());
- assertEquals("getscale", 0, ts1.getScale());
- assertEquals("getPrecision", 0, ts1.getPrecision());
- }
-
- @Test
- public void testValueScaleConstructor() {
- assertEquals("getValue", 12345, ts2.getValue());
- assertEquals("getscale", -1, ts2.getScale());
- assertEquals("getPrecision", 0, ts2.getPrecision());
- }
-
- @Test
- public void testFullConstructor() {
- assertEquals("getValue", 12345, ts3.getValue());
- assertEquals("getscale", 2, ts3.getScale());
- assertEquals("getPrecision", 5, ts3.getPrecision());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp ts = new TmfTimestamp(12345, 2, 5);
- final ITmfTimestamp copy = new TmfTimestamp(ts);
-
- assertEquals("getValue", ts.getValue(), copy.getValue());
- assertEquals("getscale", ts.getScale(), copy.getScale());
- assertEquals("getPrecision", ts.getPrecision(), copy.getPrecision());
-
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", 2, copy.getScale());
- assertEquals("getPrecision", 5, copy.getPrecision());
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCopyNullConstructor() {
- new TmfTimestamp((TmfTimestamp) null);
- }
-
- @Test
- public void testCopyConstructorBigBang() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_BANG);
- assertEquals("getValue", TmfTimestamp.BIG_BANG.getValue(), ts.getValue());
- assertEquals("getscale", TmfTimestamp.BIG_BANG.getScale(), ts.getScale());
- assertEquals("getPrecision", TmfTimestamp.BIG_BANG.getPrecision(), ts.getPrecision());
- }
-
- @Test
- public void testCopyConstructorBigCrunch() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_CRUNCH);
- assertEquals("getValue", TmfTimestamp.BIG_CRUNCH.getValue(), ts.getValue());
- assertEquals("getscale", TmfTimestamp.BIG_CRUNCH.getScale(), ts.getScale());
- assertEquals("getPrecision", TmfTimestamp.BIG_CRUNCH.getPrecision(), ts.getPrecision());
- }
-
- @Test
- public void testCopyConstructorZero() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.ZERO);
- assertEquals("getValue", TmfTimestamp.ZERO.getValue(), ts.getValue());
- assertEquals("getscale", TmfTimestamp.ZERO.getScale(), ts.getScale());
- assertEquals("getPrecision", TmfTimestamp.ZERO.getPrecision(), ts.getPrecision());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
-
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
-
- assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", ts0.equals(ts0));
- assertTrue("equals", ts1.equals(ts1));
-
- assertTrue("equals", !ts0.equals(ts1));
- assertTrue("equals", !ts1.equals(ts0));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- assertTrue("equals", ts0.equals(ts0copy));
- assertTrue("equals", ts0copy.equals(ts0));
-
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- assertTrue("equals", ts1.equals(ts1copy));
- assertTrue("equals", ts1copy.equals(ts1));
-
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
- assertTrue("equals", ts2.equals(ts2copy));
- assertTrue("equals", ts2copy.equals(ts2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfTimestamp(ts0copy1);
- assertTrue("equals", ts0.equals(ts0copy1));
- assertTrue("equals", ts0copy1.equals(ts0copy2));
- assertTrue("equals", ts0.equals(ts0copy2));
-
- final ITmfTimestamp ts1copy1 = new TmfTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfTimestamp(ts1copy1);
- assertTrue("equals", ts1.equals(ts1copy1));
- assertTrue("equals", ts1copy1.equals(ts1copy2));
- assertTrue("equals", ts1.equals(ts1copy2));
-
- final ITmfTimestamp ts2copy1 = new TmfTimestamp(ts2);
- final ITmfTimestamp ts2copy2 = new TmfTimestamp(ts2copy1);
- assertTrue("equals", ts2.equals(ts2copy1));
- assertTrue("equals", ts2copy1.equals(ts2copy2));
- assertTrue("equals", ts2.equals(ts2copy2));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !ts0.equals(null));
- assertTrue("equals", !ts1.equals(null));
- }
-
- @Test
- public void testEqualsNonTimestamp() {
- assertFalse("equals", ts0.equals(ts0.toString()));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToStringDefault() {
- DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS");
- Date d0 = new Date((long) (ts0.getValue() * Math.pow(10, ts0.getScale() + 3)));
- Date d1 = new Date((long) (ts1.getValue() * Math.pow(10, ts1.getScale() + 3)));
- Date d2 = new Date((long) (ts2.getValue() * Math.pow(10, ts2.getScale() + 3)));
- Date d3 = new Date((long) (ts3.getValue() * Math.pow(10, ts3.getScale() + 3)));
- Date d4 = new Date((long) (ts4.getValue() * Math.pow(10, ts4.getScale() + 3)));
- Date d5 = new Date((long) (ts5.getValue() * Math.pow(10, ts5.getScale() + 3)));
- Date d6 = new Date((long) (ts6.getValue() * Math.pow(10, ts6.getScale() + 3)));
- Date d7 = new Date((long) (ts7.getValue() * Math.pow(10, ts7.getScale() + 3)));
- Date d8 = new Date((long) (ts8.getValue() * Math.pow(10, ts8.getScale() + 3)) - 1);
- Date d9 = new Date((long) (ts9.getValue() * Math.pow(10, ts9.getScale() + 3)) - 1);
- assertEquals("toString", df.format(d0) + " 000 000", ts0.toString());
- assertEquals("toString", df.format(d1) + " 000 000", ts1.toString());
- assertEquals("toString", df.format(d2) + " 000 000", ts2.toString());
- assertEquals("toString", df.format(d3) + " 000 000", ts3.toString());
- assertEquals("toString", df.format(d4) + " 000 000", ts4.toString());
- assertEquals("toString", df.format(d5) + " 345 000", ts5.toString());
- assertEquals("toString", df.format(d6) + " 012 345", ts6.toString());
- assertEquals("toString", df.format(d7) + " 000 000", ts7.toString());
- assertEquals("toString", df.format(d8) + " 655 000", ts8.toString());
- assertEquals("toString", df.format(d9) + " 987 655", ts9.toString());
- }
-
- @Test
- public void testToStringInterval() {
- assertEquals("toString", "000.000 000 000", ts0.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "12345.000 000 000", ts1.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "1234.500 000 000", ts2.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "1234500.000 000 000", ts3.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "012.345 000 000", ts4.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "000.012 345 000", ts5.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "000.000 012 345", ts6.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "-012.345 000 000", ts7.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "-000.012 345 000", ts8.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- assertEquals("toString", "-000.000 012 345", ts9.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
- }
-
- // ------------------------------------------------------------------------
- // normalize
- // ------------------------------------------------------------------------
-
- @Test
- public void testNormalizeOffset() {
- ITmfTimestamp ts = ts0.normalize(0, 0);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, 0);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, 0);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, 0);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeOffsetLowerLimits() {
- final ITmfTimestamp ref = new TmfTimestamp(Long.MIN_VALUE + 5, 0);
-
- ITmfTimestamp ts = ref.normalize(-4, 0);
- assertEquals("getValue", Long.MIN_VALUE + 1, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ref.normalize(-5, 0);
- assertEquals("getValue", Long.MIN_VALUE, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ref.normalize(-6, 0);
- assertEquals("getValue", Long.MIN_VALUE, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeOffsetUpperLimits() {
- final ITmfTimestamp ref = new TmfTimestamp(Long.MAX_VALUE - 5, 0);
-
- ITmfTimestamp ts = ref.normalize(4, 0);
- assertEquals("getValue", Long.MAX_VALUE - 1, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ref.normalize(5, 0);
- assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ref.normalize(6, 0);
- assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeScale() {
- ITmfTimestamp ts = ts0.normalize(0, 10);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 10, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(0, -10);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", -10, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizedScaleLimits() {
- final int MAX_SCALE_DIFF = 19;
-
- // Test below limit
- try {
- ts1.normalize(0, +MAX_SCALE_DIFF - 1);
- ts1.normalize(0, -MAX_SCALE_DIFF + 1);
- } catch (final ArithmeticException e) {
- fail("normalize: scale error");
- }
-
- // Test at limit
- try {
- ts1.normalize(0, +MAX_SCALE_DIFF);
- fail("normalize: scale error");
- ts1.normalize(0, -MAX_SCALE_DIFF);
- fail("normalize: scale error");
- } catch (final ArithmeticException e) {
- }
-
- // Test over limit
- try {
- ts1.normalize(0, +MAX_SCALE_DIFF + 1);
- fail("normalize: scale error");
- ts1.normalize(0, -MAX_SCALE_DIFF - 1);
- fail("normalize: scale error");
- } catch (final ArithmeticException e) {
- }
- }
-
- @Test
- public void testNormalizeOffsetAndScaleTrivial() {
- final ITmfTimestamp ts = ts0.normalize(0, 0);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeOffsetAndScale() {
- final int SCALE = 12;
-
- ITmfTimestamp ts = ts0.normalize(0, SCALE);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(12345, SCALE);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(10, SCALE);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.normalize(-10, SCALE);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testNormalizeOffsetAndScale2() {
- int SCALE = 2;
- ITmfTimestamp ts = ts1.normalize(0, SCALE);
- assertEquals("getValue", 123, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts1.normalize(12345, SCALE);
- assertEquals("getValue", 12468, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- SCALE = -2;
- ts = ts1.normalize(0, SCALE);
- assertEquals("getValue", 1234500, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts1.normalize(67, SCALE);
- assertEquals("getValue", 1234567, ts.getValue());
- assertEquals("getscale", SCALE, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testBasicCompareTo() {
- final ITmfTimestamp t1 = new TmfTimestamp(900, 0, 50);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0, 50);
- final ITmfTimestamp t3 = new TmfTimestamp(1100, 0, 50);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, 0, 75);
-
- assertTrue(t1.compareTo(t1) == 0);
-
- assertTrue("CompareTo", t1.compareTo(t2) < 0);
- assertTrue("CompareTo", t1.compareTo(t3) < 0);
- assertTrue("CompareTo", t1.compareTo(t4) < 0);
-
- assertTrue("CompareTo", t2.compareTo(t1) > 0);
- assertTrue("CompareTo", t2.compareTo(t3) < 0);
- assertTrue("CompareTo", t2.compareTo(t4) == 0);
-
- assertTrue("CompareTo", t3.compareTo(t1) > 0);
- assertTrue("CompareTo", t3.compareTo(t2) > 0);
- assertTrue("CompareTo", t3.compareTo(t4) > 0);
- }
-
- @Test
- public void testCompareToCornerCases1() {
- final ITmfTimestamp ts0a = new TmfTimestamp(ts0);
- final ITmfTimestamp ts0b = new TmfTimestamp(ts0.getValue(), ts0.getScale() + 1);
- final ITmfTimestamp ts0c = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale());
- final ITmfTimestamp ts0d = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale() + 1);
-
- assertTrue("compareTo", ts0.compareTo(ts0, false) == 0);
- assertTrue("compareTo", ts0.compareTo(ts0a, false) == 0);
- assertTrue("compareTo", ts0.compareTo(ts0b, false) == 0);
- assertTrue("compareTo", ts0.compareTo(ts0c, false) == -1);
- assertTrue("compareTo", ts0.compareTo(ts0d, false) == -1);
- }
-
- @Test
- public void testCompareToCornerCases2() {
- final ITmfTimestamp ts0a = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE - 1);
- final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0c = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE);
-
- assertTrue("compareTo", ts0a.compareTo(ts0b, false) == 1);
- assertTrue("compareTo", ts0a.compareTo(ts0c, false) == -1);
-
- assertTrue("compareTo", ts0b.compareTo(ts0a, false) == -1);
- assertTrue("compareTo", ts0b.compareTo(ts0c, false) == -1);
-
- assertTrue("compareTo", ts0c.compareTo(ts0a, false) == 1);
- assertTrue("compareTo", ts0c.compareTo(ts0b, false) == 1);
- }
-
- @Test
- public void testCompareToCornerCases3() {
- final ITmfTimestamp ts0a = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE - 1);
- final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0c = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE);
-
- assertTrue("compareTo", ts0a.compareTo(ts0b, false) == -1);
- assertTrue("compareTo", ts0a.compareTo(ts0c, false) == 1);
-
- assertTrue("compareTo", ts0b.compareTo(ts0a, false) == 1);
- assertTrue("compareTo", ts0b.compareTo(ts0c, false) == 1);
-
- assertTrue("compareTo", ts0c.compareTo(ts0a, false) == -1);
- assertTrue("compareTo", ts0c.compareTo(ts0b, false) == -1);
- }
-
- @Test
- public void testCompareToCornerCases4() {
- assertTrue("compareTo", ts0.compareTo(null, false) == 1);
- assertTrue("compareTo", ts0.compareTo(null, true) == 1);
- }
-
- @Test
- public void testCompareToSameScale() {
- final ITmfTimestamp t1 = new TmfTimestamp(900, 0, 50);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0, 50);
- final ITmfTimestamp t3 = new TmfTimestamp(1100, 0, 50);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, 0, 75);
-
- assertTrue(t1.compareTo(t1, false) == 0);
-
- assertTrue("CompareTo", t1.compareTo(t2, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t4, false) < 0);
-
- assertTrue("CompareTo", t2.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t2.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t2.compareTo(t4, false) == 0);
-
- assertTrue("CompareTo", t3.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t2, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t4, false) > 0);
- }
-
- @Test
- public void testCompareToDifferentScale() {
- final ITmfTimestamp t1 = new TmfTimestamp(9000, -1, 50);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0, 50);
- final ITmfTimestamp t3 = new TmfTimestamp(110, 1, 50);
- final ITmfTimestamp t4 = new TmfTimestamp(1, 3, 75);
-
- assertTrue("CompareTo", t1.compareTo(t1, false) == 0);
-
- assertTrue("CompareTo", t1.compareTo(t2, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t4, false) < 0);
-
- assertTrue("CompareTo", t2.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t2.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t2.compareTo(t4, false) == 0);
-
- assertTrue("CompareTo", t3.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t2, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t4, false) > 0);
- }
-
- @Test
- public void testCompareToWithinPrecision() {
- final ITmfTimestamp t1 = new TmfTimestamp(900, 0, 50);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0, 50);
- final ITmfTimestamp t3 = new TmfTimestamp(1100, 0, 50);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, 0, 75);
-
- assertTrue("CompareTo", t1.compareTo(t1, true) == 0);
-
- assertTrue("CompareTo", t1.compareTo(t2, true) == 0);
- assertTrue("CompareTo", t1.compareTo(t3, true) < 0);
- assertTrue("CompareTo", t1.compareTo(t4, true) == 0);
-
- assertTrue("CompareTo", t2.compareTo(t1, true) == 0);
- assertTrue("CompareTo", t2.compareTo(t3, true) == 0);
- assertTrue("CompareTo", t2.compareTo(t4, true) == 0);
-
- assertTrue("CompareTo", t3.compareTo(t1, true) > 0);
- assertTrue("CompareTo", t3.compareTo(t2, true) == 0);
- assertTrue("CompareTo", t3.compareTo(t4, true) == 0);
- }
-
- @Test
- public void testCompareToLargeScale1() {
- final ITmfTimestamp t1 = new TmfTimestamp(-1, 100);
- final ITmfTimestamp t2 = new TmfTimestamp(-1000, -100);
- final ITmfTimestamp t3 = new TmfTimestamp(1, 100);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, -100);
-
- assertTrue("CompareTo", t1.compareTo(t2, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t1.compareTo(t4, false) < 0);
-
- assertTrue("CompareTo", t2.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t2.compareTo(t3, false) < 0);
- assertTrue("CompareTo", t2.compareTo(t4, false) < 0);
-
- assertTrue("CompareTo", t3.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t2, false) > 0);
- assertTrue("CompareTo", t3.compareTo(t4, false) > 0);
-
- assertTrue("CompareTo", t4.compareTo(t1, false) > 0);
- assertTrue("CompareTo", t4.compareTo(t2, false) > 0);
- assertTrue("CompareTo", t4.compareTo(t3, false) < 0);
- }
-
- @Test
- public void testCompareToLargeScale2() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0b = new TmfTimestamp(1, Integer.MAX_VALUE);
-
- assertTrue("CompareTo", ts0a.compareTo(ts0, false) == 0);
- assertTrue("CompareTo", ts0.compareTo(ts0a, false) == 0);
-
- assertTrue("CompareTo", ts0b.compareTo(ts0, false) == 1);
- assertTrue("CompareTo", ts0.compareTo(ts0b, false) == -1);
- }
-
- // ------------------------------------------------------------------------
- // getDelta
- // ------------------------------------------------------------------------
-
- @Test
- public void testDelta() {
- // Delta for same scale and precision (delta > 0)
- ITmfTimestamp t0 = new TmfTimestamp(10, 9);
- ITmfTimestamp t1 = new TmfTimestamp(5, 9);
- ITmfTimestamp exp = new TmfTimestamp(5, 9);
-
- ITmfTimestamp delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, false));
-
- // Delta for same scale and precision (delta < 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 9);
- exp = new TmfTimestamp(-5, 9);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, false));
-
- // Delta for different scale and same precision (delta > 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 8);
- exp = new TmfTimestamp(4, 9);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, false));
-
- // Delta for different scale and same precision (delta > 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 7);
- exp = new TmfTimestamp(5, 9);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, false));
-
- // Delta for different scale and same precision
- t0 = new TmfTimestamp(10, 9);
- t1 = new TmfTimestamp(5, 8);
- exp = new TmfTimestamp(10, 9);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, false));
-
- // Delta for same scale and different precision
- t0 = new TmfTimestamp(10, 9, 1);
- t1 = new TmfTimestamp(5, 9, 2);
- exp = new TmfTimestamp(5, 9, 3);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, true));
- assertEquals("precision", 3, delta.getPrecision());
-
- // Delta for same scale and different precision
- t0 = new TmfTimestamp(5, 9, 2);
- t1 = new TmfTimestamp(10, 9, 1);
- exp = new TmfTimestamp(-5, 9, 3);
-
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, true));
- assertEquals("precision", 3, delta.getPrecision());
-
- // Delta for different scale and different precision
- t0 = new TmfTimestamp(5, 9, 2);
- t1 = new TmfTimestamp(10, 8, 1);
- exp = new TmfTimestamp(4, 9, 3);
- delta = t0.getDelta(t1);
- assertEquals("getDelta", 0, delta.compareTo(exp, true));
- assertEquals("precision", 2, delta.getPrecision());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java
deleted file mode 100644
index 2db2ab1c80..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event.lookup;
-
-import org.eclipse.linuxtools.tmf.core.tests.event.lookup.TmfCallsiteTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.event.lookup
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfCallsiteTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java
deleted file mode 100644
index 2839784745..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.event.lookup;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfCallsite;
-import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCallsite class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCallsiteTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
- private final static String fFileName1 = "filename1";
- private final static String fFunctionName1 = "func1";
- private final static long fLine1 = 10;
-
- private final static String fFileName2 = "filename2";
- private final static String fFunctionName2 = "func2";
- private final static long fLine2 = 25;
-
- private final static String fFileName3 = "filename3";
- private final static String fFunctionName3 = null;
- private final static long fLine3 = 123;
-
- private final static ITmfCallsite fCallsite1 = new TmfCallsite(fFileName1, fFunctionName1, fLine1);
- private final static ITmfCallsite fCallsite2 = new TmfCallsite(fFileName2, fFunctionName2, fLine2);
- private final static ITmfCallsite fCallsite3 = new TmfCallsite(fFileName3, fFunctionName3, fLine3);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals(fFileName1, fCallsite1.getFileName());
- assertEquals(fFunctionName1, fCallsite1.getFunctionName());
- assertEquals(fLine1, fCallsite1.getLineNumber());
- }
-
- @Test
- public void testCallsiteCopy() {
- TmfCallsite copy = new TmfCallsite(fCallsite1);
-
- assertEquals(fFileName1, copy.getFileName());
- assertEquals(fFunctionName1, copy.getFunctionName());
- assertEquals(fLine1, copy.getLineNumber());
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCallsiteCopy2() {
- new TmfCallsite(null);
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCallsiteCopy3() {
- new TmfCallsite(new ITmfCallsite() {
- @Override
- public long getLineNumber() {
- return 0;
- }
-
- @Override
- public String getFunctionName() {
- return null;
- }
-
- @Override
- public String getFileName() {
- return null;
- }
- });
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCallsiteFileNull() {
- new TmfCallsite(null, fFunctionName1, fLine1);
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfCallsite callsite1b = new TmfCallsite(fCallsite1);
- final ITmfCallsite callsite2b = new TmfCallsite(fCallsite2);
-
- assertTrue("hashCode", fCallsite1.hashCode() == callsite1b.hashCode());
- assertTrue("hashCode", fCallsite2.hashCode() == callsite2b.hashCode());
-
- assertTrue("hashCode", fCallsite1.hashCode() != fCallsite2.hashCode());
- assertTrue("hashCode", fCallsite2.hashCode() != fCallsite1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fCallsite1.equals(fCallsite1));
- assertTrue("equals", fCallsite2.equals(fCallsite2));
-
- assertFalse("equals", fCallsite1.equals(fCallsite2));
- assertFalse("equals", fCallsite2.equals(fCallsite1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfCallsite callsite1 = new TmfCallsite(fCallsite1);
- final ITmfCallsite callsite2 = new TmfCallsite(fCallsite2);
-
- assertTrue("equals", callsite1.equals(fCallsite1));
- assertTrue("equals", fCallsite1.equals(callsite1));
-
- assertTrue("equals", callsite2.equals(fCallsite2));
- assertTrue("equals", fCallsite2.equals(callsite2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfCallsite callsite1 = new TmfCallsite(fCallsite1);
- final ITmfCallsite callsite2 = new TmfCallsite(fCallsite1);
- final ITmfCallsite callsite3 = new TmfCallsite(fCallsite1);
-
- assertTrue("equals", callsite1.equals(callsite2));
- assertTrue("equals", callsite2.equals(callsite3));
- assertTrue("equals", callsite1.equals(callsite3));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fCallsite1.equals(null));
- assertFalse("equals", fCallsite2.equals(null));
- assertFalse("equals", fCallsite3.equals(null));
- }
-
- @Test
- public void testNonEqualClasses() {
- assertFalse("equals", fCallsite1.equals(fCallsite1.getFileName()));
- }
-
- @Test
- public void testNullElements() {
- ITmfCallsite callsite = new TmfCallsite(fFileName1, null, fLine1);
- assertFalse("equals", fCallsite1.equals(callsite));
- assertFalse("equals", callsite.equals(fCallsite1));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- assertEquals("toString", "filename1:10 func1()", fCallsite1.toString());
- assertEquals("toString", "filename2:25 func2()", fCallsite2.toString());
- assertEquals("toString", "filename3:123", fCallsite3.toString());
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/AllTests.java
deleted file mode 100644
index 967226e8c3..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.filter;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Filter tests.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfCollapseFilterTest.class,
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/TmfCollapseFilterTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/TmfCollapseFilterTest.java
deleted file mode 100644
index 4c58f80685..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/filter/TmfCollapseFilterTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.filter;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.filter.TmfCollapseFilter;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.collapse.ITmfCollapsibleEvent;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TmfCollpaseFilter} class.
- *
- * @author Bernd Hufmann
- */
-@SuppressWarnings("javadoc")
-public class TmfCollapseFilterTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private CollapsibleEvent fCollapsibleEvent1 = new CollapsibleEvent(true);
- private CollapsibleEvent fCollapsibleEvent2 = new CollapsibleEvent(true);
- private CollapsibleEvent fCollapsibleEvent3 = new CollapsibleEvent(false);
- private NonCollapsibleEvent fNonCollapsibleEvent1 = new NonCollapsibleEvent();
- private TmfCollapseFilter fFilter = new TmfCollapseFilter();
-
- // ------------------------------------------------------------------------
- // matches
- // ------------------------------------------------------------------------
-
- @Test
- public void testMatches() {
-
- TmfCollapseFilter filter = new TmfCollapseFilter();
-
- assertTrue(filter.matches(fCollapsibleEvent1));
- assertFalse(filter.matches(fCollapsibleEvent2));
- assertFalse(filter.matches(fCollapsibleEvent1));
- assertFalse(filter.matches(fCollapsibleEvent2));
- assertTrue(filter.matches(fNonCollapsibleEvent1));
- assertTrue(filter.matches(fNonCollapsibleEvent1));
- assertTrue(filter.matches(fCollapsibleEvent1));
- assertFalse(filter.matches(fCollapsibleEvent2));
- assertTrue(filter.matches(fCollapsibleEvent3));
- }
-
- @Test
- public void testInterfaces() {
- assertNull("getParent()", fFilter.getParent());
- assertEquals("getName()", "Collapse", fFilter.getNodeName());
- assertEquals("hasChildren()", false, fFilter.hasChildren());
- assertEquals("getChildrenCount()", 0, fFilter.getChildrenCount());
- assertEquals("getChildren()", 0, fFilter.getChildren().length);
- }
-
- @Test
- public void testClone() {
- assertNotEquals("clone()", fFilter, fFilter.clone());
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testGetChild() {
- fFilter.getChild(0);
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testRemove() {
- fFilter.remove();
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testRemoveChild() {
- fFilter.removeChild(null);
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testAddChild() {
- fFilter.addChild(null);
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testReplaceChild() {
- fFilter.replaceChild(0, null);
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testGetValidChildren() {
- fFilter.getValidChildren();
- }
-
- // ------------------------------------------------------------------------
- // Helper Classes
- // ------------------------------------------------------------------------
-
- private class CollapsibleEvent extends TmfEvent implements ITmfCollapsibleEvent {
-
- private final boolean fIsCollapsible;
- CollapsibleEvent(boolean isCollapsible) {
- super();
- fIsCollapsible = isCollapsible;
- }
- @Override
- public boolean isCollapsibleWith(ITmfEvent otherEvent) {
- return ((CollapsibleEvent)otherEvent).fIsCollapsible;
- }
- }
-
- private class NonCollapsibleEvent implements ITmfEvent {
-
- @Override
- public Object getAdapter(Class adapter) {
- return null;
- }
- @Override
- public ITmfTrace getTrace() {
- return null;
- }
- @Override
- public long getRank() {
- return 0;
- }
- @Override
- public ITmfTimestamp getTimestamp() {
- return new TmfNanoTimestamp(100);
- }
- @Override
- public String getSource() {
- return "";
- }
- @Override
- public ITmfEventType getType() {
- return new TmfEventType();
- }
- @Override
- public ITmfEventField getContent() {
- return new TmfEventField("testField", "test", null);
- }
- @Override
- public String getReference() {
- return "remote";
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/AllTests.java
deleted file mode 100644
index 59c5dbef42..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/AllTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.request;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Requests tests
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfCoalescedEventRequestTest.class,
- TmfEventRequestTest.class,
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
deleted file mode 100644
index ae5ce9c933..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.request;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedEventRequest;
-import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfEventRequestStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCoalescedEventRequest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCoalescedEventRequestTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final TmfTimeRange range1 = new TmfTimeRange(TmfTimeRange.ETERNITY);
- private final TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
-
- private TmfCoalescedEventRequest fRequest1;
- private TmfCoalescedEventRequest fRequest2;
- private TmfCoalescedEventRequest fRequest3;
- private TmfCoalescedEventRequest fRequest4;
-
- private TmfCoalescedEventRequest fRequest1b;
- private TmfCoalescedEventRequest fRequest1c;
-
- private int fRequestCount;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- TmfEventRequest.reset();
- fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
- fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 100, ExecutionType.FOREGROUND);
- fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
- fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
-
- fRequest1b = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
- fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
-
- fRequestCount = fRequest1c.getRequestId() + 1;
- }
-
- private TmfCoalescedEventRequest setupTestRequest(final boolean[] flags) {
-
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND) {
- @Override
- public void handleCompleted() {
- super.handleCompleted();
- flags[0] = true;
- }
-
- @Override
- public void handleSuccess() {
- super.handleSuccess();
- flags[1] = true;
- }
-
- @Override
- public void handleFailure() {
- super.handleFailure();
- flags[2] = true;
- }
-
- @Override
- public void handleCancel() {
- super.handleCancel();
- flags[3] = true;
- }
- };
- return request;
- }
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfCoalescedEventRequestIndexNbEventsBlocksize() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fRequest1.equals(fRequest1));
- assertTrue("equals", fRequest2.equals(fRequest2));
-
- assertFalse("equals", fRequest1.equals(fRequest2));
- assertFalse("equals", fRequest2.equals(fRequest1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1));
-
- assertFalse("equals", fRequest1.equals(fRequest3));
- assertFalse("equals", fRequest2.equals(fRequest3));
- assertFalse("equals", fRequest3.equals(fRequest1));
- assertFalse("equals", fRequest3.equals(fRequest2));
- }
-
- @Test
- public void testEqualsTransivity() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1c));
- assertTrue("equals", fRequest1.equals(fRequest1c));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fRequest1.equals(null));
- assertFalse("equals", fRequest2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- assertTrue("hashCode", fRequest1.hashCode() == fRequest1.hashCode());
- assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
- assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String expected1 = "[TmfCoalescedEventRequest(0,ITmfEvent,FOREGROUND," + range1 + ",0,100, [])]";
- String expected2 = "[TmfCoalescedEventRequest(1,ITmfEvent,FOREGROUND," + range2 + ",0,100, [])]";
- String expected3 = "[TmfCoalescedEventRequest(2,ITmfEvent,FOREGROUND," + range2 + ",0,200, [])]";
- String expected4 = "[TmfCoalescedEventRequest(3,ITmfEvent,FOREGROUND," + range2 + ",0,200, [])]";
-
- assertEquals("toString", expected1, fRequest1.toString());
- assertEquals("toString", expected2, fRequest2.toString());
- assertEquals("toString", expected3, fRequest3.toString());
- assertEquals("toString", expected4, fRequest4.toString());
- }
-
- // ------------------------------------------------------------------------
- // isCompatible
- // ------------------------------------------------------------------------
-
- @Test
- public void testIsCompatible() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
- TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
- TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
- assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
- assertTrue("isCompatible", coalescedRequest.isCompatible(req3));
- }
-
- // ------------------------------------------------------------------------
- // addEvent
- // ------------------------------------------------------------------------
-
- @Test
- public void testAddEvent1() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND);
- TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
- TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
- assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
-
- coalescedRequest.addRequest(req1);
- coalescedRequest.addRequest(req2);
-
- assertEquals("addRequest", 0, coalescedRequest.getIndex());
- assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddEvent2() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND);
- TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
- TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
- assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
-
- coalescedRequest.addRequest(req1);
- coalescedRequest.addRequest(req2);
-
- assertEquals("addRequest", 0, coalescedRequest.getIndex());
- assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
- }
-
- // ------------------------------------------------------------------------
- // done
- // ------------------------------------------------------------------------
-
- @Test
- public void testDone() {
- // Test request
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedEventRequest request = setupTestRequest(crFlags);
- TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- request.done();
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", crFlags[0]);
- assertTrue("handleSuccess", crFlags[1]);
- assertFalse("handleFailure", crFlags[2]);
- assertFalse("handleCancel", crFlags[3]);
-
- // Validate the first coalesced request
- assertTrue("isCompleted", subRequest1.isCompleted());
- assertFalse("isFailed", subRequest1.isFailed());
- assertFalse("isCancelled", subRequest1.isCancelled());
-
- // Validate the second coalesced request
- assertTrue("isCompleted", subRequest2.isCompleted());
- assertFalse("isFailed", subRequest2.isFailed());
- assertFalse("isCancelled", subRequest2.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // fail
- // ------------------------------------------------------------------------
-
- @Test
- public void testFail() {
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedEventRequest request = setupTestRequest(crFlags);
- TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- request.fail();
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", crFlags[0]);
- assertFalse("handleSuccess", crFlags[1]);
- assertTrue("handleFailure", crFlags[2]);
- assertFalse("handleCancel", crFlags[3]);
-
- // Validate the first coalesced request
- assertTrue("isCompleted", subRequest1.isCompleted());
- assertTrue("isFailed", subRequest1.isFailed());
- assertFalse("isCancelled", subRequest1.isCancelled());
-
- // Validate the second coalesced request
- assertTrue("isCompleted", subRequest2.isCompleted());
- assertTrue("isFailed", subRequest2.isFailed());
- assertFalse("isCancelled", subRequest2.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() {
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedEventRequest request = setupTestRequest(crFlags);
- TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- request.cancel();
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertTrue("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", crFlags[0]);
- assertFalse("handleSuccess", crFlags[1]);
- assertFalse("handleFailure", crFlags[2]);
- assertTrue("handleCancel", crFlags[3]);
-
- // Validate the first coalesced request
- assertTrue("isCompleted", subRequest1.isCompleted());
- assertFalse("isFailed", subRequest1.isFailed());
- assertTrue("isCancelled", subRequest1.isCancelled());
-
- // Validate the second coalesced request
- assertTrue("isCompleted", subRequest2.isCompleted());
- assertFalse("isFailed", subRequest2.isFailed());
- assertTrue("isCancelled", subRequest2.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // Coalescing
- // ------------------------------------------------------------------------
-
- private static final TmfTestTrace TEST_TRACE = TmfTestTrace.A_TEST_10K;
- private static final int NB_EVENTS = 5000;
-
- // Initialize the test trace
- private TmfTraceStub fTrace = null;
-
- private synchronized TmfTraceStub setupTrace(String path) {
- if (fTrace == null) {
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 500, false, null);
- } catch (TmfTraceException e) {
- e.printStackTrace();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return fTrace;
- }
-
- Vector<ITmfEvent> requestedEvents1;
- Vector<ITmfEvent> requestedEvents2;
- Vector<ITmfEvent> requestedEvents3;
-
- TmfEventRequest request1;
- TmfEventRequest request2;
- TmfEventRequest request3;
-
- ITmfEventProvider[] providers;
-
- private static class TmfTestTriggerSignal extends TmfSignal {
- public final boolean forceCancel;
- public final long fIndex;
-
- public TmfTestTriggerSignal(Object source, long index, boolean cancel) {
- super(source);
- forceCancel = cancel;
- fIndex = index;
- }
- }
-
- private static class TmfTestTriggerSignal2 extends TmfSignal {
- public TmfTestTriggerSignal2(Object source) {
- super(source);
- }
- }
-
- @TmfSignalHandler
- public void trigger(final TmfTestTriggerSignal signal) {
-
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final long REQUEST_OFFSET = 1000;
-
- requestedEvents1 = new Vector<>();
- request1 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex,
- NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- if (!isCompleted()) {
- requestedEvents1.add(event);
- if (signal.forceCancel) {
- cancel();
- }
- }
- }
- };
-
- requestedEvents2 = new Vector<>();
- request2 = new TmfEventRequest(ITmfEvent.class, range,
- signal.fIndex + REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- if (!isCompleted()) {
- requestedEvents2.add(event);
- }
- }
- };
-
- requestedEvents3 = new Vector<>();
- request3 = new TmfEventRequest(ITmfEvent.class, range,
- signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- if (!isCompleted()) {
- requestedEvents3.add(event);
- }
- }
- };
-
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request1);
- providers[0].sendRequest(request2);
- providers[0].sendRequest(request3);
- }
-
- /**
- * @param signal
- * the trigger signal
- */
- @TmfSignalHandler
- public void trigger(final TmfTestTriggerSignal2 signal) {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(100, -3), TmfTimestamp.BIG_CRUNCH);
- requestedEvents1 = new Vector<>();
- request1 = new TmfEventRequest(ITmfEvent.class, range, 0, 1, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(ITmfEvent event) {
- super.handleData(event);
- if (!isCompleted()) {
- requestedEvents1.add(event);
- }
- }
- };
- providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request1);
- }
-
- public void runCoalescedRequest(long startIndex) throws InterruptedException {
-
- fTrace = setupTrace(TEST_TRACE.getFullPath());
-
- TmfSignalManager.register(this);
- TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, startIndex, false);
- TmfSignalManager.dispatchSignal(signal);
-
- request1.waitForCompletion();
- request2.waitForCompletion();
- request3.waitForCompletion();
-
- try {
- assertEquals("Request1: nbEvents", NB_EVENTS, requestedEvents1.size());
- assertTrue("Request1: isCompleted", request1.isCompleted());
- assertFalse("Request1: isCancelled", request1.isCancelled());
-
- assertEquals("Request2: nbEvents", NB_EVENTS, requestedEvents2.size());
- assertTrue("Request2: isCompleted", request2.isCompleted());
- assertFalse("Request2: isCancelled", request2.isCancelled());
-
- assertEquals("Request3: nbEvents", NB_EVENTS, requestedEvents3.size());
- assertTrue("Request3: isCompleted", request3.isCompleted());
- assertFalse("Request3: isCancelled", request3.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i + 1 + request1.getIndex(), requestedEvents1.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1 + request2.getIndex(), requestedEvents2.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1 + request3.getIndex(), requestedEvents3.get(i).getTimestamp().getValue());
- }
- } finally {
- TmfSignalManager.deregister(this);
- fTrace.dispose();
- fTrace = null;
- }
- }
-
- @Test
- public void testCoalescedRequest() throws InterruptedException {
- runCoalescedRequest(0);
- runCoalescedRequest(1);
- runCoalescedRequest(5);
- }
-
- @Test
- public void testCancelCoalescedRequest() throws InterruptedException {
-
- fTrace = setupTrace(TEST_TRACE.getFullPath());
-
- TmfSignalManager.register(this);
- TmfTestTriggerSignal signal = new TmfTestTriggerSignal(this, 0, true);
- TmfSignalManager.dispatchSignal(signal);
-
- request1.waitForCompletion();
- request2.waitForCompletion();
- request3.waitForCompletion();
-
- assertTrue("Request1: isCompleted", request1.isCompleted());
- assertTrue("Request1: isCancelled", request1.isCancelled());
-
- assertEquals("Request2: nbEvents", NB_EVENTS, requestedEvents2.size());
- assertTrue("Request2: isCompleted", request2.isCompleted());
- assertFalse("Request2: isCancelled", request2.isCancelled());
-
- assertEquals("Request3: nbEvents", NB_EVENTS, requestedEvents3.size());
- assertTrue("Request3: isCompleted", request3.isCompleted());
- assertFalse("Request3: isCancelled", request3.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i + 1 + request2.getIndex(), requestedEvents2.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1 + request3.getIndex(), requestedEvents3.get(i).getTimestamp().getValue());
- }
-
- TmfSignalManager.deregister(this);
- fTrace.dispose();
- fTrace = null;
- }
-
- @Test
- public void testSingleTimeRequest() throws InterruptedException {
-
- fTrace = setupTrace(TEST_TRACE.getFullPath());
-
- TmfSignalManager.register(this);
- TmfTestTriggerSignal2 signal = new TmfTestTriggerSignal2(this);
- TmfSignalManager.dispatchSignal(signal);
-
- request1.waitForCompletion();
-
- assertTrue("Request1: isCompleted", request1.isCompleted());
-
- // We have to have one event processed
- assertEquals("Request1: nbEvents", 1, requestedEvents1.size());
-
- TmfSignalManager.deregister(this);
- fTrace.dispose();
- fTrace = null;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfEventRequestTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfEventRequestTest.java
deleted file mode 100644
index 04c78ccc1f..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfEventRequestTest.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.request;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfEventRequestStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventRequest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventRequestTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static TmfTimeRange range1 = new TmfTimeRange(TmfTimeRange.ETERNITY);
- private static TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
-
- private static TmfEventRequest fRequest1;
- private static TmfEventRequest fRequest1b;
- private static TmfEventRequest fRequest1c;
- private static TmfEventRequest fRequest2;
- private static TmfEventRequest fRequest3;
- private static TmfEventRequest fRequest4;
-
- private static int fRequestCount;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- TmfEventRequest.reset();
- fRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- fRequest2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
- fRequest3 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 200);
- fRequest4 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 300);
- fRequest1b = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- fRequest1c = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
- fRequestCount = fRequest1c.getRequestId() + 1;
- }
-
- private static TmfEventRequest setupTestRequest(final boolean[] flags) {
-
- TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, new TmfTimeRange(TmfTimeRange.ETERNITY), 100, 200) {
- @Override
- public void handleCompleted() {
- super.handleCompleted();
- flags[0] = true;
- }
-
- @Override
- public void handleSuccess() {
- super.handleSuccess();
- flags[1] = true;
- }
-
- @Override
- public void handleFailure() {
- super.handleFailure();
- flags[2] = true;
- }
-
- @Override
- public void handleCancel() {
- super.handleCancel();
- flags[3] = true;
- }
- };
- return request;
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfEventRequest() {
- TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("StartTime", TmfTimestamp.BIG_BANG, request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
-
- assertEquals("getRange", TmfTimeRange.ETERNITY, request.getRange());
- assertSame("getRange", TmfTimeRange.ETERNITY, request.getRange());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", ITmfEventRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfEventRequestTimeRange() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
- TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", ITmfEventRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfEventRequestTimeRangeNbRequested() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
- TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfEventRequestTimeRangeNbRequestedBlocksize() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
- TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fRequest1.equals(fRequest1));
- assertTrue("equals", fRequest2.equals(fRequest2));
-
- assertFalse("equals", fRequest1.equals(fRequest2));
- assertFalse("equals", fRequest2.equals(fRequest1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1));
-
- assertFalse("equals", fRequest1.equals(fRequest3));
- assertFalse("equals", fRequest2.equals(fRequest3));
- assertFalse("equals", fRequest3.equals(fRequest1));
- assertFalse("equals", fRequest3.equals(fRequest2));
- }
-
- @Test
- public void testEqualsTransivity() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1c));
- assertTrue("equals", fRequest1.equals(fRequest1c));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fRequest1.equals(null));
- assertFalse("equals", fRequest2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- assertTrue("hashCode", fRequest1.hashCode() == fRequest1.hashCode());
- assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
- assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String expected1 = "[TmfEventRequestStub(0,ITmfEvent,FOREGROUND," + range1 + ",0,100)]";
- String expected2 = "[TmfEventRequestStub(1,ITmfEvent,FOREGROUND," + range2 + ",0,100)]";
- String expected3 = "[TmfEventRequestStub(2,ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
- String expected4 = "[TmfEventRequestStub(3,ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
-
- assertEquals("toString", expected1, fRequest1.toString());
- assertEquals("toString", expected2, fRequest2.toString());
- assertEquals("toString", expected3, fRequest3.toString());
- assertEquals("toString", expected4, fRequest4.toString());
- }
-
- // ------------------------------------------------------------------------
- // done
- // ------------------------------------------------------------------------
-
- @Test
- public void testDone() {
- final boolean[] flags = new boolean[4];
- TmfEventRequest request = setupTestRequest(flags);
- request.done();
-
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertTrue("handleSuccess", flags[1]);
- assertFalse("handleFailure", flags[2]);
- assertFalse("handleCancel", flags[3]);
- }
-
- // ------------------------------------------------------------------------
- // fail
- // ------------------------------------------------------------------------
-
- @Test
- public void testFail() {
- final boolean[] flags = new boolean[4];
- TmfEventRequest request = setupTestRequest(flags);
- request.fail();
-
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertFalse("handleSuccess", flags[1]);
- assertTrue("handleFailure", flags[2]);
- assertFalse("handleCancel", flags[3]);
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() {
- final boolean[] flags = new boolean[4];
- TmfEventRequest request = setupTestRequest(flags);
- request.cancel();
-
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertTrue("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertFalse("handleSuccess", flags[1]);
- assertFalse("handleFailure", flags[2]);
- assertTrue("handleCancel", flags[3]);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/AllTests.java
deleted file mode 100644
index 804e4abd89..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.signal;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Signal tests
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfSignalManagerTest.class,
- TmfSignalThrottlerTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalManagerTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalManagerTest.java
deleted file mode 100644
index 2dfb57dbd8..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalManagerTest.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.signal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
-import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for {@link TmfSignalManager}
- *
- * @author Bernd Hufmann
- */
-public class TmfSignalManagerTest {
-
- private TestSignalSender signalSender;
-
- /**
- * Pre-test setup
- */
- @Before
- public void setUp() {
- signalSender = new TestSignalSender();
- }
-
- /**
- * After-test cleanup
- */
- @After
- public void tearDown() {
- signalSender.dispose();
- }
-
- // ------------------------------------------------------------------------
- // Test cases
- // ------------------------------------------------------------------------
-
- /**
- * Test send and receive including synch signals.
- */
- @Test
- public void testSendReceive() {
- final int NB_HANDLERS = 10;
- TestSignalHandler[] signalReceivers = new TestSignalHandler[NB_HANDLERS];
- for (int i = 0; i < NB_HANDLERS; i++) {
- signalReceivers[i] = new TestSignalHandler();
- }
- final TestSignal1 firstSignal = new TestSignal1(signalSender);
- final TestSignal2 secondSignal = new TestSignal2(signalSender);
-
- final Class<?>[] expectedOrder = new Class[] {
- TmfStartSynchSignal.class, TestSignal1.class, TmfEndSynchSignal.class,
- TmfStartSynchSignal.class, TestSignal2.class, TmfEndSynchSignal.class };
-
- try {
- signalSender.sendSignal(firstSignal);
- signalSender.sendSignal(secondSignal);
-
- for (int i = 0; i < NB_HANDLERS; i++) {
- assertEquals(expectedOrder.length, signalReceivers[i].receivedSignals.size());
-
- for (int k = 0; k < expectedOrder.length; k++) {
- assertEquals(signalReceivers[i].receivedSignals.get(k).getClass(), expectedOrder[k]);
- }
-
- for (int k = 0; k < expectedOrder.length; k += 3) {
- // Verify signal IDs
- int startSyncId = signalReceivers[i].receivedSignals.get(k).getReference();
- int signalId = signalReceivers[i].receivedSignals.get(k + 1).getReference();
- int endSyncId = signalReceivers[i].receivedSignals.get(k + 2).getReference();
-
- assertEquals(startSyncId, signalId);
- assertEquals(startSyncId, endSyncId);
- }
- }
- } finally {
- // Make sure that handlers are disposed in any case (success or not success)
- for (int i = 0; i < NB_HANDLERS; i++) {
- signalReceivers[i].dispose();
- }
- }
- }
-
- /**
- * Test nesting signals. Verify that they are handled in the same thread.
- */
- @Test
- public void testNestedSignals() {
- TestSignalHandlerNested signalResender = new TestSignalHandlerNested();
- TestSignalHandler signalReceiver = new TestSignalHandler();
-
- final TestSignal1 mainSignal = new TestSignal1(signalSender);
-
- final Class<?>[] expectedOrder = new Class[] {
- TmfStartSynchSignal.class,
- TmfStartSynchSignal.class,
- TestSignal2.class,
- TmfEndSynchSignal.class,
- TmfStartSynchSignal.class,
- TmfStartSynchSignal.class,
- TestSignal4.class,
- TmfEndSynchSignal.class,
- TestSignal3.class,
- TmfEndSynchSignal.class,
- TestSignal1.class,
- TmfEndSynchSignal.class
- };
-
- /*
- * Index of signals in array signalReceiver.receivedSignals which have
- * to have the same signal ID.
- */
-
- final int[] sameSigNoIndex = new int[] {
- 0, 10, 11, 1, 2, 3, 4, 8, 9, 5, 6, 7
- };
-
- try {
- signalSender.sendSignal(mainSignal);
-
- assertEquals(expectedOrder.length, signalReceiver.receivedSignals.size());
-
- for (int i = 0; i < expectedOrder.length; i++) {
- assertEquals(signalReceiver.receivedSignals.get(i).getClass(), expectedOrder[i]);
- }
-
- for (int i = 0; i < sameSigNoIndex.length; i+=3) {
- // Verify signal IDs
- int startSyncId = signalReceiver.receivedSignals.get(sameSigNoIndex[i]).getReference();
- int signalId = signalReceiver.receivedSignals.get(sameSigNoIndex[i + 1]).getReference();
- int endSyncId = signalReceiver.receivedSignals.get(sameSigNoIndex[i + 2]).getReference();
- assertEquals(startSyncId, signalId);
- assertEquals(startSyncId, endSyncId);
- }
- } finally {
- // Make sure that handlers are disposed in any case (success or not success)
- signalResender.dispose();
- signalReceiver.dispose();
- }
- }
-
- /**
- * Test concurrent signals. Verify that they are handled one after each
- * other.
- */
- @Test
- public void testConcurrentSignals() {
-
- TestSignalHandlerNested signalResender = new TestSignalHandlerNested();
- TestSignalHandler signalReceiver = new TestSignalHandler(false, null);
-
- /*
- * Test of synchronization of signal manager.
- *
- * The order of received signals is either set of signals triggered by
- * thread1 before set of signals triggered by thread2 or the other way
- * around.
- *
- * If both received sets were interleaved then the synchronization of
- * the signal manager would be not working.
- */
-
- final Class<?>[] expectedOrder1 = new Class[] {
- TestSignal2.class, TestSignal4.class, TestSignal3.class, TestSignal1.class, // signals triggered by thread 1
- TestSignal4.class // signal triggered by thread2
- };
-
- final Class<?>[] expectedOrder2 = new Class[] {
- TestSignal4.class, // signal triggered by thread2
- TestSignal2.class, TestSignal4.class, TestSignal3.class, TestSignal1.class // signals triggered by thread 1
- };
-
- /*
- * Run it multiple times so that both expected order are triggered
- */
- try {
- for (int k = 0; k < 10; k++) {
- // Latch to ensure that both threads are started
- final CountDownLatch startLatch = new CountDownLatch(2);
- // Latch to ensure that signals are send roughly at the same time
- final CountDownLatch sendLatch = new CountDownLatch(1);
- // Latch to ensure that both treads are finished
- final CountDownLatch endLatch = new CountDownLatch(2);
-
- signalReceiver.receivedSignals.clear();
-
- Thread senderThread1 = new Thread() {
- @Override
- public void run() {
- startLatch.countDown();
- try {
- sendLatch.await();
- } catch (InterruptedException e) {
- }
- signalSender.sendSignal(new TestSignal1(signalSender));
- endLatch.countDown();
- }
- };
-
- Thread senderThread2 = new Thread() {
- @Override
- public void run() {
- startLatch.countDown();
- try {
- sendLatch.await();
- } catch (InterruptedException e) {
- }
- signalSender.sendSignal(new TestSignal4(signalSender));
- endLatch.countDown();
- }
- };
-
- senderThread1.start();
- senderThread2.start();
- try {
- startLatch.await();
- } catch (InterruptedException e) {
- }
- sendLatch.countDown();
-
- try {
- endLatch.await();
- } catch (InterruptedException e) {
- }
-
- assertEquals(expectedOrder1.length, signalReceiver.receivedSignals.size());
- boolean pass = true;
- for (int i = 0; i < expectedOrder1.length; i++) {
- if (!signalReceiver.receivedSignals.get(i).getClass().equals(expectedOrder1[i])) {
- pass = false;
- break;
- }
- }
-
- if (!pass) {
- for (int i = 0; i < expectedOrder2.length; i++) {
- if (!signalReceiver.receivedSignals.get(i).getClass().equals(expectedOrder2[i])) {
- fail("Concurrent signal test failure!");
- }
- }
- }
- }
- } finally {
- // Make sure that handlers are disposed in any case (success or not success)
- signalResender.dispose();
- signalReceiver.dispose();
- }
- }
-
- /**
- * Test broadcastAsync()
- */
- @Test
- public void testBroadcastAsync() {
- TestSignalHandlerNested signalResender = new TestSignalHandlerNested(false);
-
- final int NB_HANDLERS = 10;
- final CountDownLatch latch = new CountDownLatch(NB_HANDLERS);
- TestSignalHandler[] signalReceivers = new TestSignalHandler[NB_HANDLERS];
- for (int i = 0; i < NB_HANDLERS; i++) {
- signalReceivers[i] = new TestSignalHandler(false, latch);
- }
-
- final Class<?>[] expectedOrder = new Class[] {
- TestSignal1.class, TestSignal2.class, TestSignal3.class, TestSignal4.class
- };
-
- try {
- final TestSignal1 mainSignal = new TestSignal1(signalSender);
- signalSender.sendSignal(mainSignal);
-
- try {
- latch.await();
- } catch (InterruptedException e) {
- }
-
- for (int i = 0; i < NB_HANDLERS; i++) {
- assertEquals(expectedOrder.length, signalReceivers[i].receivedSignals.size());
- for (int k = 0; k < expectedOrder.length; k++) {
- assertEquals(signalReceivers[i].receivedSignals.get(k).getClass(), expectedOrder[k]);
- }
- }
- } finally {
- // Make sure that handlers are disposed in any case (success or not success)
- for (int i = 0; i < NB_HANDLERS; i++) {
- signalReceivers[i].dispose();
- }
- signalResender.dispose();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- /**
- * Signal sender
- */
- private class TestSignalSender extends TmfComponent {
-
- TestSignalSender() {
- super("TestSignalSender");
- }
-
- /**
- * Send a signal
- *
- * @param signal
- * main signal to send
- */
- public void sendSignal(TmfSignal signal) {
- broadcast(signal);
- }
- }
-
- /**
- * Signal handler implementation for testing nested signals.
- * Needs to be public so TmfSignalManager can see it.
- */
- public class TestSignalHandlerNested extends AbstractBaseSignalHandler {
-
- private boolean sync;
-
- /**
- * Constructor
- */
- private TestSignalHandlerNested() {
- this(true);
- }
-
- /**
- * Constructor
- *
- * @param sync
- * log sync signals
- *
- */
- private TestSignalHandlerNested(boolean sync) {
- super("TestSignalHandlerNested", false);
- this.sync = sync;
- TmfSignalManager.deregister(this);
- TmfSignalManager.registerVIP(this);
- }
-
- /**
- * Receive a signal of type TestSignal1.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal1(final TestSignal1 signal) {
- if (sync) {
- broadcast(new TestSignal2(signal.getSource()));
- broadcast(new TestSignal3(signal.getSource()));
- } else {
- broadcastAsync(new TestSignal2(signal.getSource()));
- broadcastAsync(new TestSignal3(signal.getSource()));
- }
- }
-
- /**
- * Receive a signal of type TestSignal3.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal3(final TestSignal3 signal) {
- if (sync) {
- broadcast(new TestSignal4(signal.getSource()));
- } else {
- broadcastAsync(new TestSignal4(signal.getSource()));
- }
- }
- }
-
- /**
- * Signal handler implementation for testing of sending and receiving
- * signals.
- */
- public class TestSignalHandler extends AbstractBaseSignalHandler {
-
- private CountDownLatch latch;
-
- /**
- * Constructor
- *
- */
- private TestSignalHandler() {
- this(true, null);
- }
-
- /**
- * Constructor
- *
- * @param logSyncSigs
- * log sync signals
- * @param latch
- * latch to count down when receiving last signal
- * (TmfSingal4)
- */
- private TestSignalHandler(boolean logSyncSigs, CountDownLatch latch) {
- super("TestSignalHandler", logSyncSigs);
- this.latch = latch;
- }
-
- /**
- * Receive a signal of type TestSignal1.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal1(final TestSignal1 signal) {
- receivedSignals.add(signal);
- }
-
- /**
- * Receive a signal of type TestSignal2.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal2(final TestSignal2 signal) {
- receivedSignals.add(signal);
- }
-
- /**
- * Receive a signal of type TestSignal3.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal3(final TestSignal3 signal) {
- receivedSignals.add(signal);
- }
-
- /**
- * Receive a signal of type TestSignal4.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal4(final TestSignal4 signal) {
- receivedSignals.add(signal);
- if (latch != null) {
- latch.countDown();
- }
- }
- }
-
- /**
- * Base signal handler for start and end sync signals.
- */
- public abstract class AbstractBaseSignalHandler extends TmfComponent {
- List<TmfSignal> receivedSignals = new ArrayList<>();
- private boolean logSyncSigs;
-
- private AbstractBaseSignalHandler(String name, boolean logSyncSignal) {
- super(name);
- this.logSyncSigs = logSyncSignal;
- }
-
- /**
- * Receive a signal of type TmfStartSynchSignal.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveStartSynch(final TmfStartSynchSignal signal) {
- if (logSyncSigs) {
- receivedSignals.add(signal);
- }
- }
-
- /**
- * Receive a signal of type TmfEndSynchSignal.
- *
- * @param signal
- * Signal received
- */
- @TmfSignalHandler
- public void receiveEndSynch(final TmfEndSynchSignal signal) {
- if (logSyncSigs) {
- receivedSignals.add(signal);
- }
- }
- }
-
-
- /**
- * Test Signal object
- */
- private class TestSignal1 extends TmfSignal {
-
- public TestSignal1(Object source) {
- super(source);
- }
- }
-
- /**
- * Test Signal object
- */
- private class TestSignal2 extends TmfSignal {
-
- public TestSignal2(Object source) {
- super(source);
- }
- }
-
- /**
- * Test Signal object
- */
- private class TestSignal3 extends TmfSignal {
-
- public TestSignal3(Object source) {
- super(source);
- }
- }
-
- /**
- * Test Signal object
- */
- private class TestSignal4 extends TmfSignal {
-
- public TestSignal4(Object source) {
- super(source);
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalThrottlerTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalThrottlerTest.java
deleted file mode 100644
index 4f153f04b9..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/signal/TmfSignalThrottlerTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.signal;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalThrottler;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for {@link TmfSignalThrottler}
- *
- * @author Alexandre Montplaisir
- */
-public class TmfSignalThrottlerTest {
-
- private MySender sender;
- private MyListener listener;
-
- /**
- * Pre-test setup
- */
- @Before
- public void setUp() {
- sender = new MySender();
- listener = new MyListener();
- }
-
- /**
- * After-test cleanup
- */
- @After
- public void tearDown() {
- sender.dispose();
- listener.dispose();
- }
-
- // ------------------------------------------------------------------------
- // Test cases
- // ------------------------------------------------------------------------
-
- /**
- * Test using only one throttler. Only one signal should go through.
- */
- @Test
- public void testOneChannel() {
- final MySignal sig1 = new MySignal(sender, 0);
- final MySignal sig2 = new MySignal(sender, 0);
- final MySignal sig3 = new MySignal(sender, 0);
-
- synchronized(this) {
- sender.sendSignal(sig1);
- sender.sendSignal(sig2);
- sender.sendSignal(sig3);
- }
-
- sleep(5000);
-
- assertEquals(1, listener.nbReceived[0]);
- assertEquals(0, listener.nbReceived[1]);
- assertEquals(0, listener.nbReceived[2]);
- }
-
- /**
- * Test using multiple throttlers in parrallel. Only one signal per
- * throttler should go through.
- */
- @Test
- public void testMultipleChannels() {
- List<MySignal> signals = new ArrayList<>();
- signals.add(new MySignal(sender, 0));
- signals.add(new MySignal(sender, 0));
- signals.add(new MySignal(sender, 0));
-
- signals.add(new MySignal(sender, 1));
- signals.add(new MySignal(sender, 1));
- signals.add(new MySignal(sender, 1));
-
- signals.add(new MySignal(sender, 2));
- signals.add(new MySignal(sender, 2));
- signals.add(new MySignal(sender, 2));
-
- Collections.shuffle(signals); /* Every day */
-
- synchronized(this) {
- for (MySignal sig : signals) {
- sender.sendSignal(sig);
- }
- }
-
- sleep(5000);
-
- for (int nb : listener.nbReceived) {
- assertEquals(1, nb);
- }
- }
-
- /**
- * Test with one throttler, sending signals slowly. All three signals should
- * go through.
- */
- @Test
- public void testDelay() {
- final MySignal sig1 = new MySignal(sender, 0);
- final MySignal sig2 = new MySignal(sender, 0);
- final MySignal sig3 = new MySignal(sender, 0);
-
- sender.sendSignal(sig1);
- sleep(2000);
- sender.sendSignal(sig2);
- sleep(2000);
- sender.sendSignal(sig3);
- sleep(2000);
-
- assertEquals(3, listener.nbReceived[0]);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
-
- private static void sleep(long millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- /**
- * Signal sender
- */
- private class MySender extends TmfComponent {
-
- private final TmfSignalThrottler[] throttlers;
-
- MySender() {
- super("MySender");
- throttlers = new TmfSignalThrottler[] {
- new TmfSignalThrottler(this, 200),
- new TmfSignalThrottler(this, 500),
- new TmfSignalThrottler(this, 1000),
- };
- }
-
- void sendSignal(MySignal signal) {
- throttlers[signal.getChannel()].queue(signal);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- for (TmfSignalThrottler elem : throttlers) {
- elem.dispose();
- }
- }
- }
-
- /**
- * Signal listener
- */
- public class MyListener extends TmfComponent {
-
- int[] nbReceived = { 0, 0, 0 };
-
- /**
- * Constructor. Needs to be public so TmfSignalHandler can see it.
- */
- public MyListener() {
- super("MyListener");
- }
-
- /**
- * Receive a signal.
- *
- * @param sig
- * Signal received
- */
- @TmfSignalHandler
- public void receiveSignal(final MySignal sig) {
- nbReceived[sig.getChannel()]++;
- }
- }
-
- /**
- * Signal object
- */
- private class MySignal extends TmfSignal {
-
- private final int channel;
-
- public MySignal(MySender source, int channel) {
- super(source);
- this.channel = channel;
- }
-
- public int getChannel() {
- return channel;
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/AllTests.java
deleted file mode 100644
index b51108aa40..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 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:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.tests.statesystem
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ExperimentStateSystemModuleTest.class,
- StateSystemAnalysisModuleTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java
deleted file mode 100644
index 93fbf0beca..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
-import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.StateSystemDisposedException;
-import org.eclipse.linuxtools.statesystem.core.interval.ITmfStateInterval;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestExperimentAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-/**
- * Test the {@link TmfStateSystemAnalysisModule} class for an experiment
- *
- * @author Geneviève Bastien
- */
-public class ExperimentStateSystemModuleTest {
-
- /** Time-out tests after some time */
- @Rule
- public TestRule globalTimeout = new Timeout(60000);
-
- /** ID of the test state system analysis module */
- public static final String MODULE_SS = "org.eclipse.linuxtools.tmf.core.tests.experiment";
-
- private TmfStateSystemAnalysisModule fModule;
- private TmfExperiment fExperiment;
-
- /**
- * Setup test trace
- */
- @Before
- public void setupTraces() {
- ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
- TmfSignalManager.deregister(trace);
- ITmfTrace trace2 = TmfTestTrace.A_TEST_10K2.getTrace();
- TmfSignalManager.deregister(trace2);
- ITmfTrace[] traces = { trace, trace2 };
- fExperiment = new TmfExperimentStub("Test", traces, 1000);
- fExperiment.traceOpened(new TmfTraceOpenedSignal(this, fExperiment, null));
-
- fModule = (TmfStateSystemAnalysisModule) fExperiment.getAnalysisModule(MODULE_SS);
- assertNotNull(fModule);
- }
-
- /**
- * Some tests use traces, let's clean them here
- */
- @After
- public void cleanupTraces() {
- fExperiment.dispose();
- }
-
- /**
- * Test the state system module execution and result
- */
- @Test
- public void testSsModule() {
- ITmfStateSystem ss = fModule.getStateSystem();
- assertNull(ss);
- fModule.schedule();
- if (fModule.waitForCompletion()) {
- ss = fModule.getStateSystem();
- assertNotNull(ss);
- try {
- int quark = ss.getQuarkAbsolute(TestExperimentAnalysis.TRACE_QUARK_NAME);
- ITmfStateInterval interval = ss.querySingleState(ss.getCurrentEndTime(), quark);
- assertEquals(2, interval.getStateValue().unboxInt());
- } catch (AttributeNotFoundException e) {
- fail("The quark for number of traces does not exist");
- } catch (StateSystemDisposedException e) {
- fail("Error: state system disposed");
- }
- } else {
- fail("Module did not complete properly");
- }
- }
-
- /**
- * Make sure that the state system is initialized after calling 
- * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
- */
- @Test
- public void testInitialization() {
- assertNull(fModule.getStateSystem());
- fModule.schedule();
-
- fModule.waitForInitialization();
- assertNotNull(fModule.getStateSystem());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/StateSystemAnalysisModuleTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/StateSystemAnalysisModuleTest.java
deleted file mode 100644
index 08d588a595..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/StateSystemAnalysisModuleTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-/**
- * Test the {@link TmfStateSystemAnalysisModule} class
- *
- * @author Geneviève Bastien
- */
-public class StateSystemAnalysisModuleTest {
-
- /** Time-out tests after 20 seconds */
- @Rule
- public TestRule globalTimeout= new Timeout(20000);
-
- /** ID of the test state system analysis module */
- public static final String MODULE_SS = "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest";
-
- private TmfStateSystemAnalysisModule module;
-
- /**
- * Setup test trace
- */
- @Before
- public void setupTraces() {
- TmfTraceStub trace = (TmfTraceStub) TmfTestTrace.A_TEST_10K.getTrace();
- TmfSignalManager.deregister(trace);
- trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
-
- module = (TmfStateSystemAnalysisModule) trace.getAnalysisModule(MODULE_SS);
- }
-
- /**
- * Some tests use traces, let's clean them here
- */
- @After
- public void cleanupTraces() {
- TmfTestTrace.A_TEST_10K.dispose();
- }
-
- /**
- * Test the state system module execution and result
- */
- @Test
- public void testSsModule() {
- ITmfStateSystem ss = module.getStateSystem();
- assertNull(ss);
- module.schedule();
- if (module.waitForCompletion()) {
- ss = module.getStateSystem();
- assertNotNull(ss);
- } else {
- fail("Module did not complete properly");
- }
- }
-
- /**
- * Make sure that the state system is initialized after calling 
- * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
- */
- @Test
- public void testInitialization() {
- assertNull(module.getStateSystem());
- module.schedule();
-
- module.waitForInitialization();
- assertNotNull(module.getStateSystem());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/AllTests.java
deleted file mode 100644
index 9b93ccaa18..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/AllTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Patrick Tasse - Updates to mipmap feature
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap;
-
-import org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap.TmfMipmapStateProviderTest;
-import org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap.TmfMipmapStateProviderWeightedTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfMipmapStateProviderTest.class,
- TmfMipmapStateProviderWeightedTest.class,
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java
deleted file mode 100644
index 0a47e1ed39..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Jean-Christian Kouamé - Initial API and implementation
- * Patrick Tasse - Updates to mipmap feature
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap;
-
-import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.eclipse.linuxtools.internal.tmf.core.statesystem.mipmap.AbstractTmfMipmapStateProvider;
-import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.linuxtools.statesystem.core.statevalue.TmfStateValue;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
-
-/**
- * A mipmap state provider for test
- *
- * @author Jean-Christian Kouamé
- * @since 3.0
- */
-class TmfMipmapStateProviderStub extends AbstractTmfMipmapStateProvider {
- /** test attribute name */
- public final static String TEST_ATTRIBUTE_NAME = "test_attribute"; //$NON-NLS-1$
-
- private int resolution;
- private ITmfStateValue.Type type;
- private final static String MIPMAP_ID = "MIPMAP_ID"; //$NON-NLS-1$
-
- private final String ERROR_ATTRIBUTE_NOT_FOUND = "Error : Impossible to find the attribute"; //$NON-NLS-1$
- private final String ERROR_INVALID_STATE_VALUE = "Error : Invalid state value"; //$NON-NLS-1$
- private final String ERROR_INVALID_TIMESTAMP = "Error : Invalid timestamp"; //$NON-NLS-1$
-
- /**
- * Constructor
- *
- * @param resolution
- * the mipmap resolution array (max, min, avg)
- * @param type
- * the type of value to use
- */
- public TmfMipmapStateProviderStub(int resolution, ITmfStateValue.Type type) {
- super(null, TmfEvent.class, MIPMAP_ID);
- this.resolution = resolution;
- this.type = type;
- }
-
- @Override
- protected void eventHandle(ITmfEvent ev) {
- final long ts = ev.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- try {
- int quark = ss.getQuarkAbsoluteAndAdd(TEST_ATTRIBUTE_NAME);
- ITmfStateValue value = (ITmfStateValue) ev.getContent().getValue();
- modifyMipmapAttribute(ts, value, quark, MIN | MAX | AVG, resolution);
- } catch (TimeRangeException e) {
- Activator.logError(ERROR_INVALID_TIMESTAMP, e);
- } catch (AttributeNotFoundException e) {
- Activator.logError(ERROR_ATTRIBUTE_NOT_FOUND, e);
- } catch (StateValueTypeException e) {
- Activator.logError(ERROR_INVALID_STATE_VALUE, e);
- }
- }
-
- @Override
- public int getVersion() {
- return 0;
- }
-
- @Override
- public TmfMipmapStateProviderStub getNewInstance() {
- return new TmfMipmapStateProviderStub(resolution, type);
- }
-
- /**
- * @param time
- * The event type
- * @param longVal
- * The event value or null
- * @return A new TmfEvent
- */
- public ITmfEvent createEvent(long time, Long longVal) {
- ITmfStateValue value;
- if (longVal == null) {
- value = TmfStateValue.nullValue();
- } else if (type == ITmfStateValue.Type.LONG) {
- value = TmfStateValue.newValueLong(longVal);
- } else if (type == ITmfStateValue.Type.INTEGER) {
- value = TmfStateValue.newValueInt(longVal.intValue());
- } else if (type == ITmfStateValue.Type.DOUBLE) {
- value = TmfStateValue.newValueDouble(longVal.doubleValue());
- } else {
- value = TmfStateValue.nullValue();
- }
- ITmfTimestamp timestamp = new TmfNanoTimestamp(time);
- ITmfEventType eventType = new TmfEventType(ITmfEventType.DEFAULT_CONTEXT_ID, MIPMAP_ID, null);
- ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null);
- ITmfEvent event = new TmfEvent(null, timestamp, null, eventType, content, null);
- return event;
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderTest.java
deleted file mode 100644
index 0e18d41d5c..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderTest.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Jean-Christian Kouamé - Initial API and implementation
- * Patrick Tasse - Updates to mipmap feature
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import java.util.Random;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.internal.tmf.core.statesystem.mipmap.AbstractTmfMipmapStateProvider;
-import org.eclipse.linuxtools.internal.tmf.core.statesystem.mipmap.TmfStateSystemOperations;
-import org.eclipse.linuxtools.statesystem.core.ITmfStateSystemBuilder;
-import org.eclipse.linuxtools.statesystem.core.StateSystemFactory;
-import org.eclipse.linuxtools.statesystem.core.backend.IStateHistoryBackend;
-import org.eclipse.linuxtools.statesystem.core.backend.InMemoryBackend;
-import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.StateSystemDisposedException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.linuxtools.statesystem.core.interval.ITmfStateInterval;
-import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue.Type;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * @author Jean-Christian Kouamé
- *
- */
-public class TmfMipmapStateProviderTest {
-
- @NonNull private static final String SSID = "mimap-test";
- private static final String TEST_ATTRIBUTE_NAME = TmfMipmapStateProviderStub.TEST_ATTRIBUTE_NAME;
- private static final int NB_LEVELS = 4;
- private static final long START_TIME = 1000L;
- private static final long END_TIME = 100000000L;
- private static final long INTERVAL = 1000L;
- private static final int RESOLUTION = 16;
- private static final double DELTA = 0.0001;
- private static final long TEST_TIMESTAMP = 12345000L;
- private static ITmfStateSystemBuilder ssq;
-
- /**
- * Startup code, build a state system with n attributes always going up
- * linearly
- */
- @BeforeClass
- public static void init() {
- TmfMipmapStateProviderStub mmp = new TmfMipmapStateProviderStub(RESOLUTION, Type.LONG);
- IStateHistoryBackend be = new InMemoryBackend(0);
- ssq = StateSystemFactory.newStateSystem(SSID, be);
- mmp.assignTargetStateSystem(ssq);
-
- for (long time = START_TIME; time <= END_TIME; time += INTERVAL) {
- long value = time / INTERVAL;
- ITmfEvent event = mmp.createEvent(time, value);
- mmp.processEvent(event);
- }
- mmp.dispose();
- ssq.waitUntilBuilt();
- }
-
- /**
- * Test a single query to the state system.
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be t / 1000
- *
- */
- @Test
- public void testQuery() {
- assertNotNull(ssq);
- try {
- Random rn = new Random();
- long time = Math.max(INTERVAL, rn.nextLong() % END_TIME);
- List<ITmfStateInterval> intervals = ssq.queryFullState(time);
- int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- ITmfStateInterval interval = intervals.get(mipmapQuark);
- long valueLong = interval.getStateValue().unboxLong();
- assertEquals(time / INTERVAL, valueLong);
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a single query to the state system for the maxLevel.
- *
- * Make sure the state system has data.
- *
- */
- @Test
- public void testMaxLevel() {
- assertNotNull(ssq);
- try {
- Random rn = new Random();
- long time = Math.max(INTERVAL, rn.nextLong() % END_TIME);
- List<ITmfStateInterval> intervals = ssq.queryFullState(time);
-
- int maxMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
- int nbLevelMax = intervals.get(maxMipmapQuark).getStateValue().unboxInt();
- assertEquals(NB_LEVELS, nbLevelMax);
-
- int minMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
- int nbLevelMin = intervals.get(minMipmapQuark).getStateValue().unboxInt();
- assertEquals(NB_LEVELS, nbLevelMin);
-
- int avgMipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.AVG_STRING);
- int nbLevelAvg = intervals.get(avgMipmapQuark).getStateValue().unboxInt();
- assertEquals(NB_LEVELS, nbLevelAvg);
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
-
- }
-
- /**
- * Test a single query to the state system for a mip
- *
- * Make sure the state system has data.
- *
- */
- @Test
- public void testQueryEventField() {
- assertNotNull(ssq);
- try {
- List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
- int eventFieldQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- ITmfStateInterval interval = intervals.get(eventFieldQuark);
- long valueLong = interval.getStateValue().unboxLong();
- assertEquals(TEST_TIMESTAMP / INTERVAL, valueLong);
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a single query to the state system for a max
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be greater than(t / 1000)
- *
- */
- @Test
- public void testQueryMipMax() {
- assertNotNull(ssq);
- try {
- List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
- int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MAX_STRING);
-
- assertEquals("max nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
- for (int level = 1; level < NB_LEVELS; level++) {
- long width = (long) Math.pow(RESOLUTION, level);
- int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
- ITmfStateInterval interval = intervals.get(levelQuark);
- long valueLong = interval.getStateValue().unboxLong();
- assertEquals("max value @ level " + level, width + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
- assertEquals("max start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
- assertEquals("max end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
- }
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a single query to the state system for a min
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be less than(t / 1000)
- */
- @Test
- public void testQueryMipMin() {
- assertNotNull(ssq);
- try {
- List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
- int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.MIN_STRING);
-
- assertEquals("min nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
- for (int level = 1; level < NB_LEVELS; level++) {
- long width = (long) Math.pow(RESOLUTION, level);
- int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
- ITmfStateInterval interval = intervals.get(levelQuark);
- long valueLong = interval.getStateValue().unboxLong();
- assertEquals("min value @ level " + level, 1 + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueLong);
- assertEquals("min start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
- assertEquals("min end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
- }
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a single query to the state system for an average
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be more or less(t / 1000)
- *
- */
- @Test
- public void testQueryMipAvg() {
- assertNotNull(ssq);
- try {
- List<ITmfStateInterval> intervals = ssq.queryFullState(TEST_TIMESTAMP);
- int mipmapQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME, AbstractTmfMipmapStateProvider.AVG_STRING);
-
- assertEquals("avg nblevels", NB_LEVELS, intervals.get(mipmapQuark).getStateValue().unboxInt());
- for (int level = 1; level < NB_LEVELS; level++) {
- long width = (long) Math.pow(RESOLUTION, level);
- int levelQuark = ssq.getQuarkRelative(mipmapQuark, String.valueOf(level));
- ITmfStateInterval interval = intervals.get(levelQuark);
- double valueDouble = interval.getStateValue().unboxDouble();
- assertEquals("avg value @ level " + level, 0.5 + (width / 2) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width, valueDouble, DELTA);
- assertEquals("avg start time @ level " + level, START_TIME + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getStartTime());
- assertEquals("avg end time @ level " + level, START_TIME + (INTERVAL * width) + (((TEST_TIMESTAMP - START_TIME) / INTERVAL) / width) * width * INTERVAL, interval.getEndTime() + 1);
- }
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a full query to the state system at the startTime
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be more or less(t / 1000)
- *
- */
- @Test
- public void testQueryValuesOnStart() {
- assertNotNull(ssq);
- try {
- int quark;
-
- List<ITmfStateInterval> intervals = ssq.queryFullState(START_TIME);
-
- int baseQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(START_TIME / INTERVAL, intervals.get(baseQuark).getStateValue().unboxLong());
-
- int maxMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.MAX_STRING);
- assertEquals("max nblevels", NB_LEVELS, intervals.get(maxMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(1));
- assertEquals("max value @ level 1", (long) Math.pow(RESOLUTION, 1), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(2));
- assertEquals("max value @ level 2", (long) Math.pow(RESOLUTION, 2), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(3));
- assertEquals("max value @ level 3", (long) Math.pow(RESOLUTION, 3), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(4));
- assertEquals("max value @ level 4", (long) Math.pow(RESOLUTION, 4), intervals.get(quark).getStateValue().unboxLong());
-
- int minMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.MIN_STRING);
- assertEquals("min nblevels", NB_LEVELS, intervals.get(minMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(1));
- assertEquals("min value @ level 1", START_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(2));
- assertEquals("min value @ level 2", START_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(3));
- assertEquals("min value @ level 3", START_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(4));
- assertEquals("min value @ level 4", START_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
-
- int avgMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.AVG_STRING);
- assertEquals("avg nblevels", NB_LEVELS, intervals.get(avgMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(1));
- assertEquals("avg value @ level 1", 0.5 + Math.pow(RESOLUTION, 1) / 2, intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(2));
- assertEquals("avg value @ level 2", 0.5 + Math.pow(RESOLUTION, 2) / 2, intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(3));
- assertEquals("avg value @ level 3", 0.5 + Math.pow(RESOLUTION, 3) / 2, intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(4));
- assertEquals("avg value @ level 4", 0.5 + Math.pow(RESOLUTION, 4) / 2, intervals.get(quark).getStateValue().unboxDouble(), DELTA);
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a full query to the state system when the end time
- *
- * Make sure the state system has data.
- *
- * Hint: the value read should always be more or less(t / 1000)
- *
- */
- @Test
- public void testQueryValuesOnClose() {
- assertNotNull(ssq);
- try {
- int quark;
-
- List<ITmfStateInterval> intervals = ssq.queryFullState(END_TIME);
-
- int baseQuark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(END_TIME / INTERVAL, intervals.get(baseQuark).getStateValue().unboxLong());
-
- int maxMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.MAX_STRING);
- assertEquals("max nblevels", NB_LEVELS, intervals.get(maxMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(1));
- assertEquals("max value @ level 1", END_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(2));
- assertEquals("max value @ level 2", END_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(3));
- assertEquals("max value @ level 3", END_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(maxMipmapQuark, String.valueOf(4));
- assertEquals("max value @ level 4", END_TIME / INTERVAL, intervals.get(quark).getStateValue().unboxLong());
-
- int minMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.MIN_STRING);
- assertEquals("min nblevels", NB_LEVELS, intervals.get(minMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(1));
- assertEquals("min value @ level 1", END_TIME / INTERVAL - (END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 1), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(2));
- assertEquals("min value @ level 2", END_TIME / INTERVAL - (END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 2), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(3));
- assertEquals("min value @ level 3", END_TIME / INTERVAL - (END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 3), intervals.get(quark).getStateValue().unboxLong());
- quark = ssq.getQuarkRelative(minMipmapQuark, String.valueOf(4));
- assertEquals("min value @ level 4", END_TIME / INTERVAL - (END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 4), intervals.get(quark).getStateValue().unboxLong());
-
- int avgMipmapQuark = ssq.getQuarkRelative(baseQuark, AbstractTmfMipmapStateProvider.AVG_STRING);
- assertEquals("avg nblevels", NB_LEVELS, intervals.get(avgMipmapQuark).getStateValue().unboxInt());
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(1));
- assertEquals("avg value @ level 1", (long) (END_TIME / INTERVAL - (double) ((END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 1)) / 2), intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(2));
- assertEquals("avg value @ level 2", (long) (END_TIME / INTERVAL - (double) ((END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 2)) / 2), intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(3));
- assertEquals("avg value @ level 3", (long) (END_TIME / INTERVAL - (double) ((END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 3)) / 2), intervals.get(quark).getStateValue().unboxDouble(), DELTA);
- quark = ssq.getQuarkRelative(avgMipmapQuark, String.valueOf(4));
- assertEquals("avg value @ level 4", (long) (END_TIME / INTERVAL - (double) ((END_TIME - START_TIME) / INTERVAL % (long) Math.pow(RESOLUTION, 4)) / 2), intervals.get(quark).getStateValue().unboxDouble(), DELTA);
-
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateSystemDisposedException e) {
- fail(e.getMessage());
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- assertTrue(true);
- }
-
- /**
- * Test a query range to the state system to get the maximum value in the
- * range
- *
- * Make sure the state system has data.
- *
- *
- */
- @Test
- public void testQueryMipmapRangeMax() {
- assertNotNull(ssq);
- try {
- long max;
- int quark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, 0, START_TIME, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, max);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, START_TIME, START_TIME, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, max);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, START_TIME, END_TIME / 2, quark).unboxLong();
- assertEquals((END_TIME / 2 / INTERVAL), max);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, 0, END_TIME, quark).unboxLong();
- assertEquals(END_TIME / INTERVAL, max);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, END_TIME / 2, END_TIME, quark).unboxLong();
- assertEquals(END_TIME / INTERVAL, max);
-
- max = TmfStateSystemOperations.queryRangeMax(ssq, START_TIME - INTERVAL / 2, END_TIME / 2 + INTERVAL / 2, quark).unboxLong();
- assertEquals(END_TIME / 2 / INTERVAL, max);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the minimum value in the
- * range
- *
- * Make sure the state system has data.
- *
- *
- */
- @Test
- public void testQueryMipmapRangeMin() {
- assertNotNull(ssq);
- try {
- long min;
- int quark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, 0, START_TIME, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, min);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, START_TIME, START_TIME, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, min);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, START_TIME, END_TIME / 2, quark).unboxLong();
- assertEquals((START_TIME / INTERVAL), min);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, 0, END_TIME, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, min);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, END_TIME / 2, END_TIME, quark).unboxLong();
- assertEquals(END_TIME / 2 / INTERVAL, min);
-
- min = TmfStateSystemOperations.queryRangeMin(ssq, START_TIME - INTERVAL / 2, END_TIME / 2 + INTERVAL / 2, quark).unboxLong();
- assertEquals(START_TIME / INTERVAL, min);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the average value in the
- * range
- *
- * Make sure the state system has data.
- *
- */
- @Test
- public void testQueryMipmapRangeAvg() {
- assertNotNull(ssq);
- try {
- double avg;
- int quark = ssq.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, 0, START_TIME, quark);
- assertEquals((double) (START_TIME - INTERVAL) / INTERVAL, avg, DELTA);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, START_TIME, START_TIME, quark);
- assertEquals((double) START_TIME / INTERVAL, avg, DELTA);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, START_TIME, END_TIME / 2, quark);
- assertEquals((double) (START_TIME + (END_TIME / 2 - INTERVAL)) / 2 / INTERVAL, avg, DELTA);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, 0, END_TIME, quark);
- assertEquals((double) (END_TIME - INTERVAL) / 2 / INTERVAL, avg, DELTA);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, END_TIME / 2, END_TIME, quark);
- assertEquals((double) (END_TIME / 2 + (END_TIME - INTERVAL)) / 2 / INTERVAL, avg, DELTA);
-
- avg = TmfStateSystemOperations.queryRangeAverage(ssq, START_TIME - INTERVAL / 2, END_TIME / 2 + INTERVAL / 2, quark);
- assertEquals((double) (START_TIME + (END_TIME / 2 - INTERVAL)) / 2 / INTERVAL, avg, DELTA);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java
deleted file mode 100644
index 45bc5165f6..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Patrick Tasse - Updates to mipmap feature
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.statesystem.mipmap;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.internal.tmf.core.statesystem.mipmap.TmfStateSystemOperations;
-import org.eclipse.linuxtools.statesystem.core.ITmfStateSystemBuilder;
-import org.eclipse.linuxtools.statesystem.core.StateSystemFactory;
-import org.eclipse.linuxtools.statesystem.core.backend.IStateHistoryBackend;
-import org.eclipse.linuxtools.statesystem.core.backend.InMemoryBackend;
-import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue.Type;
-import org.eclipse.linuxtools.statesystem.core.statevalue.TmfStateValue;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * @author Patrick Tasse
- *
- */
-public class TmfMipmapStateProviderWeightedTest {
-
- @NonNull private static final String SSID = "mipmap-test";
- private static final String TEST_ATTRIBUTE_NAME = TmfMipmapStateProviderStub.TEST_ATTRIBUTE_NAME;
- private static final long END_TIME = 250000L;
- private static final long INTERVAL = 1000L;
- private static final int RESOLUTION = 2;
- private static final double DELTA = 0.0001;
- private static ITmfStateSystemBuilder ssqi;
- private static ITmfStateSystemBuilder ssqd;
-
- /**
- * Startup code, build a state system with uneven state durations
- */
- @BeforeClass
- public static void init() {
- /* setup for INTEGER test */
- TmfMipmapStateProviderStub mmpi = new TmfMipmapStateProviderStub(RESOLUTION, Type.INTEGER);
- IStateHistoryBackend bei = new InMemoryBackend(0);
- ssqi = StateSystemFactory.newStateSystem(SSID, bei);
- mmpi.assignTargetStateSystem(ssqi);
- /* setup for DOUBLE test */
- TmfMipmapStateProviderStub mmpd = new TmfMipmapStateProviderStub(RESOLUTION, Type.DOUBLE);
- IStateHistoryBackend bed = new InMemoryBackend(0);
- ssqd = StateSystemFactory.newStateSystem(SSID, bed);
- mmpd.assignTargetStateSystem(ssqd);
- /*
- * Every 10,000 ns chunk contains the following states:
- *
- * | null | 10 | null | 20 | null | 30 | null |
- * 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10,000
- *
- * The weighted average for a chunk is (1 x 10 + 2 x 20 + 3 x 30) / 10 = 14.
- */
- for (int i = 0; i < END_TIME / INTERVAL / 10; i++) {
- long time = i * 10 * INTERVAL;
- /* update for INTEGER test */
- mmpi.processEvent(mmpi.createEvent(time, null));
- mmpi.processEvent(mmpi.createEvent(time + 1000, 10L));
- mmpi.processEvent(mmpi.createEvent(time + 2000, null));
- mmpi.processEvent(mmpi.createEvent(time + 3000, 20L));
- mmpi.processEvent(mmpi.createEvent(time + 5000, null));
- mmpi.processEvent(mmpi.createEvent(time + 6000, 30L));
- mmpi.processEvent(mmpi.createEvent(time + 9000, null));
- /* update for DOUBLE test */
- mmpd.processEvent(mmpd.createEvent(time, null));
- mmpd.processEvent(mmpd.createEvent(time + 1000, 10L));
- mmpd.processEvent(mmpd.createEvent(time + 2000, null));
- mmpd.processEvent(mmpd.createEvent(time + 3000, 20L));
- mmpd.processEvent(mmpd.createEvent(time + 5000, null));
- mmpd.processEvent(mmpd.createEvent(time + 6000, 30L));
- mmpd.processEvent(mmpd.createEvent(time + 9000, null));
- }
- /* cleanup for INTEGER test */
- mmpi.processEvent(mmpi.createEvent(END_TIME, 0L));
- mmpi.dispose();
- ssqi.waitUntilBuilt();
- /* cleanup for DOUBLE test */
- mmpd.processEvent(mmpd.createEvent(END_TIME, 0L));
- mmpd.dispose();
- ssqd.waitUntilBuilt();
- }
-
- /**
- * Test a query range to the state system to get the maximum value in the
- * range. The test values are INTEGER.
- */
- @Test
- public void testQueryMipmapRangeMaxInteger() {
- assertNotNull(ssqi);
- try {
- int quark = ssqi.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMax(ssqi, 0, 0, quark));
- assertEquals(10, TmfStateSystemOperations.queryRangeMax(ssqi, 500, 1500, quark).unboxInt());
- assertEquals(20, TmfStateSystemOperations.queryRangeMax(ssqi, 1500, 5000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 5000, 10000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 0, 10000, quark).unboxInt());
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMax(ssqi, 120000, 120000, quark));
- assertEquals(10, TmfStateSystemOperations.queryRangeMax(ssqi, 120500, 121500, quark).unboxInt());
- assertEquals(20, TmfStateSystemOperations.queryRangeMax(ssqi, 121500, 125000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 125000, 130000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 120000, 130000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 100000, 150000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 240000, 250000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMax(ssqi, 0, 250000, quark).unboxInt());
- assertEquals(00, TmfStateSystemOperations.queryRangeMax(ssqi, 250000, 250000, quark).unboxInt());
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the minimum value in the
- * range. The test values are INTEGER.
- */
- @Test
- public void testQueryMipmapRangeMinInteger() {
- assertNotNull(ssqi);
- try {
- int quark = ssqi.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMin(ssqi, 0, 0, quark));
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 500, 1500, quark).unboxInt());
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 1500, 5000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMin(ssqi, 5000, 10000, quark).unboxInt());
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 0, 10000, quark).unboxInt());
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMin(ssqi, 120000, 120000, quark));
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 120500, 121500, quark).unboxInt());
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 121500, 125000, quark).unboxInt());
- assertEquals(30, TmfStateSystemOperations.queryRangeMin(ssqi, 125000, 130000, quark).unboxInt());
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 120000, 130000, quark).unboxInt());
- assertEquals(10, TmfStateSystemOperations.queryRangeMin(ssqi, 100000, 150000, quark).unboxInt());
- assertEquals(00, TmfStateSystemOperations.queryRangeMin(ssqi, 240000, 250000, quark).unboxInt());
- assertEquals(00, TmfStateSystemOperations.queryRangeMin(ssqi, 0, 250000, quark).unboxInt());
- assertEquals(00, TmfStateSystemOperations.queryRangeMin(ssqi, 250000, 250000, quark).unboxInt());
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the average value in the
- * range. The test values are INTEGER.
- */
- @Test
- public void testQueryMipmapRangeAvgInteger() {
- assertNotNull(ssqi);
- try {
- int quark = ssqi.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 0, 0, quark), DELTA);
- assertEquals(5.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 500, 1500, quark), DELTA);
- assertEquals(90.0 / 7, TmfStateSystemOperations.queryRangeAverage(ssqi, 1500, 5000, quark), DELTA);
- assertEquals(90.0 / 5, TmfStateSystemOperations.queryRangeAverage(ssqi, 5000, 10000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 0, 10000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 0, 20000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 500, 20500, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 1000, 21000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 2000, 22000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 3000, 23000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 4000, 24000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 5000, 25000, quark), DELTA);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 120000, 120000, quark), DELTA);
- assertEquals(5.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 120500, 121500, quark), DELTA);
- assertEquals(90.0 / 7, TmfStateSystemOperations.queryRangeAverage(ssqi, 121500, 125000, quark), DELTA);
- assertEquals(90.0 / 5, TmfStateSystemOperations.queryRangeAverage(ssqi, 125000, 130000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 120000, 130000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 100000, 150000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 240000, 250000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 0, 250000, quark), DELTA);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqi, 250000, 250000, quark), DELTA);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the maximum value in the
- * range. The test values are DOUBLE.
- */
- @Test
- public void testQueryMipmapRangeMaxDouble() {
- assertNotNull(ssqd);
- try {
- int quark = ssqd.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMax(ssqd, 0, 0, quark));
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMax(ssqd, 500, 1500, quark).unboxDouble(), DELTA);
- assertEquals(20.0, TmfStateSystemOperations.queryRangeMax(ssqd, 1500, 5000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 5000, 10000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 0, 10000, quark).unboxDouble(), DELTA);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMax(ssqd, 120000, 120000, quark));
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMax(ssqd, 120500, 121500, quark).unboxDouble(), DELTA);
- assertEquals(20.0, TmfStateSystemOperations.queryRangeMax(ssqd, 121500, 125000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 125000, 130000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 120000, 130000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 100000, 150000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 240000, 250000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMax(ssqd, 0, 250000, quark).unboxDouble(), DELTA);
- assertEquals(00.0, TmfStateSystemOperations.queryRangeMax(ssqd, 250000, 250000, quark).unboxDouble(), DELTA);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the minimum value in the
- * range. The test values are DOUBLE.
- */
- @Test
- public void testQueryMipmapRangeMinDouble() {
- assertNotNull(ssqd);
- try {
- int quark = ssqd.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMin(ssqd, 0, 0, quark));
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 500, 1500, quark).unboxDouble(), DELTA);
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 1500, 5000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMin(ssqd, 5000, 10000, quark).unboxDouble(), DELTA);
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 0, 10000, quark).unboxDouble(), DELTA);
- assertEquals(TmfStateValue.nullValue(), TmfStateSystemOperations.queryRangeMin(ssqd, 120000, 120000, quark));
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 120500, 121500, quark).unboxDouble(), DELTA);
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 121500, 125000, quark).unboxDouble(), DELTA);
- assertEquals(30.0, TmfStateSystemOperations.queryRangeMin(ssqd, 125000, 130000, quark).unboxDouble(), DELTA);
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 120000, 130000, quark).unboxDouble(), DELTA);
- assertEquals(10.0, TmfStateSystemOperations.queryRangeMin(ssqd, 100000, 150000, quark).unboxDouble(), DELTA);
- assertEquals(00.0, TmfStateSystemOperations.queryRangeMin(ssqd, 240000, 250000, quark).unboxDouble(), DELTA);
- assertEquals(00.0, TmfStateSystemOperations.queryRangeMin(ssqd, 0, 250000, quark).unboxDouble(), DELTA);
- assertEquals(00.0, TmfStateSystemOperations.queryRangeMin(ssqd, 250000, 250000, quark).unboxDouble(), DELTA);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test a query range to the state system to get the average value in the
- * range. The test values are DOUBLE.
- */
- @Test
- public void testQueryMipmapRangeAvgDouble() {
- assertNotNull(ssqd);
- try {
- int quark = ssqd.getQuarkAbsolute(TEST_ATTRIBUTE_NAME);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 0, 0, quark), DELTA);
- assertEquals(5.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 500, 1500, quark), DELTA);
- assertEquals(90.0 / 7, TmfStateSystemOperations.queryRangeAverage(ssqd, 1500, 5000, quark), DELTA);
- assertEquals(90.0 / 5, TmfStateSystemOperations.queryRangeAverage(ssqd, 5000, 10000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 0, 10000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 0, 20000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 500, 20500, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 1000, 21000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 2000, 22000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 3000, 23000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 4000, 24000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 5000, 25000, quark), DELTA);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 120000, 120000, quark), DELTA);
- assertEquals(5.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 120500, 121500, quark), DELTA);
- assertEquals(90.0 / 7, TmfStateSystemOperations.queryRangeAverage(ssqd, 121500, 125000, quark), DELTA);
- assertEquals(90.0 / 5, TmfStateSystemOperations.queryRangeAverage(ssqd, 125000, 130000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 120000, 130000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 100000, 150000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 240000, 250000, quark), DELTA);
- assertEquals(14.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 0, 250000, quark), DELTA);
- assertEquals(0.0, TmfStateSystemOperations.queryRangeAverage(ssqd, 250000, 250000, quark), DELTA);
-
- } catch (AttributeNotFoundException e) {
- fail(e.getMessage());
- } catch (TimeRangeException e) {
- fail(e.getMessage());
- } catch (StateValueTypeException e) {
- fail(e.getMessage());
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/AllTests.java
deleted file mode 100644
index 18e5442e6a..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.synchronization;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.synchronization
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ TsTransformTest.class,
- SyncTest.class,
- TsTransformFactoryTest.class,
- TimeOffsetTest.class })
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/SyncTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/SyncTest.java
deleted file mode 100644
index 270df9f851..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/SyncTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.synchronization;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
-import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
-import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
-import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm.SyncQuality;
-import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithmFactory;
-import org.eclipse.linuxtools.tmf.core.synchronization.TimestampTransformFactory;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.event.TmfSyncEventStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests for {@link SynchronizationAlgorithm} and its descendants
- *
- * @author Geneviève Bastien
- */
-@SuppressWarnings("nls")
-public class SyncTest {
-
- private TmfTraceStub t1, t2;
- private Collection<ITmfTrace> fTraces;
-
- /**
- * Initializing the traces
- */
- @Before
- public void init() {
- t1 = new TmfTraceStub();
- t1.init("t1");
- t2 = new TmfTraceStub();
- t2.init("t2");
-
- Collection<ITmfTrace> traces = new LinkedList<>();
- traces.add(t1);
- traces.add(t2);
- fTraces = traces;
- }
-
- /**
- * Testing fully incremental algorithm with communication between the two
- * traces
- */
- @Test
- public void testFullyIncremental() {
-
- SynchronizationAlgorithm syncAlgo = SynchronizationAlgorithmFactory.getFullyIncrementalAlgorithm();
-
- syncAlgo.init(fTraces);
-
- assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(1)),
- new TmfSyncEventStub(t1, new TmfTimestamp(1))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
- new TmfSyncEventStub(t2, new TmfTimestamp(3))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(2)),
- new TmfSyncEventStub(t1, new TmfTimestamp(3))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0.5 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
- new TmfSyncEventStub(t2, new TmfTimestamp(5))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
- new TmfSyncEventStub(t2, new TmfTimestamp(8))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(4)),
- new TmfSyncEventStub(t1, new TmfTimestamp(5))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(4)),
- new TmfSyncEventStub(t1, new TmfTimestamp(6))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(6)),
- new TmfSyncEventStub(t2, new TmfTimestamp(7))
- ));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.725 beta 1.275 ]]", syncAlgo.toString());
- assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(t2);
- ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(t1);
-
- assertEquals(syncAlgo.getTimestampTransform(t1.getHostId()), tt1);
- assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
- assertEquals(syncAlgo.getTimestampTransform(t2.getHostId()), tt2);
-
- /* Make the two hulls intersect */
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(7)),
- new TmfSyncEventStub(t2, new TmfTimestamp(4))
- ));
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(7)),
- new TmfSyncEventStub(t1, new TmfTimestamp(3))
- ));
- assertEquals(SyncQuality.FAIL, syncAlgo.getSynchronizationQuality(t1, t2));
- }
-
- /**
- * Testing the fully incremental synchronization algorithm when
- * communication goes in only one direction
- */
- @Test
- public void testOneHull() {
-
- SynchronizationAlgorithm syncAlgo = SynchronizationAlgorithmFactory.getFullyIncrementalAlgorithm();
-
- syncAlgo.init(fTraces);
-
- assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
- new TmfSyncEventStub(t2, new TmfTimestamp(3)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(2)),
- new TmfSyncEventStub(t2, new TmfTimestamp(5)))
- );
-
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
- new TmfSyncEventStub(t2, new TmfTimestamp(5)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
- new TmfSyncEventStub(t2, new TmfTimestamp(7)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
-
- }
-
- /**
- * Testing the fully incremental synchronization algorithm when all
- * communication from trace1 to trace2 happens before all communication from
- * trace2 to trace1
- */
- @Test
- public void testDisjoint() {
-
- SynchronizationAlgorithm syncAlgo = SynchronizationAlgorithmFactory.getFullyIncrementalAlgorithm();
-
- syncAlgo.init(fTraces);
-
- assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
- new TmfSyncEventStub(t2, new TmfTimestamp(3)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(2)),
- new TmfSyncEventStub(t2, new TmfTimestamp(5)))
- );
-
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
- new TmfSyncEventStub(t2, new TmfTimestamp(5)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
- new TmfSyncEventStub(t2, new TmfTimestamp(7)))
- );
- assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(7)),
- new TmfSyncEventStub(t1, new TmfTimestamp(6)))
- );
- assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(8)),
- new TmfSyncEventStub(t1, new TmfTimestamp(6)))
- );
- assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
-
- syncAlgo.addMatch(
- new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(10)),
- new TmfSyncEventStub(t1, new TmfTimestamp(8)))
- );
- assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
- assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 2.5 ]]", syncAlgo.toString());
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TimeOffsetTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TimeOffsetTest.java
deleted file mode 100644
index ba10d661d7..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TimeOffsetTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Patrick Tasse - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.synchronization;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
-import org.eclipse.linuxtools.tmf.core.synchronization.TimestampTransformFactory;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-/**
- * Test suite for time offset of traces.
- */
-@SuppressWarnings("javadoc")
-public class TimeOffsetTest {
-
- /** Time-out tests after 20 seconds */
- @Rule
- public TestRule globalTimeout= new Timeout(20000);
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final TmfTestTrace TEST_TRACE = TmfTestTrace.A_TEST_10K;
- private static final String PROJECT = "Test Project";
- private static final String RESOURCE = "Test Resource";
- private static final long ONE_MS = 1000000L;
- private IFile fResource;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT);
- if (!project.exists()) {
- project.create(null);
- }
- project.open(null);
- fResource = project.getFile(RESOURCE);
- if (!fResource.exists()) {
- final InputStream source = new ByteArrayInputStream(new byte[0]);
- fResource.create(source, true, null);
- }
- fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, fResource.getParent().getLocationURI().getPath());
- }
-
- @After
- public void tearDown() throws CoreException {
- if (fResource != null && fResource.exists()) {
- fResource.getProject().delete(true, null);
- }
- }
-
- private ITmfTrace createAndIndexTrace() throws URISyntaxException, IOException, TmfTraceException {
- 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(fResource, testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null);
- trace.indexTrace(true);
- return trace;
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
-
- @Test
- public void testNoOffset() throws URISyntaxException, IOException, TmfTraceException {
- ITmfTrace trace = createAndIndexTrace();
- final TmfContext context = (TmfContext) trace.seekEvent(0);
-
- ITmfEvent event = trace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- event = trace.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testPositiveOffset() throws URISyntaxException, IOException, TmfTraceException {
- ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
- TimestampTransformFactory.setTimestampTransform(fResource, tt);
-
- ITmfTrace trace = createAndIndexTrace();
- final TmfContext context = (TmfContext) trace.seekEvent(0);
-
- ITmfEvent event = trace.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- event = trace.getNext(context);
- assertEquals("Event timestamp", 3, event.getTimestamp().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testNegativeOffset() throws URISyntaxException, IOException, TmfTraceException {
- ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(-ONE_MS);
- TimestampTransformFactory.setTimestampTransform(fResource, tt);
-
- ITmfTrace trace = createAndIndexTrace();
- final TmfContext context = (TmfContext) trace.seekEvent(0);
-
- ITmfEvent event = trace.getNext(context);
- assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
- event = trace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testClearOffset() throws URISyntaxException, IOException, TmfTraceException {
- ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
- TimestampTransformFactory.setTimestampTransform(fResource, tt);
- TimestampTransformFactory.setTimestampTransform(fResource, null);
-
- ITmfTrace trace = createAndIndexTrace();
- final TmfContext context = (TmfContext) trace.seekEvent(0);
-
- ITmfEvent event = trace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- event = trace.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-
- trace.dispose();
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformFactoryTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformFactoryTest.java
deleted file mode 100644
index 1ab11c3b7f..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformFactoryTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Matthew Khouzam - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.synchronization;
-
-import static org.junit.Assert.assertEquals;
-
-import java.math.BigDecimal;
-
-import org.eclipse.linuxtools.internal.tmf.core.synchronization.TmfConstantTransform;
-import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
-import org.eclipse.linuxtools.tmf.core.synchronization.TimestampTransformFactory;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Timestamp transform tests
- *
- * @author Matthew Khouzam
- *
- */
-public class TsTransformFactoryTest {
- private final ITmfTimestamp t0 = new TmfTimestamp(0);
- private final ITmfTimestamp t100 = new TmfTimestamp(100);
- private final ITmfTimestamp t1e2 = new TmfTimestamp(1, 2);
- private final ITmfTimestamp t1e3 = new TmfTimestamp(1, 3);
- private final ITmfTimestamp tn0 = new TmfNanoTimestamp(0);
- private final ITmfTimestamp tn100 = new TmfNanoTimestamp(100);
- private final ITmfTimestamp tn1 = new TmfNanoTimestamp(1);
- private final ITmfTimestampTransform identity1 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(0));
- private final ITmfTimestampTransform offset1 = TimestampTransformFactory.createWithOffset(100);
- private final ITmfTimestampTransform offset2 = TimestampTransformFactory.createLinear(BigDecimal.ONE, new BigDecimal(100));
- private final ITmfTimestampTransform offset3 = TimestampTransformFactory.createLinear(1.0, 100);
- private final ITmfTimestampTransform offset4 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(100));
-
- /**
- * Test with identity
- */
- @Test
- public void transformIdenity() {
- final ITmfTimestampTransform identity = TimestampTransformFactory.createWithOffset(0);
- final ITmfTimestampTransform innefficientIdentity = new TmfConstantTransform();
- final ITmfTimestampTransform compositeInnefficientIdentity = identity.composeWith(innefficientIdentity);
- final ITmfTimestampTransform compositeInnefficientIdentity2 = innefficientIdentity.composeWith(innefficientIdentity);
- final ITmfTimestampTransform compositeInnefficientIdentity3 = innefficientIdentity.composeWith(identity);
- assertEquals(t0, identity.transform(t0));
- assertEquals(tn0, identity.transform(tn0));
- assertEquals(t100, identity.transform(t100));
- assertEquals(t1e2, identity.transform(t100));
- assertEquals(t1e2, identity.transform(t1e2));
- assertEquals(t1e3, identity.transform(t1e3));
- assertEquals(tn100, identity.transform(tn100));
- assertEquals(t0, innefficientIdentity.transform(t0)); // bad practice
- assertEquals(t0, compositeInnefficientIdentity.transform(t0)); // bad
- // practice
- assertEquals(t0, compositeInnefficientIdentity2.transform(t0)); // bad
- // practice
- assertEquals(t0, compositeInnefficientIdentity3.transform(t0)); // bad
- // practice
- }
-
- /**
- * Test with an offset of 100
- */
- @Test
- public void transformOffset() {
- final ITmfTimestampTransform offset = offset1;
- final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.createWithOffset(new TmfNanoTimestamp(-100)));
- assertEquals(tn100, offset.transform(t0));
- assertEquals(tn100, offset.transform(tn0));
- assertEquals(tn0, compositeTransform.transform(tn0));
- assertEquals(t0, compositeTransform.transform(t0));
- assertEquals(200, offset1.transform(100));
- assertEquals(200, offset2.transform(100));
- assertEquals(200, offset3.transform(100));
- assertEquals(200, offset4.transform(100));
- }
-
- /**
- * Test with a slope
- */
- @Test
- public void transformSlope() {
- final ITmfTimestampTransform slope = TimestampTransformFactory.createLinear(10, 0);
- final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, new TmfNanoTimestamp(0));
- assertEquals(t1e3, slope.transform(t1e2));
- assertEquals(tn100, slope.transform(new TmfNanoTimestamp(10)));
- assertEquals(tn100, slope.transform(slope.transform(tn1)));
- assertEquals(tn100, slope.composeWith(slope).transform(tn1));
- assertEquals(tn100, slope1.transform(new TmfNanoTimestamp(10)));
- }
-
- /**
- * Test toStrings
- */
- @Test
- public void testToString() {
- final String expectedLinear = "TmfTimestampLinear [ slope = 314.0, offset = 0.0 ]";
- final String expectedLinearBigDec = "TmfTimestampLinear [ slope = 314, offset = 0 ]";
- final String expectedOffset = "TmfConstantTransform [ offset = 314 ]";
- final String expectedIdentity = "TmfTimestampTransform [ IDENTITY ]";
- final String expectedOffset100 = "TmfConstantTransform [ offset = 100 ]";
- assertEquals(expectedLinear, TimestampTransformFactory.createLinear(314, 0).toString());
- assertEquals(expectedLinearBigDec, TimestampTransformFactory.createLinear(BigDecimal.valueOf(314), BigDecimal.ZERO).toString());
- assertEquals(expectedOffset, TimestampTransformFactory.createLinear(1, 314).toString());
- assertEquals(expectedOffset, TimestampTransformFactory.createWithOffset(314).toString());
- assertEquals(expectedOffset, TimestampTransformFactory.createWithOffset(14).composeWith(TimestampTransformFactory.createWithOffset(300)).toString());
- assertEquals(expectedIdentity, TimestampTransformFactory.createWithOffset(314).composeWith(TimestampTransformFactory.createWithOffset(-314)).toString());
- assertEquals(expectedIdentity, TimestampTransformFactory.createWithOffset(0).toString());
- assertEquals(expectedIdentity, identity1.toString());
- assertEquals(expectedOffset100, offset1.toString());
- assertEquals(expectedOffset100, offset2.toString());
- assertEquals(expectedOffset100, offset3.toString());
- assertEquals(expectedOffset100, offset4.toString());
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformTest.java
deleted file mode 100644
index 3d355ba147..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/synchronization/TsTransformTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.synchronization;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.linuxtools.internal.tmf.core.synchronization.TmfTimestampTransform;
-import org.eclipse.linuxtools.internal.tmf.core.synchronization.TmfTimestampTransformLinear;
-import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Tests for {@link TmfTimestampTransform} and its descendants
- *
- * @author Geneviève Bastien
- */
-@SuppressWarnings("nls")
-public class TsTransformTest {
-
- private long ts = 1361657893526374091L;
- private ITmfTimestamp oTs = new TmfTimestamp(ts);
-
- /**
- * Test the linear transform
- */
- @Test
- public void testLinearTransform() {
- /* Default constructor */
- TmfTimestampTransformLinear ttl = new TmfTimestampTransformLinear();
- assertEquals(1361657893526374091L, ttl.transform(ts));
- assertEquals(1361657893526374091L, ttl.transform(oTs).getValue());
-
- /* Just an offset */
- ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(1.0), BigDecimal.valueOf(3));
- assertEquals(1361657893526374094L, ttl.transform(ts));
- assertEquals(1361657893526374094L, ttl.transform(oTs).getValue());
-
- /* Just a slope */
- ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(0));
- assertEquals(2723315787052748182L, ttl.transform(ts));
- assertEquals(2723315787052748182L, ttl.transform(oTs).getValue());
-
- /* Offset and slope */
- ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
- assertEquals(2723315787052748185L, ttl.transform(ts));
- assertEquals(2723315787052748185L, ttl.transform(oTs).getValue());
-
- /* Offset and slope */
- ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(0.5), BigDecimal.valueOf(0));
- assertEquals(680828946763187045L, ttl.transform(ts));
- assertEquals(680828946763187045L, ttl.transform(oTs).getValue());
- }
-
- /**
- * Test for the identity transform
- */
- @Test
- public void testIdentityTransform() {
- ITmfTimestampTransform tt = TmfTimestampTransform.IDENTITY;
- assertEquals(ts, tt.transform(ts));
- assertEquals(oTs, tt.transform(oTs));
- }
-
- /**
- * Test hash and equals function
- */
- @Test
- public void testEquality() {
- Map<ITmfTimestampTransform, String> map = new HashMap<>();
- ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
- ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
- ITmfTimestampTransform ttl3 = new TmfTimestampTransformLinear(BigDecimal.valueOf(3), BigDecimal.valueOf(3));
- assertEquals(ttl, ttl2);
- assertFalse(ttl.equals(ttl3));
- assertFalse(ttl2.equals(ttl3));
-
- map.put(ttl, "a");
- assertTrue(map.containsKey(ttl2));
- assertEquals("a", map.get(ttl));
-
- ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
- assertEquals(TmfTimestampTransform.IDENTITY, ti);
- assertFalse(TmfTimestampTransform.IDENTITY.equals(ttl));
-
- map.put(ti, "b");
- assertTrue(map.containsKey(TmfTimestampTransform.IDENTITY));
- assertEquals("b", map.get(ti));
-
- assertFalse(ti.equals(ttl));
- assertFalse(ttl.equals(ti));
-
- }
-
- /**
- * Test the transform composition function
- */
- @Test
- public void testComposition() {
- long t = 100;
- ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
- ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
- ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(1.5), BigDecimal.valueOf(8));
-
- ITmfTimestampTransform tc1 = ti.composeWith(ttl);
- /* Should be ttl */
- assertEquals(ttl, tc1);
- assertEquals(203, tc1.transform(t));
-
- tc1 = ttl.composeWith(ti);
- /* Should be ttl also */
- assertEquals(ttl, tc1);
- assertEquals(203, tc1.transform(t));
-
- tc1 = ti.composeWith(ti);
- /* Should be identity */
- assertEquals(tc1, TmfTimestampTransform.IDENTITY);
- assertEquals(100, tc1.transform(t));
-
- tc1 = ttl.composeWith(ttl2);
- assertEquals(ttl.transform(ttl2.transform(t)), tc1.transform(t));
- assertEquals(319, tc1.transform(t));
-
- tc1 = ttl2.composeWith(ttl);
- assertEquals(ttl2.transform(ttl.transform(t)), tc1.transform(t));
- assertEquals(312, tc1.transform(t));
-
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java
deleted file mode 100644
index 657ce1b761..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.trace
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfContextTest.class,
- TmfExperimentTest.class,
- TmfMultiTraceExperimentTest.class,
- TmfTraceTest.class
-})
-public class AllTests {} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java
deleted file mode 100644
index e5f76dc206..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for removal of context clone
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfContext class.
- */
-@SuppressWarnings("javadoc")
-public class TmfContextTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final Long aLong = 12345L;
- private final TmfTimestamp aTimestamp = new TmfTimestamp();
-
- private final TmfLongLocation fLocation1 = new TmfLongLocation(aLong);
- private final TmfTimestampLocation fLocation2 = new TmfTimestampLocation(aTimestamp);
-
- private final long fRank1 = 1;
- private final long fRank2 = 2;
-
- private final TmfContext fContext1 = new TmfContext(fLocation1, fRank1);
- private final TmfContext fContext2 = new TmfContext(fLocation2, fRank2);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfContextDefault() {
- final TmfContext context = new TmfContext();
- assertEquals("getLocation", null, context.getLocation());
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- @Test
- public void testTmfContextNoRank() {
- final TmfContext context1 = new TmfContext(fLocation1);
- final TmfContext context2 = new TmfContext(fLocation2);
-
- assertEquals("getLocation", fLocation1, context1.getLocation());
- assertEquals("getLocation", fLocation2, context2.getLocation());
-
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context2.getRank());
- }
-
- @Test
- public void testTmfContext() {
- assertEquals("getLocation", fLocation1, fContext1.getLocation());
- assertEquals("getLocation", fLocation2, fContext2.getLocation());
-
- assertEquals("getRank", fRank1, fContext1.getRank());
- assertEquals("getRank", fRank2, fContext2.getRank());
- }
-
- @Test
- public void testTmfContextCopy() {
- final TmfContext context1 = new TmfContext(fContext1);
- final TmfContext context2 = new TmfContext(fContext2);
-
- assertEquals("getLocation", fLocation1, context1.getLocation());
- assertEquals("getLocation", fLocation2, context2.getLocation());
-
- assertEquals("getRank", fRank1, context1.getRank());
- assertEquals("getRank", fRank2, context2.getRank());
- }
-
- @Test
- public void testTmfContextCopy2() {
- try {
- new TmfContext((TmfContext) null);
- fail("Copy constructor: no exception");
- }
- catch (final IllegalArgumentException e) {
- // pass
- }
- catch (final Exception e) {
- fail("Copy constructor: wrong exception");
- }
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fContext1.equals(fContext1));
- assertTrue("equals", fContext2.equals(fContext2));
-
- assertFalse("equals", fContext1.equals(fContext2));
- assertFalse("equals", fContext2.equals(fContext1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfContext context1 = new TmfContext(fContext1);
- final TmfContext context2 = new TmfContext(fContext2);
-
- assertTrue("equals", context1.equals(fContext1));
- assertTrue("equals", fContext1.equals(context1));
-
- assertTrue("equals", context2.equals(fContext2));
- assertTrue("equals", fContext2.equals(context2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final TmfContext context1 = new TmfContext(fContext1);
- final TmfContext context2 = new TmfContext(context1);
- final TmfContext context3 = new TmfContext(context2);
-
- assertTrue("equals", context1.equals(context2));
- assertTrue("equals", context2.equals(context3));
- assertTrue("equals", context1.equals(context3));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fContext1.equals(null));
- assertFalse("equals", fContext2.equals(null));
- }
-
- private static class MyContext extends TmfContext {
- }
-
- @Test
- public void testNonEquals() {
-
- // Different classes
- final MyContext myContext = new MyContext();
- assertFalse("equals", fContext1.equals(myContext));
- assertFalse("equals", myContext.equals(fContext1));
-
- // Different locations
- TmfContext context1 = new TmfContext(fContext1);
- TmfContext context2 = new TmfContext(fContext1);
- context1.setLocation(null);
- context2.setLocation(null);
-
- assertFalse("equals", fContext1.equals(context1));
- assertFalse("equals", context1.equals(fContext1));
- assertTrue("equals", context1.equals(context2));
-
- // Different ranks
- context1 = new TmfContext(fContext1);
- context2 = new TmfContext(fContext1);
- context1.setRank(fContext1.getRank() + 1);
- context2.setRank(fContext1.getRank() + 2);
-
- assertFalse("equals", fContext1.equals(context1));
- assertFalse("equals", context1.equals(fContext1));
- assertFalse("equals", context1.equals(context2));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TmfContext context1 = new TmfContext(fContext1);
- final TmfContext context2 = new TmfContext(fContext2);
-
- assertEquals("hashCode", fContext1.hashCode(), context1.hashCode());
- assertEquals("hashCode", fContext2.hashCode(), context2.hashCode());
-
- assertFalse("hashCode", fContext1.hashCode() == context2.hashCode());
- assertFalse("hashCode", fContext2.hashCode() == context1.hashCode());
-
- final TmfContext nullContext1 = new TmfContext();
- final TmfContext nullContext2 = new TmfContext(nullContext1);
- assertEquals("hashCode", nullContext1.hashCode(), nullContext2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfContext [fLocation=" + fLocation1 + ", fRank=" + fRank1 + "]";
- final String expected2 = "TmfContext [fLocation=" + fLocation2 + ", fRank=" + fRank2 + "]";
-
- assertEquals("toString", expected1, fContext1.toString());
- assertEquals("toString", expected2, fContext2.toString());
- }
-
- // ------------------------------------------------------------------------
- // setLocation, setRank, updateRank
- // ------------------------------------------------------------------------
-
- @Test
- public void testSetLocation() {
- final TmfContext context1 = new TmfContext(fContext1);
- context1.setLocation(fContext2.getLocation());
-
- assertEquals("getLocation", fLocation2, context1.getLocation());
- assertEquals("getRank", fRank1, context1.getRank());
- }
-
- @Test
- public void testSetRank() {
- final TmfContext context1 = new TmfContext(fContext1);
- context1.setRank(fContext2.getRank());
-
- assertEquals("getLocation", fLocation1, context1.getLocation());
- assertEquals("getRank", fRank2, context1.getRank());
- }
-
- @Test
- public void testIncreaseRank() {
- final TmfContext context1 = new TmfContext(fContext1);
-
- context1.increaseRank();
- assertEquals("getRank", fRank1 + 1, context1.getRank());
- context1.increaseRank();
- assertEquals("getRank", fRank1 + 2, context1.getRank());
-
- context1.setRank(ITmfContext.UNKNOWN_RANK);
- context1.increaseRank();
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
- context1.increaseRank();
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java
deleted file mode 100644
index a8635e6592..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java
+++ /dev/null
@@ -1,941 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 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
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for rank in experiment location
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Vector;
-
-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.internal.tmf.core.trace.TmfExperimentLocation;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestExperimentAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfExperiment class (single trace).
- */
-@SuppressWarnings("javadoc")
-public class TmfExperimentTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static final String EXPERIMENT = "MyExperiment";
- private static int NB_EVENTS = 10000;
- private static int BLOCK_SIZE = 1000;
-
- private static final double DELTA = 1e-15;
-
- private ITmfTrace[] fTestTraces;
- private TmfExperimentStub fExperiment;
-
- private static byte SCALE = (byte) -3;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- private synchronized ITmfTrace[] setupTrace(final String path) {
- if (fTestTraces == null) {
- fTestTraces = new ITmfTrace[1];
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true, null);
- fTestTraces[0] = trace;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
- return fTestTraces;
- }
-
- private synchronized void setupExperiment() {
- if (fExperiment == null) {
- fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
- fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- }
- }
-
- @Before
- public void setUp() {
- setupTrace(TmfTestTrace.A_TEST_10K.getFullPath());
- setupExperiment();
- }
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- @Test
- public void testSimpleTmfExperimentConstructor() {
- TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, fTestTraces);
- assertEquals("GetId", EXPERIMENT, experiment.getName());
- assertEquals("GetCacheSize", TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, experiment.getCacheSize());
- experiment.dispose();
-
- experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, null);
- experiment.dispose();
- }
-
- @Test
- public void testNormalTmfExperimentConstructor() {
- assertEquals("GetId", EXPERIMENT, fExperiment.getName());
- assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
-
- final long nbExperimentEvents = fExperiment.getNbEvents();
- assertEquals("GetNbEvents", NB_EVENTS, nbExperimentEvents);
-
- final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
- assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
-
- final TmfTimeRange timeRange = fExperiment.getTimeRange();
- assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
- }
-
- // ------------------------------------------------------------------------
- // Experiment setup
- // ------------------------------------------------------------------------
-
- @Test
- public void testExperimentInitialization() {
- /*
- * Calling default constructor, then init should be equivalent to
- * calling the full constructor
- */
-
- TmfExperimentStub experiment = new TmfExperimentStub();
- experiment.initExperiment(ITmfEvent.class, EXPERIMENT, fTestTraces, 5000, null);
- experiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
-
- assertEquals("GetId", EXPERIMENT, fExperiment.getName());
- assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
-
- final long nbExperimentEvents = fExperiment.getNbEvents();
- assertEquals("GetNbEvents", NB_EVENTS, nbExperimentEvents);
-
- final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
- assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
-
- final TmfTimeRange timeRange = fExperiment.getTimeRange();
- assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
- }
-
- // ------------------------------------------------------------------------
- // getTimestamp
- // ------------------------------------------------------------------------
-
- @Test
- 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));
- assertNull("getTimestamp", fExperiment.getTimestamp(10000));
- }
-
- // ------------------------------------------------------------------------
- // State system, statistics and modules methods
- // ------------------------------------------------------------------------
-
- @Test
- public void testGetAnalysisModules() {
- /* There should not be any modules at this point */
- Iterable<IAnalysisModule> modules = fExperiment.getAnalysisModules();
- assertFalse(modules.iterator().hasNext());
-
- /* Open the experiment, the modules should be populated */
- fExperiment.traceOpened(new TmfTraceOpenedSignal(this, fExperiment, null));
- modules = fExperiment.getAnalysisModules();
- Iterable<TestExperimentAnalysis> testModules = fExperiment.getAnalysisModulesOfClass(TestExperimentAnalysis.class);
- assertTrue(modules.iterator().hasNext());
- assertTrue(testModules.iterator().hasNext());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent by location
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekBadLocation() {
- ITmfContext context = fExperiment.seekEvent(new TmfLongLocation(0L));
- assertNull("seekEvent", context);
- }
-
- @Test
- public void testSeekNoTrace() {
- TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, null);
- ITmfContext context = experiment.seekEvent((TmfExperimentLocation) null);
- assertNull("seekEvent", context);
- experiment.dispose();
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on ratio
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekEventOnRatio() {
- // First event
- ITmfContext context = fExperiment.seekEvent(0.0);
- assertEquals("Context rank", 0, context.getRank());
- ITmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 0, context.getRank());
-
- // Middle event
- int midTrace = NB_EVENTS / 2;
- context = fExperiment.seekEvent(0.5);
- assertEquals("Context rank", midTrace, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", midTrace + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", midTrace, context.getRank());
-
- // Last event
- context = fExperiment.seekEvent(1.0);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertNull("Event timestamp", event);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
-
- // Beyond last event
- context = fExperiment.seekEvent(1.1);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertNull("Event timestamp", event);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
-
- // Negative ratio
- context = fExperiment.seekEvent(-0.5);
- assertEquals("Context rank", 0, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 0, context.getRank());
- }
-
- @Test
- public void testGetLocationRatio() {
- // First event
- ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
- double ratio = fExperiment.getLocationRatio(context.getLocation());
- assertEquals("getLocationRatio", 0.0, ratio, DELTA);
-
- // Middle event
- context = fExperiment.seekEvent(NB_EVENTS / 2);
- ratio = fExperiment.getLocationRatio(context.getLocation());
- assertEquals("getLocationRatio", (double) (NB_EVENTS / 2) / NB_EVENTS, ratio, DELTA);
-
- // Last event
- context = fExperiment.seekEvent(NB_EVENTS - 1);
- ratio = fExperiment.getLocationRatio(context.getLocation());
- assertEquals("getLocationRatio", (double) (NB_EVENTS - 1) / NB_EVENTS, ratio, DELTA);
- }
-
-// @SuppressWarnings("rawtypes")
-// public void testGetCurrentLocation() {
-// ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
-// ITmfLocation location = fExperiment.getCurrentLocation();
-// assertEquals("getCurrentLocation", location, context.getLocation());
-// }
-
- // ------------------------------------------------------------------------
- // seekEvent on rank
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekRankOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // On lower bound, returns the first event (TS = 1)
- ITmfContext context = fExperiment.seekEvent(0);
- assertEquals("Context rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(cacheSize);
- assertEquals("Context rank", cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- // Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(4 * cacheSize);
- assertEquals("Context rank", 4 * cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
- }
-
- @Test
- public void testSeekRankNotOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 9
- ITmfContext context = fExperiment.seekEvent(9);
- assertEquals("Context rank", 9, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Context rank", 10, context.getRank());
-
- // Position trace at event rank [cacheSize - 1]
- context = fExperiment.seekEvent(cacheSize - 1);
- assertEquals("Context rank", cacheSize - 1, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize, context.getRank());
-
- // Position trace at event rank [cacheSize + 1]
- context = fExperiment.seekEvent(cacheSize + 1);
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 2, context.getRank());
-
- // Position trace at event rank 4500
- context = fExperiment.seekEvent(4500);
- assertEquals("Context rank", 4500, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Context rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekRankOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(-1);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fExperiment.seekEvent(NB_EVENTS);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
-
- event = fExperiment.getNext(context);
- assertNull("Event", event);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on timestamp
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekTimestampOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 0
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
- assertEquals("Context rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE, 0));
- assertEquals("Event rank", cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- // Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE, 0));
- assertEquals("Context rank", 4 * cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
- }
-
- @Test
- public void testSeekTimestampNotOnCacheBoundary() {
- // Position trace at event rank 1 (TS = 2)
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
- assertEquals("Context rank", 1, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Context rank", 2, context.getRank());
-
- // Position trace at event rank 9 (TS = 10)
- context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- assertEquals("Context rank", 9, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Context rank", 10, context.getRank());
-
- // Position trace at event rank 999 (TS = 1000)
- context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- assertEquals("Context rank", 999, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Context rank", 1000, context.getRank());
-
- // Position trace at event rank 1001 (TS = 1002)
- context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- assertEquals("Context rank", 1001, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Context rank", 1002, context.getRank());
-
- // Position trace at event rank 4500 (TS = 4501)
- context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- assertEquals("Context rank", 4500, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Context rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekTimestampOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- event = fExperiment.getNext(context);
- assertNull("Event location", event);
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent by location (context rank is undefined)
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekLocationOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 0
- ITmfContext tmpContext = fExperiment.seekEvent(0);
- ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-
- // Position trace at event rank 'cacheSize'
- tmpContext = fExperiment.seekEvent(cacheSize);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
-
- // Position trace at event rank 4 * 'cacheSize'
- tmpContext = fExperiment.seekEvent(4 * cacheSize);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
- }
-
- @Test
- public void testSeekLocationNotOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event 'cacheSize' - 1
- ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1);
- ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
-
- // Position trace at event rank 2 * 'cacheSize' - 1
- tmpContext = fExperiment.seekEvent(2 * cacheSize - 1);
- context = fExperiment.seekEvent(tmpContext.getLocation());
- context = fExperiment.seekEvent(2 * cacheSize - 1);
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue());
-
- // Position trace at event rank 4500
- tmpContext = fExperiment.seekEvent(4500);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
- }
-
- @Test
- public void testSeekLocationOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- }
-
- // ------------------------------------------------------------------------
- // getNext - updates the context
- // ------------------------------------------------------------------------
-
- private static void validateContextRanks(ITmfContext context) {
- assertTrue("Experiment context type", context instanceof TmfExperimentContext);
- TmfExperimentContext ctx = (TmfExperimentContext) context;
-
- int nbTraces = ctx.getNbTraces();
-
- // 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++) {
- ITmfContext subContext = ctx.getContext(i);
- assertNotNull(subContext);
- long rank = subContext.getRank();
- if (rank == -1) {
- expRank = -1;
- break;
- }
- expRank += rank;
- }
- assertEquals("Experiment context rank", expRank, ctx.getRank());
- }
-
- @Test
- 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));
-
- 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);
- }
-
- @Test
- 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", 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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());
- }
-
- @Test
- 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
- // ------------------------------------------------------------------------
-
- @Test
- public void testProcessRequestForNbEvents() throws InterruptedException {
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessRequestForAllEvents() throws InterruptedException {
- final int nbEvents = ITmfEventRequest.ALL_DATA;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
- final long nbExpectedEvents = NB_EVENTS;
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbExpectedEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() throws InterruptedException {
- final int nbEvents = NB_EVENTS;
- final int limit = BLOCK_SIZE;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- int nbRead = 0;
-
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- if (++nbRead == limit) {
- cancel();
- }
- }
-
- @Override
- public void handleCancel() {
- if (requestedEvents.size() < limit) {
- System.out.println("aie");
- }
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", limit, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isCancelled", request.isCancelled());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
deleted file mode 100644
index f4731c0eba..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
+++ /dev/null
@@ -1,814 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Fix for concurrency
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Vector;
-
-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.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-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;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfExperiment class (multiple traces).
- */
-@SuppressWarnings("javadoc")
-public class TmfMultiTraceExperimentTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
- private static final String EXPERIMENT = "MyExperiment";
- private static int NB_EVENTS = 20000;
- private static int BLOCK_SIZE = 1000;
-
- private static TmfExperimentStub fExperiment;
-
- private static byte SCALE = (byte) -3;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @BeforeClass
- public static void setUp() {
- ITmfTrace[] traces = setupTraces();
- fExperiment = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE);
- fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- }
-
- @AfterClass
- public static void tearDown() {
- fExperiment.dispose();
- }
-
- private static ITmfTrace[] setupTraces() {
- try {
- ITmfTrace[] traces = new ITmfTrace[2];
-
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TmfTestTrace.O_TEST_10K.getFullPath()), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null);
- traces[0] = trace1;
-
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TmfTestTrace.E_TEST_10K.getFullPath()), null);
- test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null);
- traces[1] = trace2;
-
- return traces;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- return new ITmfTrace[0];
- }
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- @Test
- public void testBasicTmfExperimentConstructor() {
- assertEquals("GetId", EXPERIMENT, fExperiment.getName());
- assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
-
- final TmfTimeRange timeRange = fExperiment.getTimeRange();
- assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
-
- TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on rank
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekRankOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // On lower bound, returns the first event (TS = 1)
- ITmfContext context = fExperiment.seekEvent(0);
- assertEquals("Context rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(cacheSize);
- assertEquals("Context rank", cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- // Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(4 * cacheSize);
- assertEquals("Context rank", 4 * cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
- }
-
- @Test
- public void testSeekRankNotOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 9
- ITmfContext context = fExperiment.seekEvent(9);
- assertEquals("Context rank", 9, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Context rank", 10, context.getRank());
-
- // Position trace at event rank [cacheSize - 1]
- context = fExperiment.seekEvent(cacheSize - 1);
- assertEquals("Context rank", cacheSize - 1, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize, context.getRank());
-
- // Position trace at event rank [cacheSize + 1]
- context = fExperiment.seekEvent(cacheSize + 1);
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 2, context.getRank());
-
- // Position trace at event rank 4500
- context = fExperiment.seekEvent(4500);
- assertEquals("Context rank", 4500, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Context rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekRankOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(-1);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fExperiment.seekEvent(NB_EVENTS);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
-
- event = fExperiment.getNext(context);
- assertNull("Event", event);
- assertEquals("Context rank", NB_EVENTS, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on timestamp
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekTimestampOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 0
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
- assertEquals("Context rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 1, context.getRank());
-
- // Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE, 0));
- assertEquals("Event rank", cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", cacheSize + 1, context.getRank());
-
- // Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE, 0));
- assertEquals("Context rank", 4 * cacheSize, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
- assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
- }
-
- @Test
- public void testSeekTimestampNotOnCacheBoundary() {
- // Position trace at event rank 1 (TS = 2)
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
- assertEquals("Context rank", 1, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Context rank", 2, context.getRank());
-
- // Position trace at event rank 9 (TS = 10)
- context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- assertEquals("Context rank", 9, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Context rank", 10, context.getRank());
-
- // Position trace at event rank 999 (TS = 1000)
- context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- assertEquals("Context rank", 999, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Context rank", 1000, context.getRank());
-
- // Position trace at event rank 1001 (TS = 1002)
- context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- assertEquals("Context rank", 1001, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Context rank", 1002, context.getRank());
-
- // Position trace at event rank 4500 (TS = 4501)
- context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- assertEquals("Context rank", 4500, context.getRank());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Context rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekTimestampOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- event = fExperiment.getNext(context);
- assertNull("Event location", event);
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent by location (context rank is undefined)
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekLocationOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event rank 0
- ITmfContext tmpContext = fExperiment.seekEvent(0);
- ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-
- // Position trace at event rank 'cacheSize'
- tmpContext = fExperiment.seekEvent(cacheSize);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
-
- // Position trace at event rank 4 * 'cacheSize'
- tmpContext = fExperiment.seekEvent(4 * cacheSize);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
- }
-
- @Test
- public void testSeekLocationNotOnCacheBoundary() {
- long cacheSize = fExperiment.getCacheSize();
-
- // Position trace at event 'cacheSize' - 1
- ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1);
- ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
-
- // Position trace at event rank 2 * 'cacheSize' - 1
- tmpContext = fExperiment.seekEvent(2 * cacheSize - 1);
- context = fExperiment.seekEvent(tmpContext.getLocation());
- context = fExperiment.seekEvent(2 * cacheSize - 1);
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue());
-
- // Position trace at event rank 4500
- tmpContext = fExperiment.seekEvent(4500);
- context = fExperiment.seekEvent(tmpContext.getLocation());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-
- event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
- }
-
- @Test
- public void testSeekLocationOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
-
- ITmfEvent event = fExperiment.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- }
-
- // ------------------------------------------------------------------------
- // getNext - updates the context
- // ------------------------------------------------------------------------
-
- private static void validateContextRanks(ITmfContext context) {
- assertTrue("Experiment context type", context instanceof TmfExperimentContext);
- TmfExperimentContext ctx = (TmfExperimentContext) context;
-
- int nbTraces = ctx.getNbTraces();
-
- // 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++) {
- ITmfContext subContext = ctx.getContext(i);
- assertNotNull(subContext);
- long rank = subContext.getRank();
- if (rank == -1) {
- expRank = -1;
- break;
- }
- expRank += rank;
- }
- assertEquals("Experiment context rank", expRank, ctx.getRank());
- }
-
- @Test
- 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));
-
- 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);
- }
-
- @Test
- 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", 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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);
- }
-
- @Test
- 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());
- }
-
- @Test
- 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
- // ------------------------------------------------------------------------
-
- @Test
- public void testProcessRequestForNbEvents() throws InterruptedException {
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessRequestForAllEvents() throws InterruptedException {
- final int nbEvents = ITmfEventRequest.ALL_DATA;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
- final long nbExpectedEvents = NB_EVENTS;
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbExpectedEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() throws InterruptedException {
- final int nbEvents = NB_EVENTS;
- final int limit = BLOCK_SIZE;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- int nbRead = 0;
-
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- if (++nbRead == limit) {
- cancel();
- }
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", limit, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isCancelled", request.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // getTimestamp
- // ------------------------------------------------------------------------
-
- @Test
- 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));
- }
-
- // ------------------------------------------------------------------------
- // getInitialRangeOffset, getCurrentRange, getCurrentTime
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultCurrentTimeValues() {
- ITmfTrace[] traces = setupTraces();
- TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE);
-
- // verify initial values
- TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
-
- exp.dispose();
- }
-
- @Test
- public void testInitialRangeOffset() {
- ITmfTrace[] traces = setupTraces();
- ((TmfTraceStub) traces[0]).setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
- ((TmfTraceStub) traces[1]).setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE));
- TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE);
-
- TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
-
- exp.dispose();
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
deleted file mode 100644
index fa46b548a8..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
+++ /dev/null
@@ -1,1389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
-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;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-/**
- * Test suite for the TmfTrace class.
- */
-@SuppressWarnings("javadoc")
-public class TmfTraceTest {
-
- /** Time-out tests after 20 seconds */
- @Rule
- public TestRule globalTimeout= new Timeout(20000);
-
- // ------------------------------------------------------------------------
- // 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 int NB_EVENTS = 10000;
- private TmfTraceStub fTrace = null;
-
- private static int SCALE = -3;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null);
- TmfSignalManager.deregister(fTrace);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testFullConstructor() throws TmfTraceException {
- try {
- 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);
- trace.indexTrace(true);
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
- }
-
- @Test
- public void testLiveTraceConstructor() throws TmfTraceException {
- final long interval = 100;
- try {
- 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("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
- assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
- }
-
- @Test
- public void testCopyConstructor() throws TmfTraceException {
- try {
- 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, null);
- TmfTraceStub trace = new TmfTraceStub(original);
- trace.indexTrace(true);
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
-
- // Test the copy of a null trace
- try {
- new TmfTraceStub((TmfTraceStub) null);
- fail("Missing exception");
- } catch (final IllegalArgumentException e) {
- // test passed
- } catch (final Exception e) {
- fail("Unexpected exception");
- }
- }
-
- // ------------------------------------------------------------------------
- // Trace initialization
- // ------------------------------------------------------------------------
-
- @Test
- public void testInitializeNullPath() {
- // Instantiate an "empty" trace
- final TmfTraceStub trace = new TmfTraceStub();
-
- try {
- trace.initialize(null, null, ITmfEvent.class);
- fail("TmfTrace.initialize() - no exception thrown");
- } catch (TmfTraceException e) {
- // Success
- } catch (Exception e) {
- fail("TmfTrace.initialize() - wrong exception thrown");
- }
- }
-
- @Test
- public void testInitializeSimplePath() {
- // Instantiate an "empty" trace
- final TmfTraceStub trace = new TmfTraceStub();
-
- // Path == trace name
- String path = "TraceName";
- try {
- trace.initialize(null, path, ITmfEvent.class);
- } catch (Exception e) {
- fail("TmfTrace.initialize() - Exception thrown");
- }
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull ("getResource", trace.getResource());
- assertEquals("getPath", path, trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", path, trace.getName());
-
- assertEquals("getNbEvents", 0, trace.getNbEvents());
- assertEquals("getRange-start", Long.MIN_VALUE, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", Long.MIN_VALUE, trace.getStartTime().getValue());
- assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
- }
-
- @Test
- public void testInitializeNormalPath() {
- // Instantiate an "empty" trace
- final TmfTraceStub trace = new TmfTraceStub();
-
- // Path == trace name
- String name = "TraceName";
- String path = "/my/trace/path/" + name;
- try {
- trace.initialize(null, path, ITmfEvent.class);
- } catch (Exception e) {
- fail("TmfTrace.initialize() - Exception thrown");
- }
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull ("getResource", trace.getResource());
- assertEquals("getPath", path, trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", name, trace.getName());
-
- assertEquals("getNbEvents", 0, trace.getNbEvents());
- assertEquals("getRange-start", Long.MIN_VALUE, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", Long.MIN_VALUE, trace.getStartTime().getValue());
- assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
- }
-
- @Test
- public void testInitTrace() throws URISyntaxException, IOException, TmfTraceException, InterruptedException {
- // Instantiate an "empty" trace
- final TmfTraceStub trace = new TmfTraceStub();
-
- assertNull ("getType", trace.getType());
- assertNull ("getResource", trace.getResource());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", "", trace.getName());
-
- assertEquals("getNbEvents", 0, trace.getNbEvents());
- assertEquals("getRange-start", Long.MIN_VALUE, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", Long.MIN_VALUE, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", Long.MIN_VALUE, trace.getStartTime().getValue());
- assertEquals("getEndTime", Long.MIN_VALUE, trace.getEndTime().getValue());
-
- // Validate
- 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());
-
- // InitTrace and wait for indexing completion...
- trace.initTrace(null, testfile.toURI().getPath(), ITmfEvent.class);
- trace.indexTrace(true);
- int nbSecs = 0;
- while (trace.getNbEvents() < NB_EVENTS && nbSecs < 10) {
- Thread.sleep(1000);
- nbSecs++;
- }
- if (trace.getNbEvents() < NB_EVENTS) {
- fail("indexing");
- }
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull ("getResource", trace.getResource());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_TRACE.getPath(), trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
- }
-
- // ------------------------------------------------------------------------
- // Set/Get streaming interval
- // ------------------------------------------------------------------------
-
- @Test
- public void testSetStreamingInterval() throws TmfTraceException {
- final TmfTraceStub trace = new TmfTraceStub(fTrace);
-
- long interval = 0;
- assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
-
- interval = 100;
- trace.setStreamingInterval(interval);
- assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
-
- interval = -1;
- trace.setStreamingInterval(interval);
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
-
- interval = 0;
- trace.setStreamingInterval(interval);
- assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
-
- trace.dispose();
- }
-
- // ------------------------------------------------------------------------
- // Set/Get time range
- // ------------------------------------------------------------------------
-
- @Test
- public void testSetTimeRange() throws TmfTraceException {
- final TmfTraceStub trace = new TmfTraceStub(fTrace);
- trace.indexTrace(true);
-
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- trace.setTimeRange(new TmfTimeRange(new TmfTimestamp(100), new TmfTimestamp(200)));
- assertEquals("setTimeRange", 100, trace.getTimeRange().getStartTime().getValue());
- assertEquals("setTimeRange", 200, trace.getTimeRange().getEndTime().getValue());
- assertEquals("setTimeRange", 100, trace.getStartTime().getValue());
- assertEquals("setTimeRange", 200, trace.getEndTime().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testSetStartTime() throws TmfTraceException {
- final TmfTraceStub trace = new TmfTraceStub(fTrace);
- trace.indexTrace(true);
-
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- trace.setStartTime(new TmfTimestamp(100));
- assertEquals("setStartTime", 100, trace.getTimeRange().getStartTime().getValue());
- assertEquals("setStartTime", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("setStartTime", 100, trace.getStartTime().getValue());
- assertEquals("setStartTime", NB_EVENTS, trace.getEndTime().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testSetEndTime() throws TmfTraceException {
- final TmfTraceStub trace = new TmfTraceStub(fTrace);
- trace.indexTrace(true);
-
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- trace.setEndTime(new TmfTimestamp(100));
- assertEquals("setEndTime", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("setEndTime", 100, trace.getTimeRange().getEndTime().getValue());
- assertEquals("setEndTime", 1, trace.getStartTime().getValue());
- assertEquals("setEndTime", 100, trace.getEndTime().getValue());
-
- trace.dispose();
- }
-
- @Test
- public void testSetNbEvents() throws TmfTraceException {
- final TmfTraceStub trace = new TmfTraceStub(fTrace);
- trace.indexTrace(true);
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
-
- trace.setNbEvents(0);
- assertEquals("getNbEvents", 0, trace.getNbEvents());
-
- trace.setNbEvents(-1);
- assertEquals("getNbEvents", 0, trace.getNbEvents());
-
- trace.setNbEvents(NB_EVENTS + 1);
- assertEquals("getNbEvents", NB_EVENTS + 1, trace.getNbEvents());
-
- trace.setNbEvents(NB_EVENTS);
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
-
- trace.dispose();
- }
-
- // ------------------------------------------------------------------------
- // State system, statistics and modules methods
- // ------------------------------------------------------------------------
-
- @Test
- public void testGetModulesByClass() {
- /* There should not be any modules at this point */
- Iterable<IAnalysisModule> modules = fTrace.getAnalysisModules();
- assertFalse(modules.iterator().hasNext());
-
- /* Open the trace, the modules should be populated */
- fTrace.traceOpened(new TmfTraceOpenedSignal(this, fTrace, null));
-
- modules = fTrace.getAnalysisModules();
- Iterable<TestAnalysis> testModules = fTrace.getAnalysisModulesOfClass(TestAnalysis.class);
- assertTrue(modules.iterator().hasNext());
- assertTrue(testModules.iterator().hasNext());
-
- /*
- * Make sure all modules of type TestAnalysis are returned in the second
- * call
- */
- for (IAnalysisModule module : modules) {
- if (module instanceof TestAnalysis) {
- IAnalysisModule otherModule = fTrace.getAnalysisModule(module.getId());
- assertNotNull(otherModule);
- assertTrue(otherModule.equals(module));
- }
- }
-
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on location (note: does not reliably set the rank)
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekEventOnCacheBoundary() {
- // Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent(0);
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
-
- context = fTrace.seekEvent(context.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event rank 1000
- ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event rank 4000
- tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- @Test
- public void testSeekEventNotOnCacheBoundary() {
- // Position trace at event rank 9
- ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event rank 999
- tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event rank 1001
- tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event rank 4500
- tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- @Test
- public void testSeekEventOutOfScope() {
- // Position trace at beginning
- ITmfContext tmpContext = fTrace.seekEvent(0);
- ITmfContext context = fTrace.seekEvent(tmpContext.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- // Position trace at event passed the end
- context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- assertNull("Event timestamp", context.getLocation());
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertNull("Event", event);
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on timestamp (note: does not reliably set the rank)
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekEventOnNullTimestamp() {
- // Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- }
-
- @Test
- public void testSeekEventOnTimestampOnCacheBoundary() {
- // Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0));
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event rank 1000
- context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- assertEquals("Event rank", 1000, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
-
- // Position trace at event rank 4000
- context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- assertEquals("Event rank", 4000, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4000, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4001, context.getRank());
- }
-
- @Test
- public void testSeekEventOnTimestampNotOnCacheBoundary() {
- // Position trace at event rank 1
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0));
- assertEquals("Event rank", 1, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Event rank", 2, context.getRank());
-
- // Position trace at event rank 9
- context = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
- assertEquals("Event rank", 9, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 9, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 10, context.getRank());
-
- // Position trace at event rank 999
- context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- assertEquals("Event rank", 999, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 999, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
-
- // Position trace at event rank 1001
- context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- assertEquals("Event rank", 1001, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1002, context.getRank());
-
- // Position trace at event rank 4500
- context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- assertEquals("Event rank", 4500, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4500, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekEventOnTimestampOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0));
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on rank
- // ------------------------------------------------------------------------
-
- @Test
- public void testSeekEventOnNegativeRank() {
- // Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent(-1);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- }
-
- @Test
- public void testSeekOnRankOnCacheBoundary() {
- // On lower bound, returns the first event (ts = 1)
- ITmfContext context = fTrace.seekEvent(0);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event rank 1000
- context = fTrace.seekEvent(1000);
- assertEquals("Event rank", 1000, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
-
- // Position trace at event rank 4000
- context = fTrace.seekEvent(4000);
- assertEquals("Event rank", 4000, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4000, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4001, context.getRank());
- }
-
- @Test
- public void testSeekOnRankNotOnCacheBoundary() {
- // Position trace at event rank 9
- ITmfContext context = fTrace.seekEvent(9);
- assertEquals("Event rank", 9, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 9, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 10, context.getRank());
-
- // Position trace at event rank 999
- context = fTrace.seekEvent(999);
- assertEquals("Event rank", 999, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 999, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
-
- // Position trace at event rank 1001
- context = fTrace.seekEvent(1001);
- assertEquals("Event rank", 1001, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1002, context.getRank());
-
- // Position trace at event rank 4500
- context = fTrace.seekEvent(4500);
- assertEquals("Event rank", 4500, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4500, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4501, context.getRank());
- }
-
- @Test
- public void testSeekEventOnRankOutOfScope() {
- // Position trace at beginning
- ITmfContext context = fTrace.seekEvent(-1);
- assertEquals("Event rank", 0, context.getRank());
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
-
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event passed the end
- context = fTrace.seekEvent(NB_EVENTS);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
-
- event = fTrace.parseEvent(context);
- assertNull("Event", event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
-
- event = fTrace.getNext(context);
- assertNull("Event", event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // parseEvent - make sure parseEvent doesn't update the context
- // ------------------------------------------------------------------------
-
- @Test
- public void testParseEvent() {
- final int NB_READS = 20;
-
- // On lower bound, returns the first event (ts = 0)
- final TmfContext context = (TmfContext) fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0));
- TmfContext svContext = new TmfContext(context);
-
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- assertTrue("parseEvent", context.equals(svContext));
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- assertTrue("parseEvent", context.equals(svContext));
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- assertTrue("parseEvent", context.equals(svContext));
-
- // Position the trace at event NB_READS
- for (int i = 1; i < NB_READS; i++) {
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
- }
-
- svContext = new TmfContext(context);
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", NB_READS -1 , context.getRank());
- assertTrue("parseEvent", context.equals(svContext));
-
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", NB_READS - 1, context.getRank());
- assertTrue("parseEvent", context.equals(svContext));
- }
-
- // ------------------------------------------------------------------------
- // getNext - updates the context
- // ------------------------------------------------------------------------
-
- @Test
- 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 = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
- }
-
- @Test
- public void testGetNextAfteSeekingOnTS_2() {
- final long INITIAL_TS = 2;
- final int NB_READS = 20;
-
- // On lower bound, returns the first event (ts = 500)
- final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
- }
-
- @Test
- 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 = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE, 0));
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
- }
-
- @Test
- 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 = fTrace.seekEvent(INITIAL_RANK);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
- }
-
- @Test
- 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 = fTrace.seekEvent(INITIAL_RANK);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
- }
-
- @Test
- 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 = fTrace.seekEvent(INITIAL_RANK);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
- }
-
- @Test
- 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 = fTrace.seekEvent(INITIAL_LOC);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.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 = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
- }
-
- @Test
- public void testGetNextAfterSeekingOnLocation_2() {
- final ITmfLocation INITIAL_LOC = fTrace.seekEvent(1L).getLocation();
- final long INITIAL_TS = 2;
- final int NB_READS = 20;
-
- // On lower bound, returns the first event (ts = 501)
- final ITmfContext context = fTrace.seekEvent(INITIAL_LOC);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
- }
-
- // Make sure we stay positioned
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- }
-
- @Test
- public void testGetNextAfterSeekingOnLocation_3() {
- final ITmfLocation INITIAL_LOC = fTrace.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 = fTrace.seekEvent(INITIAL_LOC);
-
- // Read NB_EVENTS
- ITmfEvent event;
- for (int i = 0; i < NB_READS; i++) {
- event = fTrace.getNext(context);
- assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
- }
-
- // Make sure we stay positioned
- event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
- }
-
- @Test
- public void testGetNextLocation() {
- ITmfContext context1 = fTrace.seekEvent(0);
- fTrace.getNext(context1);
- ITmfLocation location = context1.getLocation();
- ITmfEvent event1 = fTrace.getNext(context1);
- ITmfContext context2 = fTrace.seekEvent(location);
- ITmfEvent event2 = fTrace.getNext(context2);
- assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue());
- }
-
- @Test
- public void testGetNextEndLocation() {
- ITmfContext context1 = fTrace.seekEvent(fTrace.getNbEvents() - 1);
- fTrace.getNext(context1);
- ITmfLocation location = context1.getLocation();
- ITmfContext context2 = fTrace.seekEvent(location);
- ITmfEvent event = fTrace.getNext(context2);
- assertNull("Event", event);
- }
-
- // ------------------------------------------------------------------------
- // processRequest
- // ------------------------------------------------------------------------
-
- @Test
- public void testProcessEventRequestForAllEvents() throws InterruptedException {
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessEventRequestForNbEvents() throws InterruptedException {
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessEventRequestForSomeEvents() throws InterruptedException {
- final long startTime = 100;
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessEventRequestForOtherEvents() throws InterruptedException {
- final int startIndex = 99;
- final long startTime = 100;
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, startIndex, nbEvents, ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessDataRequestForSomeEvents() throws InterruptedException {
- final int startIndex = 100;
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- TmfTimeRange.ETERNITY,
- startIndex,
- nbEvents,
- TmfEventRequest.ExecutionType.FOREGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isCancelled", request.isCancelled());
-
- // Ensure that we have distinct events.
- // Don't go overboard: we are not validating the stub!
- for (int i = 0; i < nbEvents; i++) {
- assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() throws InterruptedException {
- final int limit = 500;
- final Vector<ITmfEvent> requestedEvents = new Vector<>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
- range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
- int nbRead = 0;
-
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- if (++nbRead == limit) {
- cancel();
- }
- }
- };
- final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
- providers[0].sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", limit, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isCancelled", request.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultTmfTraceStub() {
- assertFalse ("Open trace", fTrace == null);
- assertEquals("getType", ITmfEvent.class, fTrace.getType());
- assertNull ("getResource", fTrace.getResource());
- assertEquals("getStreamingInterval", 0, fTrace.getStreamingInterval());
- assertEquals("getName", TEST_TRACE.getPath(), fTrace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue());
-
- String expected = "TmfTrace [fPath=" + fTrace.getPath() + ", fCacheSize=" + fTrace.getCacheSize() +
- ", fNbEvents=" + fTrace.getNbEvents() + ", fStartTime=" + fTrace.getStartTime() +
- ", fEndTime=" + fTrace.getEndTime() + ", fStreamingInterval=" + fTrace.getStreamingInterval() +
- "]";
- assertEquals("toString", expected, fTrace.toString());
- }
-
- // ------------------------------------------------------------------------
- // getInitialRangeOffset, getCurrentRange, getCurrentTime
- // ------------------------------------------------------------------------
-
- @Test
- public void testCurrentTimeValues() throws TmfTraceException {
-
- TmfTraceStub trace = null;
- File testfile = null;
- try {
- 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);
- // verify initial values
- TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
- 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");
- }
- }
-
- /**
- * Run the String getHostId() method test
- */
- @Test
- public void testTraceHostId() {
- String a = fTrace.getHostId();
- assertEquals("A-Test-10K", a);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java
deleted file mode 100644
index 0d386a8849..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Random;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.ICheckpointCollection;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Common code for ICheckpointCollection test classes
- *
- * @author Marc-Andre Laperle
- */
-public abstract class AbstractCheckpointCollectionTest {
-
- private static final String INDEX_FILE_NAME = "checkpoint.idx"; //$NON-NLS-1$
-
- /**
- * The number of checkpoints to be inserted in insert tests
- */
- protected static final int CHECKPOINTS_INSERT_NUM = 50000;
- /**
- * The collection being tested
- */
- protected ICheckpointCollection fCheckpointCollection = null;
-
- private TmfTraceStub fTrace;
- private File fFile = new File(INDEX_FILE_NAME);
-
- /**
- * Setup the test. Make sure the index is deleted.
- */
- @Before
- public void setUp() {
- fTrace = new TmfTraceStub();
- if (fFile.exists()) {
- fFile.delete();
- }
- fCheckpointCollection = createCollection();
- }
-
- /**
- * Tear down the test. Make sure the index is deleted.
- */
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- if (fCheckpointCollection != null) {
- fCheckpointCollection.dispose();
- }
- if (fFile.exists()) {
- fFile.delete();
- }
- }
-
- /**
- * Get the trace being tested.
- *
- * @return the trace being tested.
- */
- public ITmfTrace getTrace() {
- return fTrace;
- }
-
- /**
- * Returns whether or not the collection is persisted to disk
- *
- * @return true if the collection is persisted to disk, false otherwise
- */
- public boolean isPersistableCollection() {
- return false;
- }
-
- /**
- * Get the file used for the index being tested.
- *
- * @return the file used for the index being tested.
- */
- public File getFile() {
- return fFile;
- }
-
- /**
- * Test constructing a new checkpoint collection
- */
- @Test
- public void testConstructor() {
- if (isPersistableCollection()) {
- assertTrue(fFile.exists());
- }
- assertTrue(fCheckpointCollection.isCreatedFromScratch());
- }
-
- /**
- * Test constructing a new checkpoint collection, existing file
- */
- @Test
- public void testConstructorExistingFile() {
- if (isPersistableCollection()) {
- assertTrue(fFile.exists());
- fCheckpointCollection.setIndexComplete();
- fCheckpointCollection.dispose();
-
- fCheckpointCollection = createCollection();
- assertFalse(fCheckpointCollection.isCreatedFromScratch());
- }
- }
-
- /**
- * Test that a new checkpoint collection is considered created from scratch
- * and vice versa
- */
- @Test
- public void testIsCreatedFromScratch() {
- assertTrue(fCheckpointCollection.isCreatedFromScratch());
- fCheckpointCollection.setIndexComplete();
-
- if (isPersistableCollection()) {
- fCheckpointCollection.dispose();
- fCheckpointCollection = createCollection();
- assertFalse(fCheckpointCollection.isCreatedFromScratch());
- }
- }
-
- /**
- * Test setTimeRange, getTimeRange
- */
- @Test
- public void testSetGetTimeRange() {
- if (isPersistableCollection()) {
- TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(0), new TmfTimestamp(100));
- fCheckpointCollection.setTimeRange(timeRange);
- assertEquals(timeRange, fCheckpointCollection.getTimeRange());
- }
- }
-
- /**
- * Create a collection for the test
- *
- * @return the collection
- */
- abstract protected ICheckpointCollection createCollection();
-
- /**
- * Test setNbEvents, getNbEvents
- */
- @Test
- public void testSetGetNbEvents() {
- if (isPersistableCollection()) {
- int expected = 12345;
- fCheckpointCollection.setNbEvents(expected);
- assertEquals(expected, fCheckpointCollection.getNbEvents());
- }
- }
-
- /**
- * Test setSize, size
- */
- @Test
- public void testSetGetSize() {
- assertEquals(0, fCheckpointCollection.size());
- int expected = CHECKPOINTS_INSERT_NUM;
- for (int i = 0; i < expected; ++i) {
- fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(0), new TmfLongLocation(0L), 0));
- }
- assertEquals(expected, fCheckpointCollection.size());
- }
-
- /**
- * Test delete
- */
- @Test
- public void testDelete() {
- if (isPersistableCollection()) {
- assertTrue(fFile.exists());
- fCheckpointCollection.delete();
- assertFalse(fFile.exists());
- }
- }
-
- /**
- * Test version change
- *
- * @throws IOException
- * can throw this
- */
- @Test
- public void testVersionChange() throws IOException {
- fCheckpointCollection.setIndexComplete();
- fCheckpointCollection.dispose();
- try (RandomAccessFile f = new RandomAccessFile(fFile, "rw");) {
- f.writeInt(-1);
- }
-
- fCheckpointCollection = createCollection();
- assertTrue(fCheckpointCollection.isCreatedFromScratch());
- }
-
- /**
- * Test a single insertion
- */
- @Test
- public void testInsert() {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0);
- fCheckpointCollection.insert(checkpoint);
-
- long found = fCheckpointCollection.binarySearch(checkpoint);
- assertEquals(0, found);
- }
-
- /**
- * Generate many checkpoints and insert them in the collection
- *
- * @return the list of generated checkpoints
- */
- protected ArrayList<Integer> insertAlot() {
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
- fCheckpointCollection.insert(checkpoint);
- }
-
- fCheckpointCollection.setIndexComplete();
- if (isPersistableCollection()) {
- fCheckpointCollection.dispose();
- }
-
- boolean random = true;
- ArrayList<Integer> list = new ArrayList<>();
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- if (random) {
- Random rand = new Random();
- list.add(rand.nextInt(CHECKPOINTS_INSERT_NUM));
- } else {
- list.add(i);
- }
- }
- return list;
- }
-
- /**
- * Test many checkpoint insertions. Make sure they can be found after
- * re-opening the file
- */
- @Test
- public void testInsertAlot() {
- ArrayList<Integer> list = insertAlot();
-
- if (isPersistableCollection()) {
- fCheckpointCollection = createCollection();
- }
-
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
- long found = fCheckpointCollection.binarySearch(checkpoint);
- assertEquals(randomCheckpoint.intValue(), found);
- }
- }
-
- /**
- * Test many checkpoint insertions using the same timestamp. Make sure they
- * can be found after re-opening the file
- */
- @Test
- public void testInsertSameTimestamp() {
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + i), i);
- fCheckpointCollection.insert(checkpoint);
- }
-
- fCheckpointCollection.setIndexComplete();
- if (isPersistableCollection()) {
- fCheckpointCollection.dispose();
- }
-
- boolean random = true;
- ArrayList<Integer> list = new ArrayList<>();
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- if (random) {
- Random rand = new Random();
- list.add(rand.nextInt(CHECKPOINTS_INSERT_NUM));
- } else {
- list.add(i);
- }
- }
-
- if (isPersistableCollection()) {
- fCheckpointCollection = createCollection();
- }
-
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + randomCheckpoint), 0);
- long found = fCheckpointCollection.binarySearch(checkpoint);
- assertEquals(randomCheckpoint.intValue(), found);
- }
- }
-
- /**
- * Tests that binarySearch find the correct checkpoint when the time stamp
- * is between checkpoints
- */
- @Test
- public void testBinarySearchFindInBetween() {
- for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(2 * i), new TmfLongLocation(2 * i), i);
- fCheckpointCollection.insert(checkpoint);
- }
-
- TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 123);
- int expectedInsertionPoint = 61;
- int expectedRank = -(expectedInsertionPoint + 2);
-
- long rank = fCheckpointCollection.binarySearch(searchedCheckpoint);
- assertEquals(expectedRank, rank);
- }
-
-
- /**
- * Tests that binarySearch finds the correct checkpoint when searching for a
- * checkpoint with a null location. It should return the previous checkpoint
- * from the first checkpoint that matches the timestamp.
- */
- @Test
- public void testBinarySearchInBetweenSameTimestamp() {
- int checkpointNum = 0;
- for (; checkpointNum < 100; checkpointNum++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(0), new TmfLongLocation(checkpointNum), checkpointNum);
- fCheckpointCollection.insert(checkpoint);
- }
-
- for (; checkpointNum < 200; checkpointNum++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(1), new TmfLongLocation(checkpointNum), checkpointNum);
- fCheckpointCollection.insert(checkpoint);
- }
-
- final TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(1), null, 0);
-
- long found = fCheckpointCollection.binarySearch(searchedCheckpoint);
-
- int expectedInsertionPoint = 99;
- int expectedRank = -(expectedInsertionPoint + 2);
-
- assertEquals(expectedRank, found);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllBench.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllBench.java
deleted file mode 100644
index d05abe293e..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllBench.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Random;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.BTree;
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.BTreeCheckpointVisitor;
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.FlatArray;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-
-/**
- * A class to benchmark different algoritms for storing the
- * checkpoint index on disk
- *
- * @author Marc-Andre Laperle
- */
-public class AllBench {
-
- private static final boolean reportProgress = true;
- private static ArrayList<ArrayList<Integer>> nums;
- private TmfTraceStub fTrace;
- private File file = new File("index.idx");
-
- static int BTREE_DEGREE = 10;
-
- private void setUp() {
- fTrace = new TmfTraceStub();
- if (file.exists()) {
- file.delete();
- }
- }
-
- private void tearDown() {
- fTrace.dispose();
- fTrace = null;
- if (file.exists()) {
- file.delete();
- }
- }
-
- private static void generateDataFile(ArrayList<Integer> list, int checkpointsNums) throws IOException {
- File randomDataFile = new File("data" + checkpointsNums);
- try (RandomAccessFile f = new RandomAccessFile(randomDataFile, "rw");) {
- if (randomDataFile.exists()) {
- for (int i = 0; i < checkpointsNums; i++) {
- Random rand = new Random();
- int nextInt = rand.nextInt(checkpointsNums);
- list.add(nextInt);
- f.writeInt(nextInt);
- }
- } else {
- for (int i = 0; i < checkpointsNums; i++) {
- list.add(f.readInt());
- }
- }
- }
- }
-
- @SuppressWarnings("javadoc")
- public static void main(String[] args) throws IOException {
- int checkpointsNums [] = new int [] { 5000, 50000, 500000, 1000000 };
- nums = new ArrayList<>(checkpointsNums.length);
-
- System.out.println("DEGREE: " + BTREE_DEGREE);
-
- AllBench b = new AllBench();
- b.setUp();
- for (int i = 0; i < checkpointsNums.length; i++) {
- ArrayList<Integer> list = new ArrayList<>();
- generateDataFile(list, checkpointsNums[i]);
- nums.add(list);
-
- System.out.println("*** " + checkpointsNums[i] + " checkpoints ***\n");
-
- b.benchIt(list);
- }
- b.tearDown();
- }
-
- private void benchIt(ArrayList<Integer> list) {
-
- System.out.println("Testing BTree\n");
-
- testInsertAlot(list);
-
- System.out.println("Testing Array\n");
-
- testInsertAlotArray(list);
- }
-
- private void testInsertAlot(ArrayList<Integer> list2) {
- int checkpointsNum = list2.size();
-
- writeCheckpoints(checkpointsNum);
-
- ArrayList<Integer> list = new ArrayList<>();
- for (int i = 0; i < checkpointsNum; i++) {
- list.add(i);
- }
-
- readCheckpoints(checkpointsNum, list, false);
- readCheckpoints(checkpointsNum, list2, true);
-
- file.delete();
-
- System.out.println();
- }
-
- private void testInsertAlotArray(ArrayList<Integer> list2) {
- int checkpointsNum = list2.size();
-
- writeCheckpointsArray(checkpointsNum);
-
- ArrayList<Integer> list = new ArrayList<>();
- for (int i = 0; i < checkpointsNum; i++) {
- list.add(i);
- }
-
- readCheckpointsArray(checkpointsNum, list, false);
- readCheckpointsArray(checkpointsNum, list2, true);
-
- file.delete();
-
- System.out.println();
- }
-
- private void writeCheckpoints(int checkpointsNum) {
- BTree bTree;
- int REPEAT = 10;
- long time = 0;
- for (int j = 0; j < REPEAT; j++) {
- long old = System.currentTimeMillis();
- bTree = new BTree(BTREE_DEGREE, file, fTrace);
- for (int i = 0; i < checkpointsNum; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
- bTree.insert(checkpoint);
- }
-
- time += (System.currentTimeMillis() - old);
- bTree.setIndexComplete();
- bTree.dispose();
- if (j != REPEAT - 1) {
- file.delete();
- }
- if (reportProgress) {
- System.out.print(".");
- }
- }
-
- System.out.println("Write time average: " + (float) time / REPEAT);
- }
-
- private void writeCheckpointsArray(int checkpointsNum) {
- FlatArray array;
- int REPEAT = 10;
- long time = 0;
- for (int j = 0; j < REPEAT; j++) {
- long old = System.currentTimeMillis();
- array = new FlatArray(file, fTrace);
- for (int i = 0; i < checkpointsNum; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
- array.insert(checkpoint);
- }
-
- time += (System.currentTimeMillis() - old);
- array.setIndexComplete();
- array.dispose();
- if (j != REPEAT - 1) {
- file.delete();
- }
- if (reportProgress) {
- System.out.print(".");
- }
- }
-
- System.out.println("Write time average: " + (float) time / REPEAT);
- }
-
-
- private void readCheckpoints(int checkpointsNum, ArrayList<Integer> list, boolean random) {
- BTree bTree;
- int REPEAT = 10;
- long time = 0;
- long cacheMisses = 0;
- for (int j = 0; j < REPEAT; j++) {
- long old = System.currentTimeMillis();
- bTree = new BTree(BTREE_DEGREE, file, fTrace);
- for (int i = 0; i < checkpointsNum; i++) {
- Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
- BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint);
- bTree.accept(treeVisitor);
- assertEquals(randomCheckpoint.intValue(), treeVisitor.getCheckpoint().getCheckpointRank());
- }
- time += (System.currentTimeMillis() - old);
- cacheMisses = bTree.getCacheMisses();
- bTree.dispose();
- if (reportProgress) {
- System.out.print(".");
- }
- }
-
- System.out.println("Read " + (random ? "(random)" : "(linear)") + "time average: " + (float) time / REPEAT + " (cache miss: " + cacheMisses + ")");
- }
-
- private void readCheckpointsArray(int checkpointsNum, ArrayList<Integer> list, boolean random) {
- FlatArray array;
- int REPEAT = 10;
- long time = 0;
- long cacheMisses = 0;
- for (int j = 0; j < REPEAT; j++) {
- long old = System.currentTimeMillis();
- array = new FlatArray(file, fTrace);
- for (int i = 0; i < checkpointsNum; i++) {
- Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
- long found = array.binarySearch(checkpoint);
- assertEquals(randomCheckpoint.intValue(), found);
- }
- time += (System.currentTimeMillis() - old);
- cacheMisses = array.getCacheMisses();
- array.dispose();
- if (reportProgress) {
- System.out.print(".");
- }
- }
-
- System.out.println("Read " + (random ? "(random)" : "(linear)") + "time average: " + (float) time / REPEAT + " (cache miss: " + cacheMisses + ")");
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllTests.java
deleted file mode 100644
index 0cc9a11dcd..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/AllTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite indexer classes
- *
- * @author Marc-Andre Laperle
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- BTreeTest.class,
- FlatArrayTest.class,
- TmfMemoryIndexTest.class
-})
-public class AllTests {
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/BTreeTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/BTreeTest.java
deleted file mode 100644
index 2ea65819c9..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/BTreeTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.BTree;
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.BTreeCheckpointVisitor;
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.IBTreeVisitor;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfPersistentlyIndexable;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Tests for the BTree class
- *
- * @author Marc-Andre Laperle
- */
-public class BTreeTest extends AbstractCheckpointCollectionTest {
-
- private final int DEGREE = 15;
- private BTree fBTree;
-
- @Override
- protected BTree createCollection() {
- fCheckpointCollection = fBTree = new BTree(DEGREE, getFile(), (ITmfPersistentlyIndexable) getTrace());
- return fBTree;
- }
-
- @Override
- public boolean isPersistableCollection() {
- return true;
- }
-
- /**
- * Tests that accepts find the correct checkpoint and ends with a perfect
- * match
- */
- @Test
- public void testAccept() {
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
- fBTree.insert(checkpoint);
- }
-
- final TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 0);
-
- class TestVisitor implements IBTreeVisitor {
- public int fLastCompare = 0;
- ITmfCheckpoint fFoundCheckpoint;
-
- @Override
- public int compare(ITmfCheckpoint checkRec) {
- fLastCompare = checkRec.compareTo(checkpoint);
- if (fLastCompare == 0) {
- fFoundCheckpoint = checkRec;
- }
- return fLastCompare;
- }
- }
- final TestVisitor t = new TestVisitor();
-
- fBTree.accept(t);
-
- assertEquals(checkpoint, t.fFoundCheckpoint);
- assertEquals(0, t.fLastCompare);
- }
-
- /**
- * Test many checkpoint insertions. Make sure they can be found after
- * re-opening the file
- */
- @Test
- public void testInsertAlotCheckEquals() {
- ArrayList<Integer> list = insertAlot();
-
- fBTree = createCollection();
-
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- Integer checkpointIndex = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), 0);
- BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint);
- fBTree.accept(treeVisitor);
- assertEquals(checkpoint, treeVisitor.getCheckpoint());
- }
- }
-
- /**
- * Test setSize, size
- */
- @Override
- @Test
- public void testSetGetSize() {
- assertEquals(0, fBTree.size());
- int expected = CHECKPOINTS_INSERT_NUM;
- for (int i = 0; i < expected; ++i) {
- fBTree.insert(new TmfCheckpoint(new TmfTimestamp(0), new TmfLongLocation(0L), 0));
- fBTree.setSize(fBTree.size() + 1);
- }
- assertEquals(expected, fBTree.size());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/FlatArrayTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/FlatArrayTest.java
deleted file mode 100644
index 215a5d1903..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/FlatArrayTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.FlatArray;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfPersistentlyIndexable;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Tests for the FlatArray class
- *
- * @author Marc-Andre Laperle
- */
-public class FlatArrayTest extends AbstractCheckpointCollectionTest {
-
- private FlatArray fFlatArray;
-
- @Override
- protected FlatArray createCollection() {
- fCheckpointCollection = fFlatArray = new FlatArray(getFile(), (ITmfPersistentlyIndexable) getTrace());
- return fFlatArray;
- }
-
- @Override
- public boolean isPersistableCollection() {
- return true;
- }
-
- /**
- * Tests that binarySearch find the correct checkpoint and ends with a
- * perfect match
- */
- @Test
- public void testBinarySearch() {
- for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
- fFlatArray.insert(checkpoint);
- }
-
- TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0);
- int expectedRank = 122;
-
- long rank = fFlatArray.binarySearch(expectedCheckpoint);
- ITmfCheckpoint found = fFlatArray.get(rank);
-
- assertEquals(expectedRank, rank);
- assertEquals(found, expectedCheckpoint);
- }
-
- /**
- * Test many checkpoint insertions. Make sure they can be found after
- * re-opening the file
- */
- @Test
- public void testInsertAlotCheckEquals() {
- ArrayList<Integer> list = insertAlot();
-
- fFlatArray = createCollection();
-
- for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- int checkpointIndex = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex),
- new TmfLongLocation(123456L + checkpointIndex), checkpointIndex);
- ITmfCheckpoint found = fFlatArray.get(checkpointIndex);
- assertEquals(checkpoint, found);
- }
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java
deleted file mode 100644
index 33ebec31c4..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Marc-Andre Laperle - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.TmfMemoryIndex;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Test for the TmfMemoryIndex class
- *
- * @author Marc-Andre Laperle
- */
-public class TmfMemoryIndexTest extends AbstractCheckpointCollectionTest {
-
- private TmfMemoryIndex fMemoryIndex;
-
- @Override
- protected TmfMemoryIndex createCollection() {
- fCheckpointCollection = fMemoryIndex = new TmfMemoryIndex(getTrace());
- return fMemoryIndex;
- }
-
- /**
- * Test a single insertion
- */
- @Override
- @Test
- public void testInsert() {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0);
- fMemoryIndex.insert(checkpoint);
-
- ITmfCheckpoint indexCheckpoint = fMemoryIndex.get(0);
- assertEquals(checkpoint, indexCheckpoint);
-
- long found = fMemoryIndex.binarySearch(checkpoint);
- assertEquals(0, found);
- }
-
- /**
- * Tests that binarySearch find the correct checkpoint and ends with a perfect match
- */
- @Test
- public void testBinarySearch() {
- for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
- fMemoryIndex.insert(checkpoint);
- }
-
- TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0);
- int expectedRank = 122;
-
- long rank = fMemoryIndex.binarySearch(expectedCheckpoint);
- ITmfCheckpoint found = fMemoryIndex.get(rank);
-
- assertEquals(expectedRank, rank);
- assertEquals(found, expectedCheckpoint);
- }
-
- /**
- * Test dispose
- */
- @Test
- public void testDispose() {
- fMemoryIndex.dispose();
- assertTrue(fMemoryIndex.isEmpty());
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AbstractIndexTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AbstractIndexTest.java
deleted file mode 100644
index 7f964a22fe..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AbstractIndexTest.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Marc-Andre Laperle - Extracted to a common class from TmfCheckpointIndexTest
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Common code for index testing
- *
- * @author Marc-Andre Laperle
- */
-public abstract class AbstractIndexTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- /**
- *
- */
- protected static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 10000;
- /**
- * The trace being tested
- */
- protected static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * Setup the test
- */
- @Before
- public void setUp() {
- setupTrace(getTracePath());
- }
-
- /**
- * Get the trace path
- *
- * @return the trace path
- */
- protected String getTracePath() {
- return TmfTestTrace.A_TEST_10K.getFullPath();
- }
-
- /**
- * Tear down the test
- */
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- interface TestIndexerInterface extends ITmfTraceIndexer {
- ITmfCheckpointIndex getCheckpoints();
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- /**
- * A test indexer
- */
- protected static class TestIndexer extends TmfCheckpointIndexer implements TestIndexerInterface {
- /**
- * Constructs the test indexer for a normal test trace
- *
- * @param testTrace
- * the test trace
- */
- public TestIndexer(ITmfTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
-
- @Override
- public ITmfCheckpointIndex getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- /**
- * Create the indexer for testing
- *
- * @param trace
- * the trace
- * @return the indexer for testing
- */
- protected TestIndexerInterface createTestIndexer(TestTrace trace) {
- return new TestIndexer(trace);
- }
-
- /**
- * A test trace
- */
- protected class TestTrace extends TmfTraceStub {
- /**
- *
- * @param path
- * the path
- * @param blockSize
- * the block size
- * @throws TmfTraceException
- * when error occurs
- */
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize, false, null);
- }
-
- @Override
- protected ITmfTraceIndexer createIndexer(int interval) {
- return createTestIndexer(this);
- }
-
- @Override
- public TestIndexerInterface getIndexer() {
- return (TestIndexerInterface) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- init(getClass().getSimpleName(), TmfEvent.class);
- }
-
- @Override
- protected ITmfTraceIndexer createIndexer(int interval) {
- return new TestIndexer(this);
- }
-
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- /**
- * Creates the trace for the specified path
- *
- * @param path
- * the path
- * @return the created trace
- * @throws URISyntaxException
- * when error occurs
- * @throws IOException
- * when error occurs
- * @throws TmfTraceException
- * when error occurs
- */
- protected TestTrace createTrace(final String path) throws URISyntaxException, IOException, TmfTraceException {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- TestTrace trace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- trace.indexTrace(true);
- return trace;
- }
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- fTrace = createTrace(path);
- } catch (final TmfTraceException e) {
- fail(e.getMessage());
- } catch (final URISyntaxException e) {
- fail(e.getMessage());
- } catch (final IOException e) {
- fail(e.getMessage());
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- /**
- * Test the content of the index after building the full index
- */
- @Test
- public void testTmfTraceIndexing() {
- verifyIndexContent();
- }
-
- /**
- * Verify the content of the index
- */
- protected static void verifyIndexContent() {
- assertEquals(BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals(NB_EVENTS, fTrace.getNbEvents());
- assertEquals(1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals(NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals(1, fTrace.getStartTime().getValue());
- assertEquals(NB_EVENTS, fTrace.getEndTime().getValue());
-
- ITmfCheckpointIndex checkpoints = fTrace.getIndexer().getCheckpoints();
- int pageSize = fTrace.getCacheSize();
- assertTrue(checkpoints != null);
- assertEquals(NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- ITmfEvent event = fTrace.parseEvent(context);
- assertEquals(context.getRank(), i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- /**
- * Test that a empty trace has the correct content
- */
- @Test
- public void testEmptyTmfTraceIndexing() {
- assertEquals(ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
- assertEquals(0, fEmptyTrace.getNbEvents());
- assertEquals(TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
- assertEquals(TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
- assertEquals(TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
- assertEquals(TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
-
- ITmfCheckpointIndex checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
- assertTrue(checkpoints != null);
- assertEquals(0, checkpoints.size());
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AllTests.java
deleted file mode 100644
index 43ab0a43ea..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/AllTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfBTreeIndexTest.class,
- TmfCheckpointIndexTest.class,
- TmfCheckpointIndexTest2.class,
- TmfCheckpointTest.class,
- TmfExperimentCheckpointIndexTest.class,
-})
-public class AllTests {} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfBTreeIndexTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfBTreeIndexTest.java
deleted file mode 100644
index f522a95f56..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfBTreeIndexTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Marc-Andre Laperle - Adapted to BTree indexer from TmfCheckpointIndexTest
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import static org.junit.Assert.assertFalse;
-
-import org.eclipse.linuxtools.tmf.core.trace.indexer.TmfBTreeTraceIndexer;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfBTreeTraceIndexer class.
- *
- * @author Marc-Andre Laperle
- */
-public class TmfBTreeIndexTest extends AbstractIndexTest {
-
- /**
- * Create the indexer for testing
- *
- * @param trace
- * the trace
- * @return the indexer for testing
- */
- @Override
- protected TestIndexerInterface createTestIndexer(TestTrace trace) {
- return new TestBTreeIndexer(trace);
- }
-
- private static class TestBTreeIndexer extends TmfBTreeTraceIndexer implements TestIndexerInterface {
- public TestBTreeIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
-
- @Override
- public ITmfCheckpointIndex getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- /**
- * Test that a fully built index has the same content when reloaded from disk
- *
- * @throws Exception when error occurs
- */
- @Test
- public void testReopenIndex() throws Exception {
- fTrace.dispose();
- fTrace = createTrace(getTracePath());
- assertFalse(fTrace.getIndexer().getCheckpoints().isCreatedFromScratch());
- fTrace.indexTrace(true);
-
- verifyIndexContent();
- }
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest.java
deleted file mode 100644
index 6eba8a3c3c..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-public class TmfCheckpointIndexTest extends AbstractIndexTest {
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java
deleted file mode 100644
index b7049cb63b..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexer class (events with same
- * timestamp around checkpoint).
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointIndexTest2 {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 702;
- private static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- // Trace has 3 events at t=101 at rank 99, 100, 101
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- setupTrace(TmfTestTrace.A_TEST_10K2.getFullPath());
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
- public TestIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- @SuppressWarnings({ })
- public TestIndexer(EmptyTestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- public ITmfCheckpointIndex getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- private class TestTrace extends TmfTraceStub {
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize, false, null);
- }
-
- @Override
- protected ITmfTraceIndexer createIndexer(int interval) {
- return new TestIndexer(this);
- }
-
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
-
- public EmptyTestTrace() {
- super();
- init(getClass().getSimpleName(), TmfEvent.class);
- }
-
- @Override
- protected ITmfTraceIndexer createIndexer(int interval) {
- return new TestIndexer(this);
- }
-
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceMultiTimestamps() {
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
-
- ITmfCheckpointIndex checkpoints = fTrace.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
-
- // Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
-
- // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
- // and not the event at checkpoint boundary
- TmfTimestamp seekTs = new TmfTimestamp(101, -3, 0);
- ITmfContext ctx = fTrace.seekEvent(seekTs);
- ITmfEvent event = fTrace.getNext(ctx);
-
- assertEquals(99, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(100, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(101, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
- // and not the event at checkpoint boundary
- seekTs = new TmfTimestamp(102, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(102, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to first checkpoint
- seekTs = new TmfTimestamp(1, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp before first event
- seekTs = new TmfTimestamp(0, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, new TmfTimestamp(1, -3, 0).compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp between first and second checkpoint
- seekTs = new TmfTimestamp(50, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(50, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp after last event in trace
- seekTs = new TmfTimestamp(103, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(-1, ctx.getRank());
- assertNull(event);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java
deleted file mode 100644
index c4e202a250..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 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 - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for location in checkpoint
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpoint class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
- private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
- private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
-
- private long aLong1 = 12345L;
- private long aLong2 = 23456L;
- private long aLong3 = 34567L;
- private long RANK1 = 1L;
- private long RANK2 = 2L;
- private long RANK3 = 3L;
-
- private ITmfLocation fLocation1 = new TmfLongLocation(aLong1);
- private ITmfLocation fLocation2 = new TmfLongLocation(aLong2);
- private ITmfLocation fLocation3 = new TmfLongLocation(aLong3);
-
- private TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1, RANK1);
- private TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2, RANK2);
- private TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3, RANK3);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfCheckpoint() {
- assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, fCheckpoint1.getLocation());
- }
-
- public void testTmfLocationCopy() {
- final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
-
- assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, checkpoint.getLocation());
- }
-
- @Test
- public void testTmfLocationCopy2() {
- try {
- new TmfCheckpoint(null);
- fail("null copy");
- }
- catch (final IllegalArgumentException e) {
- // Success
- }
- catch (final Exception e) {
- fail("wrong exception");
- }
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testCompareTo() {
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint2.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint2));
- assertEquals("compareTo", 0, fCheckpoint3.compareTo(fCheckpoint3));
- }
-
- @Test
- public void testCompareToNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1, RANK1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(null, fLocation2, RANK2);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(null, fLocation3, RANK3);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(null, fLocation1, RANK1);
-
- // Test the various 'null' vs. '!null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", 1, fCheckpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint3));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(checkpoint1));
-
- // Test the 'null' vs. 'null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(checkpoint4));
- assertEquals("compareTo", 0, checkpoint4.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint2));
- assertEquals("compareTo", 1, checkpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint3));
- assertEquals("compareTo", 1, checkpoint3.compareTo(checkpoint1));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
- }
-
- @Test
- public void testHashCodeNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1, RANK1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp1, null, RANK1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
-
- assertTrue("hashCode", checkpoint1.hashCode() == checkpoint3.hashCode());
- assertTrue("hashCode", checkpoint2.hashCode() == checkpoint4.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
-
- assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
- assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("equals", checkpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint1.equals(checkpoint1));
-
- assertTrue("equals", checkpoint2.equals(fCheckpoint2));
- assertTrue("equals", fCheckpoint2.equals(checkpoint2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("equals", checkpoint1.equals(checkpoint2));
- assertTrue("equals", checkpoint2.equals(checkpoint3));
- assertTrue("equals", checkpoint1.equals(checkpoint3));
- }
-
- @Test
- public void testNotEqual() {
- // Various checkpoints
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1, RANK1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp2, fLocation1, RANK1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(fTimestamp1, fLocation2, RANK2);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(fTimestamp1, null, RANK1);
- final TmfCheckpoint checkpoint5 = new TmfCheckpoint(null, fLocation1, RANK1);
-
- // Null check
- assertFalse("equals", checkpoint1.equals(null));
-
- // Different types
- assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
-
- // Null locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint4));
- assertFalse("equals", checkpoint1.equals(checkpoint5));
- assertFalse("equals", checkpoint4.equals(checkpoint1));
- assertFalse("equals", checkpoint5.equals(checkpoint1));
-
- // Different locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint2));
- assertFalse("equals", checkpoint1.equals(checkpoint3));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
- ", fTimestamp=" + fCheckpoint1.getTimestamp() + ", fCheckpointRank=" + fCheckpoint1.getCheckpointRank() + "]";
- final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
- ", fTimestamp=" + fCheckpoint2.getTimestamp() + ", fCheckpointRank=" + fCheckpoint2.getCheckpointRank() + "]";
- final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
- ", fTimestamp=" + fCheckpoint3.getTimestamp() + ", fCheckpointRank=" + fCheckpoint3.getCheckpointRank() + "]";
-
- assertEquals("toString", expected1, fCheckpoint1.toString());
- assertEquals("toString", expected2, fCheckpoint2.toString());
- assertEquals("toString", expected3, fCheckpoint3.toString());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java
deleted file mode 100644
index 1aa81bf3c1..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for ranks in experiment location
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfExperimentCheckpointIndexTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static final String EXPERIMENT = "MyExperiment";
- private static final TmfTestTrace TEST_TRACE1 = TmfTestTrace.O_TEST_10K;
- private static final TmfTestTrace TEST_TRACE2 = TmfTestTrace.E_TEST_10K;
- private static int NB_EVENTS = 20000;
- private static int BLOCK_SIZE = 1000;
-
- private static ITmfTrace[] fTestTraces;
- private static TmfExperimentStub fExperiment;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTraces();
- fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
- fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- }
-
- @After
- public void tearDown() {
- fExperiment.dispose();
- fExperiment = null;
- for (ITmfTrace trace : fTestTraces) {
- trace.dispose();
- }
- fTestTraces = null;
- }
-
- private static void setupTraces() {
-
- fTestTraces = new ITmfTrace[2];
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE1.getFullPath()), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null);
- fTestTraces[0] = trace1;
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE2.getFullPath()), null);
- test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null);
- fTestTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceIndexing() {
- assertEquals("getCacheSize", BLOCK_SIZE, fExperiment.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
- assertEquals("getRange-start", 1, fExperiment.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fExperiment.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fExperiment.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fExperiment.getEndTime().getValue());
-
- ITmfCheckpointIndex checkpoints = fExperiment.getIndexer().getCheckpoints();
- int pageSize = fExperiment.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = fExperiment.seekEvent(location);
- ITmfEvent event = fExperiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- // ------------------------------------------------------------------------
- // Streaming
- // ------------------------------------------------------------------------
-
- @Test
- public void testGrowingIndex() {
- ITmfTrace[] testTraces = new TmfTraceStub[2];
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE1.getFullPath()), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, false, null);
- testTraces[0] = trace1;
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE2.getFullPath()), null);
- test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, false, null);
- testTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
-
- TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, testTraces, BLOCK_SIZE);
- int pageSize = experiment.getCacheSize();
-
- // Build the first half of the index
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
- experiment.getIndexer().buildIndex(0, range, true);
-
- // Validate that each checkpoint points to the right event
- ITmfCheckpointIndex checkpoints = experiment.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE / 2, checkpoints.size());
-
- // Build the second half of the index
- experiment.getIndexer().buildIndex(NB_EVENTS / 2, TmfTimeRange.ETERNITY, true);
-
- // Validate that each checkpoint points to the right event
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = experiment.seekEvent(location);
- ITmfEvent event = experiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- assertEquals("Checkpoint value", i * pageSize + 1, checkpoint.getTimestamp().getValue());
- }
-
- /* Clean up (since we didn't use the class-specific fixtures) */
- experiment.dispose();
- for (ITmfTrace trace : testTraces) {
- trace.dispose();
- }
- }
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/AllTests.java
deleted file mode 100644
index 3593f4caaa..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.location;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.trace.location
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfLocationTest.class,
-})
-public class AllTests {} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/TmfLocationTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/TmfLocationTest.java
deleted file mode 100644
index fdbc6a4b1b..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/location/TmfLocationTest.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 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
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Add tests for TmfExperimentLocation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.location;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfLocation class.
- */
-@SuppressWarnings("javadoc")
-public class TmfLocationTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private Long aLong = 12345L;
- private TmfTimestamp aTimestamp = new TmfTimestamp();
- private TmfLocationArray aLocationArray;
-
- private TmfLongLocation fLocation1;
- private TmfLongLocation fLocation2;
- private TmfTimestampLocation fLocation3;
- private TmfExperimentLocation fExpLocation;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- fLocation1 = new TmfLongLocation((Long) null);
- fLocation2 = new TmfLongLocation(aLong);
- fLocation3 = new TmfTimestampLocation(aTimestamp);
- aLocationArray = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2, 3 }
- );
- fExpLocation = new TmfExperimentLocation(aLocationArray);
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfLocation() {
- assertNull("TmfLocation", fLocation1.getLocationInfo());
- assertEquals("TmfLocation", aLong, fLocation2.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, fLocation3.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo());
- }
-
- @Test
- public void testTmfLocationCopy() {
- TmfLongLocation location1 = new TmfLongLocation(fLocation1);
- TmfLongLocation location2 = new TmfLongLocation(fLocation2);
- TmfTimestampLocation location3 = new TmfTimestampLocation(fLocation3);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertNull("TmfLocation", location1.getLocationInfo());
- assertEquals("TmfLocation", aLong, location2.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, location3.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- TmfLongLocation location1 = new TmfLongLocation((Long) null);
- TmfLongLocation location2 = new TmfLongLocation(aLong);
- TmfTimestampLocation location3 = new TmfTimestampLocation(aTimestamp);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 2, fLocation3, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 2, fLocation2, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2 },
- new long[] { 1, 2 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
-
- assertTrue("hashCode", fLocation1.hashCode() == location1.hashCode());
- assertTrue("hashCode", fLocation2.hashCode() == location2.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() == location3.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() == expLocation.hashCode());
-
- assertTrue("hashCode", fLocation2.hashCode() != location3.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() != location2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation1.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation3.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toEquals
- // ------------------------------------------------------------------------
-
- private static class TmfTestLongLocation extends TmfLocation {
- public TmfTestLongLocation(Long location) {
- super(location);
- }
-
- @Override
- public void serialize(ByteBuffer bufferOut) {}
- }
-
- private static class TmfTestLongLocation2 extends TmfTestLongLocation {
- public TmfTestLongLocation2(Long location) {
- super(location);
- }
- }
-
- @Test
- public void testEqualsWrongTypes() {
- ITmfLocation location1 = new TmfTestLongLocation(aLong);
- TmfTestLongLocation location2 = new TmfTestLongLocation2(aLong);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsWithNulls() {
- ITmfLocation location1 = new TmfLongLocation(aLong);
- ITmfLocation location2 = new TmfLongLocation((Long) null);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fLocation1.equals(fLocation1));
- assertTrue("equals", fLocation2.equals(fLocation2));
- assertTrue("equals", fLocation3.equals(fLocation3));
- assertTrue("equals", fExpLocation.equals(fExpLocation));
-
- assertTrue("equals", !fLocation2.equals(fLocation3));
- assertTrue("equals", !fLocation3.equals(fLocation2));
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 2, fLocation3, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 2, fLocation2, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
- assertTrue("equals", !fExpLocation.equals(expLocation1));
- assertTrue("equals", !expLocation1.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation2));
- assertTrue("equals", !expLocation2.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation3));
- assertTrue("equals", !expLocation3.equals(fExpLocation));
- }
-
- @Test
- public void testEqualsSymmetry() {
- TmfLongLocation location2 = new TmfLongLocation(aLong);
- TmfTimestampLocation location3 = new TmfTimestampLocation(aTimestamp);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertTrue("equals", location2.equals(fLocation2));
- assertTrue("equals", fLocation2.equals(location2));
-
- assertTrue("equals", location3.equals(fLocation3));
- assertTrue("equals", fLocation3.equals(location3));
-
- assertTrue("equals", expLocation.equals(fExpLocation));
- assertTrue("equals", fExpLocation.equals(expLocation));
- }
-
- @Test
- public void testEqualsTransivity() {
- TmfLongLocation location1 = new TmfLongLocation(aLong);
- TmfLongLocation location2 = new TmfLongLocation(aLong);
- TmfLongLocation location3 = new TmfLongLocation(aLong);
-
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray);
-
- assertTrue("equals", location1.equals(location2));
- assertTrue("equals", location2.equals(location3));
- assertTrue("equals", location3.equals(location1));
- assertTrue("equals", expLocation1.equals(expLocation2));
- assertTrue("equals", expLocation2.equals(expLocation3));
- assertTrue("equals", expLocation3.equals(expLocation1));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !fLocation1.equals(null));
- assertTrue("equals", !fLocation2.equals(null));
- assertTrue("equals", !fLocation3.equals(null));
- assertTrue("equals", !fExpLocation.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- TmfTimestamp ts = new TmfTimestamp();
-
- TmfLongLocation location1 = new TmfLongLocation(aLong);
- TmfTimestampLocation location2 = new TmfTimestampLocation(ts);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray);
-
- String expected1 = "TmfLongLocation [fLocationInfo=" + aLong + "]";
- String expected2 = "TmfTimestampLocation [fLocationInfo=" + ts + "]";
- String expected3 = "TmfExperimentLocation [" + aLocationArray + "]";
-
- assertEquals("toString", expected1, location1.toString());
- assertEquals("toString", expected2, location2.toString());
- assertEquals("toString", expected3, expLocation.toString());
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/AllTests.java
deleted file mode 100644
index 4ed2c6ed23..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.stub;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Unit tests for the development trace package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- XmlStubTraceTest.class
-})
-public class AllTests {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/XmlStubTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/XmlStubTraceTest.java
deleted file mode 100644
index 5705e938a9..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/stub/XmlStubTraceTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * 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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.stub;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TmfXmlTraceStub} class
- *
- * @author Geneviève Bastien
- */
-public class XmlStubTraceTest {
-
- private static final Path VALID_FILE = new Path("testfiles/stub_xml_traces/valid/test.xml");
- private static final Path VALID_PATH = new Path("testfiles/stub_xml_traces/valid");
- private static final Path INVALID_PATH = new Path("testfiles/stub_xml_traces/invalid");
-
- private static final String EVENT_A = "A";
- private static final String EVENT_B = "B";
- private static final String FIELD_A = "b";
- private static final String FIELD_B = "f";
-
- private static IPath getAbsolutePath(Path relativePath) {
- Plugin plugin = TmfCoreTestPlugin.getDefault();
- if (plugin == null) {
- /*
- * Shouldn't happen but at least throw something to get the test to
- * fail early
- */
- throw new IllegalStateException();
- }
- URL location = FileLocator.find(plugin.getBundle(), relativePath, null);
- try {
- IPath path = new Path(FileLocator.toFileURL(location).getPath());
- return path;
- } catch (IOException e) {
- throw new IllegalStateException();
- }
- }
-
- /**
- * Test the
- * {@link TmfXmlTraceStub#validate(org.eclipse.core.resources.IProject, String)}
- * method
- */
- @Test
- public void testValidate() {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
- File[] invalidFiles = getAbsolutePath(INVALID_PATH).toFile().listFiles();
- assertTrue(invalidFiles.length > 0);
- for (File f : invalidFiles) {
- assertTrue(!trace.validate(null, f.getAbsolutePath()).isOK());
- }
-
- File[] validFiles = getAbsolutePath(VALID_PATH).toFile().listFiles();
- assertTrue(validFiles.length > 0);
- for (File f : validFiles) {
- assertTrue(trace.validate(null, f.getAbsolutePath()).isOK());
- }
- }
-
- /**
- * Test the reading and querying the XML trace and make sure fields are
- * present
- */
- @Test
- public void testDevelopmentTrace() {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
- IStatus status = trace.validate(null, getAbsolutePath(VALID_FILE).toOSString());
- if (!status.isOK()) {
- fail(status.getException().getMessage());
- }
-
- try {
- trace.initTrace(null, getAbsolutePath(VALID_FILE).toOSString(), TmfEvent.class);
- } catch (TmfTraceException e1) {
- fail(e1.getMessage());
- }
-
- CustomEventRequest req = new CustomEventRequest(trace);
- trace.sendRequest(req);
- try {
- req.waitForCompletion();
- if (req.isCancelled()) {
- fail(req.getStatus().getMessage());
- }
- } catch (InterruptedException e) {
- fail(e.getMessage());
- }
- assertEquals(4, req.getCount());
- }
-
- private static IStatus testEvent(ITmfEvent event) {
- switch (event.getType().getName()) {
- case EVENT_A: {
- ITmfEventField content = event.getContent();
- if (!event.getSource().equals("1")) {
- return new Status(IStatus.ERROR, TmfCoreTestPlugin.PLUGIN_ID, "Events of type A should have source 1 but was " + event.getSource());
- }
- if (content.getField(FIELD_A) == null) {
- return new Status(IStatus.ERROR, TmfCoreTestPlugin.PLUGIN_ID, String.format("Field %s does not exist in event %s", FIELD_A, EVENT_A));
- }
- break;
- }
- case EVENT_B: {
- ITmfEventField content = event.getContent();
- if (!event.getSource().equals("2")) {
- return new Status(IStatus.ERROR, TmfCoreTestPlugin.PLUGIN_ID, "Events of type B should have source 2 but was " + event.getSource());
- }
- if (content.getField(FIELD_B) == null) {
- return new Status(IStatus.ERROR, TmfCoreTestPlugin.PLUGIN_ID, String.format("Field %s does not exist in event %s", FIELD_B, EVENT_B));
- }
- break;
- }
- default:
- return new Status(IStatus.ERROR, TmfCoreTestPlugin.PLUGIN_ID, "Unexpected event " + event.getType().getName());
- }
- return Status.OK_STATUS;
- }
-
- private class CustomEventRequest extends TmfEventRequest {
- private final ITmfTrace fTrace;
- private IStatus fResult = Status.OK_STATUS;
- private int fCount = 0;
-
- public CustomEventRequest(ITmfTrace trace) {
- super(trace.getEventType(),
- TmfTimeRange.ETERNITY,
- 0,
- ITmfEventRequest.ALL_DATA,
- ITmfEventRequest.ExecutionType.BACKGROUND);
- this.fTrace = trace;
- }
-
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- if (event.getTrace() == fTrace) {
- fCount++;
- IStatus result = testEvent(event);
- if (!result.isOK()) {
- fResult = result;
- this.cancel();
- }
- }
- }
-
- public IStatus getStatus() {
- return fResult;
- }
-
- public int getCount() {
- return fCount;
- }
-
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/AllTests.java
deleted file mode 100644
index 77274652b1..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.text;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.linuxtools.tmf.core.trace.location
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TextTraceContextTest.class,
- TextTraceEventContentTest.class,
- TextTraceTest.class,
-})
-public class AllTests {} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceContextTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceContextTest.java
deleted file mode 100644
index c514c5bcdb..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceContextTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.text;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.text.TextTraceContext;
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TextTraceContext} class.
- */
-@SuppressWarnings("javadoc")
-public class TextTraceContextTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final Long aLong1 = 12345L;
- private final Long aLong2 = 12346L;
- private final Long aLong3 = 12347L;
-
- private final TmfLongLocation fLocation1 = new TmfLongLocation(aLong1);
- private final TmfLongLocation fLocation2 = new TmfLongLocation(aLong2);
-
- private final long fRank1 = 1;
- private final long fRank2 = 2;
-
- private final TextTraceContext fContext1 = new TextTraceContext(fLocation1, fRank1);
- private final TextTraceContext fContext2 = new TextTraceContext(fLocation1, fRank1);
-
- private final Pattern pattern1 = Pattern.compile("\\s*.*");
- private final Pattern pattern2 = Pattern.compile("\\s*.*");
-
- private final String line1 = "line1";
- private final String line2 = "line2";
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public TextTraceContextTest () {
- fContext1.firstLine = line1;
- fContext1.firstLineMatcher = pattern1.matcher(line1);
- fContext1.nextLineLocation = aLong2;
-
- fContext2.firstLine = line2;
- fContext2.firstLineMatcher = pattern2.matcher(line2);
- fContext2.nextLineLocation = aLong3;
- }
-
- @Test
- public void testTmfContextDefault() {
- final TextTraceContext context = new TextTraceContext(fLocation1, fRank1);
- assertEquals("getLocation", fLocation1, context.getLocation());
- assertEquals("getRank", fRank1, context.getRank());
- assertNull(context.firstLine);
- assertNull(context.firstLineMatcher);
- assertEquals(0, context.nextLineLocation);
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fContext1.equals(fContext1));
- assertTrue("equals", fContext2.equals(fContext2));
-
- assertFalse("equals", fContext1.equals(fContext2));
- assertFalse("equals", fContext2.equals(fContext1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TextTraceContext context1 = new TextTraceContext(fContext1);
- final TextTraceContext context2 = new TextTraceContext(fContext2);
-
- assertTrue("equals", context1.equals(fContext1));
- assertTrue("equals", fContext1.equals(context1));
-
- assertTrue("equals", context2.equals(fContext2));
- assertTrue("equals", fContext2.equals(context2));
- }
-
- @Test
- public void testEqualsTransivity() {
-
- final TextTraceContext context1 = new TextTraceContext(fContext1);
- final TextTraceContext context2 = new TextTraceContext(fContext1);
- final TextTraceContext context3 = new TextTraceContext(fContext1);
-
- assertTrue("equals", context1.equals(context2));
- assertTrue("equals", context2.equals(context3));
- assertTrue("equals", context1.equals(context3));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fContext1.equals(null));
- assertFalse("equals", fContext2.equals(null));
- }
-
- private static class MyContext extends TextTraceContext {
-
- public MyContext(ITmfLocation location, long rank) {
- super(location, rank);
- }
- }
-
- @Test
- public void testNonEquals() {
-
- // Different classes
- final MyContext myContext = new MyContext(fLocation1, fRank1);
- assertFalse("equals", fContext1.equals(myContext));
- assertFalse("equals", myContext.equals(fContext1));
-
- // Different locations
- TextTraceContext context1 = new TextTraceContext(fLocation1, fRank1);
- TextTraceContext context2 = new TextTraceContext(fLocation2, fRank1);
- assertFalse("equals", context1.equals(context2));
-
- // Different ranks
- context1 = new TextTraceContext(fLocation1, fRank1);
- context2 = new TextTraceContext(fLocation1, fRank2);
- assertFalse("equals", context1.equals(context2));
-
- // Different firstLine
- context1 = new TextTraceContext(fLocation1, fRank1);
- context1.firstLine = line1;
- context2 = new TextTraceContext(fLocation1, fRank1);
- context2.firstLine = line2;
- assertFalse("equals", context1.equals(context2));
-
- // Different firstLineMatcher
- context1 = new TextTraceContext(fLocation1, fRank1);
- context1.firstLine = line1;
- context1.firstLineMatcher = fContext1.firstLineMatcher;
- context2 = new TextTraceContext(fLocation1, fRank1);
- context2.firstLine = line1;
- context2.firstLineMatcher = fContext2.firstLineMatcher;
- assertFalse("equals", context1.equals(context2));
-
- // Different nextLineLocation
- context1 = new TextTraceContext(fLocation1, fRank1);
- context1.firstLine = line1;
- context1.firstLineMatcher = fContext1.firstLineMatcher;
- context1.nextLineLocation = aLong2;
- context2 = new TextTraceContext(fLocation1, fRank1);
- context2.firstLine = line1;
- context2.firstLineMatcher = fContext1.firstLineMatcher;
- context2.nextLineLocation = aLong3;
- assertFalse("equals", context1.equals(context2));
-
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TextTraceContext context1 = new TextTraceContext(fContext1);
- final TextTraceContext context2 = new TextTraceContext(fContext2);
-
- assertEquals("hashCode", fContext1.hashCode(), context1.hashCode());
- assertEquals("hashCode", fContext2.hashCode(), context2.hashCode());
-
- assertFalse("hashCode", fContext1.hashCode() == context2.hashCode());
- assertFalse("hashCode", fContext2.hashCode() == context1.hashCode());
-
- final TmfContext nullContext1 = new TmfContext();
- final TmfContext nullContext2 = new TmfContext(nullContext1);
- assertEquals("hashCode", nullContext1.hashCode(), nullContext2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // setLocation, setRank, updateRank
- // ------------------------------------------------------------------------
-
- @Test
- public void testSetLocation() {
- final TextTraceContext context1 = new TextTraceContext(fLocation1, fRank1);
- context1.setLocation(fLocation2);
-
- assertEquals("getLocation", fLocation2, context1.getLocation());
- assertEquals("getRank", fRank1, context1.getRank());
- }
-
- @Test
- public void testSetRank() {
- final TextTraceContext context1 = new TextTraceContext(fContext1);
- context1.setRank(fContext2.getRank());
-
- assertEquals("getLocation", fContext1.getLocation(), context1.getLocation());
- assertEquals("getRank", fContext2.getRank(), context1.getRank());
- }
-
- @Test
- public void testIncreaseRank() {
- final TextTraceContext context1 = new TextTraceContext(fLocation1, fRank1);
-
- context1.increaseRank();
- assertEquals("getRank", fRank1 + 1, context1.getRank());
- context1.increaseRank();
- assertEquals("getRank", fRank1 + 2, context1.getRank());
-
- context1.setRank(ITmfContext.UNKNOWN_RANK);
- context1.increaseRank();
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
- context1.increaseRank();
- assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank());
- }
-
-}
-
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceEventContentTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceEventContentTest.java
deleted file mode 100644
index 8930792c9e..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceEventContentTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.tmf.core.tests.trace.text;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.trace.text.TextTraceEventContent;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.text.SyslogEventType;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.text.SyslogEventType.Index;
-import org.junit.Test;
-
-/**
- * Test suite for the {@link TextTraceEventContent} class.
- */
-@SuppressWarnings({ "javadoc", "nls" })
-public class TextTraceEventContentTest {
-
- // ------------------------------------------------------------------------
- // Members
- // ------------------------------------------------------------------------
-
- private TextTraceEventContent fEventContent1;
- private TextTraceEventContent fEventContent1Clone;
- private TextTraceEventContent fEventContent2;
- private TextTraceEventContent fEventContent2Clone;
-
- public TextTraceEventContentTest () {
- fEventContent1 = new TextTraceEventContent(SyslogEventType.LABELS);
- fEventContent1.setValue("CONTENT");
- fEventContent1.setFieldValue(Index.TIMESTAMP, "Jan 1 01:01:01");
- fEventContent1.setFieldValue(Index.HOST, "HostA");
- fEventContent1.setFieldValue(Index.LOGGER, "LoggerA");
- fEventContent1.setFieldValue(Index.MESSAGE, "MessageA");
-
- fEventContent1Clone = new TextTraceEventContent(SyslogEventType.LABELS);
- fEventContent1Clone.setValue("CONTENT");
- fEventContent1Clone.setFieldValue(Index.TIMESTAMP, "Jan 1 01:01:01");
- fEventContent1Clone.setFieldValue(Index.HOST, "HostA");
- fEventContent1Clone.setFieldValue(Index.LOGGER, "LoggerA");
- fEventContent1Clone.setFieldValue(Index.MESSAGE, "MessageA");
-
- fEventContent2 = new TextTraceEventContent(SyslogEventType.LABELS);
- fEventContent2.setFieldValue(SyslogEventType.LABELS[0], "Jan 1 02:02:02");
- fEventContent2.setFieldValue(SyslogEventType.LABELS[1], "HostB");
- fEventContent2.setFieldValue(SyslogEventType.LABELS[2], "LoggerB");
- StringBuffer buffer = new StringBuffer();
- buffer.append("Message B");
- fEventContent2.setFieldValue(SyslogEventType.LABELS[3], buffer);
-
- fEventContent2Clone = new TextTraceEventContent(SyslogEventType.LABELS);
- fEventContent2Clone.setFieldValue(SyslogEventType.LABELS[0], "Jan 1 02:02:02");
- fEventContent2Clone.setFieldValue(SyslogEventType.LABELS[1], "HostB");
- fEventContent2Clone.setFieldValue(SyslogEventType.LABELS[2], "LoggerB");
- buffer = new StringBuffer();
- buffer.append("Message B");
- fEventContent2Clone.setFieldValue(SyslogEventType.LABELS[3], buffer);
- }
-
- public void testConstructorConstructor() {
- assertEquals("getField:TIMESTAMP", "Jan 1 01:01:01", fEventContent1.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostA", fEventContent1.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerA", fEventContent1.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "MessageA", fEventContent1.getFieldValue(Index.MESSAGE).toString());
- }
-
- // ------------------------------------------------------------------------
- // Event Type
- // ------------------------------------------------------------------------
-
- @Test
- public void testEventTypeInstance() {
- SyslogEventType eventType = SyslogEventType.INSTANCE;
- assertEquals("getTypeId", "Syslog", eventType.getName());
- assertNotNull ("instance", eventType);
- assertTrue (eventType.getFieldNames().contains("Timestamp"));
- assertTrue (eventType.getFieldNames().contains("Host"));
- assertTrue (eventType.getFieldNames().contains("Logger"));
- assertTrue (eventType.getFieldNames().contains("Message"));
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEquals() {
- assertEquals("equals", fEventContent1, fEventContent1);
- assertEquals("equals", fEventContent2, fEventContent2);
-
- assertTrue("equals", !fEventContent1.equals(fEventContent2));
- assertTrue("equals", !fEventContent2.equals(fEventContent1));
-
- assertEquals("equals", fEventContent1, fEventContent1Clone);
- assertEquals("equals", fEventContent2, fEventContent2Clone);
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !fEventContent1.equals(null));
- assertTrue("equals", !fEventContent2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
-
- assertEquals("hashCode", fEventContent1.hashCode(), fEventContent1Clone.hashCode());
- assertEquals("hashCode", fEventContent2.hashCode(), fEventContent2Clone.hashCode());
-
- assertNotEquals("hashCode", fEventContent1.hashCode(), fEventContent2.hashCode());
- assertNotEquals("hashCode", fEventContent2.hashCode(), fEventContent1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // Event Content
- // ------------------------------------------------------------------------
-
- @Test
- public void testGetFieldValueWithIndex() {
- assertEquals("getFieldValue:TIMESTAMP", "Jan 1 01:01:01", fEventContent1.getFieldValue(Index.TIMESTAMP));
- assertEquals("getFieldValue:HOST", "HostA", fEventContent1.getFieldValue(Index.HOST));
- assertEquals("getFieldValue:LOGGER", "LoggerA", fEventContent1.getFieldValue(Index.LOGGER));
- assertEquals("getFieldValue:MESSAGE", "MessageA", fEventContent1.getFieldValue(Index.MESSAGE));
- assertNull(fEventContent1.getFieldValue(4));
- }
-
- @Test
- public void testGetFieldValueWithName() {
- assertEquals("getFieldValue:TIMESTAMP", "Jan 1 01:01:01", fEventContent1.getFieldValue("Timestamp"));
- assertEquals("getFieldValue:HOST", "HostA", fEventContent1.getFieldValue("Host"));
- assertEquals("getFieldValue:LOGGER", "LoggerA", fEventContent1.getFieldValue("Logger"));
- assertEquals("getFieldValue:MESSAGE", "MessageA", fEventContent1.getFieldValue("Message"));
- assertNull(fEventContent1.getFieldValue("BlaBla"));
- }
-
- @Test
- public void testGetFieldNameWithIndex() {
-
- assertEquals("getFieldName:TIMESTAMP", SyslogEventType.LABELS[0], fEventContent1.getFieldName(Index.TIMESTAMP));
- assertEquals("getFieldName:HOST", SyslogEventType.LABELS[1], fEventContent1.getFieldName(Index.HOST));
- assertEquals("getFieldName:LOGGER", SyslogEventType.LABELS[2], fEventContent1.getFieldName(Index.LOGGER));
- assertEquals("getFieldName:MESSAGE", SyslogEventType.LABELS[3], fEventContent1.getFieldName(Index.MESSAGE));
- assertNull(fEventContent1.getFieldValue(4));
- }
-
- @Test
- public void testGetFields() {
- List<TextTraceEventContent> fields = fEventContent1.getFields();
- assertEquals(4, fields.size());
- assertEquals("getFields:TIMESTAMP", SyslogEventType.LABELS[0], fields.get(Index.TIMESTAMP).getName());
- assertEquals("getFields:TIMESTAMP", "Jan 1 01:01:01", fields.get(Index.TIMESTAMP).getValue());
- assertEquals("getFields:HOST", SyslogEventType.LABELS[1], fields.get(Index.HOST).getName());
- assertEquals("getFields:HOST", "HostA", fields.get(Index.HOST).getValue());
- assertEquals("getFields:LOGGER", SyslogEventType.LABELS[2], fields.get(Index.LOGGER).getName());
- assertEquals("getFields:LOGGER", "LoggerA", fields.get(Index.LOGGER).getValue());
- assertEquals("getFields:MESSAGE", SyslogEventType.LABELS[3], fields.get(Index.MESSAGE).getName());
- assertEquals("getFields:MESSAGE", "MessageA", fields.get(Index.MESSAGE).getValue());
- }
-
- @Test
- public void testGetFieldWithName() {
- ITmfEventField field = fEventContent1.getField("Timestamp");
- assertEquals("getFieldName:TIMESTAMP", SyslogEventType.LABELS[0], field.getName());
- assertEquals("getFieldName:TIMESTAMP", "Jan 1 01:01:01", field.getValue());
-
- field = fEventContent1.getField(SyslogEventType.LABELS[1]);
- assertEquals("getFieldName:HOST", SyslogEventType.LABELS[1], field.getName());
- assertEquals("getFieldName:HOST", "HostA", field.getValue());
-
- field = fEventContent1.getField(SyslogEventType.LABELS[2]);
- assertEquals("getFieldName:LOGGER", SyslogEventType.LABELS[2], field.getName());
- assertEquals("getFieldName:LOGGER", "LoggerA", field.getValue());
-
- field = fEventContent1.getField(SyslogEventType.LABELS[3]);
- assertEquals("getFieldName:Message", SyslogEventType.LABELS[3], field.getName());
- assertEquals("getgetFieldName:Message", "MessageA", field.getValue());
-
- field = fEventContent1.getField("BlaBla");
- assertNull(field);
- }
-
- @Test
- public void testGetFormattedValue() {
- assertEquals("CONTENT", fEventContent1.getFormattedValue());
- }
-
- @Test
- public void testToString() {
- assertEquals("Timestamp=Jan 1 01:01:01, Host=HostA, Logger=LoggerA, Message=MessageA", fEventContent1.toString());
- }
-
- @Test
- public void testGetSubField() {
- String[] names = { "Timestamp"};
-
- ITmfEventField field = fEventContent1.getSubField(names);
- assertEquals("getSubField:TIMESTAMP", SyslogEventType.LABELS[0], field.getName());
- assertEquals("getSubField:TIMESTAMP", "Jan 1 01:01:01", field.getValue());
-
- String[] names2 = { "Timestamp", "subField" };
- field = fEventContent1.getSubField(names2);
- assertNull(field);
- }
-
- @Test
- public void testGetFieldNames() {
- String[] labels = {"Timestamp", "Host", "Logger", "Message"};
- List<String> names = fEventContent1.getFieldNames();
- assertArrayEquals(labels, names.toArray(new String[names.size()]));
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceTest.java
deleted file mode 100644
index a8df8d27a8..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/text/TextTraceTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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:
- * Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace.text;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Locale;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TraceValidationStatus;
-import org.eclipse.linuxtools.tmf.core.trace.text.TextTraceEventContent;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.text.SyslogEvent;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.text.SyslogEventType.Index;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.text.SyslogTrace;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-@SuppressWarnings({ "nls", "javadoc"})
-public class TextTraceTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final String NAME = "syslog";
- private static final String PATH = "testfiles/" + NAME;
-
- private static final String OTHER_PATH = "testfiles/" + "A-Test-10K";
-
- private static SyslogTrace fTrace = null;
- private static File fTestFile = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @BeforeClass
- public static void setUp() throws Exception {
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
- defaultPreferences.put(ITmfTimePreferencesConstants.LOCALE, Locale.CANADA.toLanguageTag());
- TmfTimestampFormat.updateDefaultFormats();
-
- if (fTrace == null) {
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(PATH), null);
- URI uri = FileLocator.toFileURL(location).toURI();
- fTestFile = new File(uri);
-
- fTrace = new SyslogTrace();
- IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(PATH));
- fTrace.initTrace(resource, uri.getPath(), SyslogEvent.class);
- // Dummy request to force the trace indexing
- TmfEventRequest request = new TmfEventRequest(
- SyslogEvent.class,
- TmfTimeRange.ETERNITY,
- 0,
- ITmfEventRequest.ALL_DATA,
- ExecutionType.FOREGROUND) {
- };
- fTrace.sendRequest(request);
- request.waitForCompletion();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- @AfterClass
- public static void tearDown() {
- fTrace.dispose();
- fTrace = null;
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
- defaultPreferences.put(ITmfTimePreferencesConstants.LOCALE, Locale.getDefault().toLanguageTag());
- TmfTimestampFormat.updateDefaultFormats();
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- @Test
- public void testEmptyConstructor() {
- SyslogTrace trace = new SyslogTrace();
- assertEquals("getType", null, trace.getType());
- assertEquals("getPath", null, trace.getPath());
- assertEquals("getName", "", trace.getName());
- assertEquals("getCacheSize", 100, trace.getCacheSize());
-
- TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
- }
-
- @Test
- public void testValidation() throws URISyntaxException, IOException {
- SyslogTrace trace = new SyslogTrace();
- String validTracePath = fTestFile.getAbsolutePath();
- IStatus status = trace.validate(null, validTracePath);
- assertTrue(status.isOK());
- assertTrue(status instanceof TraceValidationStatus);
- assertEquals(180, ((TraceValidationStatus) status).getConfidence());
-
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(OTHER_PATH), null);
- URI uri = FileLocator.toFileURL(location).toURI();
- File otherFile = new File(uri);
-
- String validNoConfidenceTrace = otherFile.getAbsolutePath();
- status = trace.validate(null, validNoConfidenceTrace);
- assertTrue(status instanceof TraceValidationStatus);
- assertEquals(0, ((TraceValidationStatus) status).getConfidence());
- assertTrue(status.isOK());
-
- String invalidTrace = fTestFile.getParentFile().getAbsolutePath();
- status = trace.validate(null, invalidTrace);
- assertFalse(status.isOK());
- }
-
- @Test
- public void testInitTrace() throws Exception {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(PATH), null);
- String path = FileLocator.toFileURL(location).toURI().getPath();
- SyslogTrace trace = new SyslogTrace();
- IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(PATH));
- trace.initTrace(resource, path, SyslogEvent.class);
- assertEquals("getType", SyslogEvent.class, trace.getType());
- assertEquals("getPath", fTestFile.toURI().getPath(), trace.getPath());
- assertEquals("getName", NAME, trace.getName());
- assertEquals("getCacheSize", 100, trace.getCacheSize());
- }
-
- // ------------------------------------------------------------------------
- // Indexing
- // ------------------------------------------------------------------------
-
- @Test
- public void testTraceIndexing() {
- assertEquals("getNbEvents", 6, fTrace.getNbEvents());
-
- TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, fTrace.getInitialRangeOffset());
- }
-
- // ------------------------------------------------------------------------
- // Parsing
- // ------------------------------------------------------------------------
-
- @Test
- public void testTraceParsing() {
- ITmfContext context = fTrace.seekEvent(0);
- SyslogEvent event = fTrace.getNext(context);
- TextTraceEventContent content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 01:01:01", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 01:01:01", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostA", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerA", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "Message A", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 02:02:02", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 02:02:02", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostB", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerB", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "Message B", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 03:03:03", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 03:03:03", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostC", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerC", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "Message C", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 04:04:04", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 04:04:04", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostD", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerD", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "Message D", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 05:05:05", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 05:05:05", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostE", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerE", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getTimestamp", "Jan 1 06:06:06", event.getTimestamp().toString());
- assertEquals("getField:TIMESTAMP", "Jan 1 06:06:06", content.getFieldValue(Index.TIMESTAMP));
- assertEquals("getField:HOST", "HostF", content.getFieldValue(Index.HOST));
- assertEquals("getField:LOGGER", "LoggerF", content.getFieldValue(Index.LOGGER));
- assertEquals("getField:MESSAGE", "Message F", content.getFieldValue(Index.MESSAGE).toString());
- event = fTrace.getNext(context);
- assertEquals("event", null, event);
- context.dispose();
- }
-
- @Test
- public void testLocationRatio() {
- ITmfContext context = fTrace.seekEvent(3);
- double ratio = fTrace.getLocationRatio(context.getLocation());
- SyslogEvent event = fTrace.getNext(context);
- TextTraceEventContent content = event.getContent();
- Object logger = content.getFieldValue(Index.LOGGER);
- context.dispose();
- context = fTrace.seekEvent(ratio);
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getField:LOGGER", logger.toString(), content.getFieldValue(Index.LOGGER).toString());
- context.dispose();
- context = fTrace.seekEvent(0.0);
- event = fTrace.getNext(context);
- content = event.getContent();
- assertEquals("getField:LOGGER", "LoggerA", content.getFieldValue(Index.LOGGER));
- context.dispose();
- context = fTrace.seekEvent(1.0);
- event = fTrace.getNext(context);
- assertEquals("event", null, event);
- context.dispose();
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/AllTests.java
deleted file mode 100644
index 0fb01f8e78..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/AllTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.uml2sd;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Unit tests for tmf.core.uml2sd
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfAsyncSequenceDiagramEventTest.class,
- TmfSyncSequenceDiagramEventTest.class
-})
-public class AllTests {
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java
deleted file mode 100644
index 8c0d54c6d7..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.uml2sd;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.uml2sd.TmfAsyncSequenceDiagramEvent;
-
-import org.junit.Test;
-
-/**
- * TmfAsyncSequenceDiagramEventTest
- */
-public class TmfAsyncSequenceDiagramEventTest {
-
- private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
- private final String fTypeId = "Some type";
- private final String fLabel0 = "label1";
- private final String fLabel1 = "label2";
- private final String[] fLabels = new String[] { fLabel0, fLabel1 };
-
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
- private final String fSource = "Source";
- private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
- private final String fReference = "Some reference";
-
- private final ITmfEvent fEvent1;
- private final ITmfEvent fEvent2;
- private final TmfEventField fContent1;
- private final TmfEventField fContent2;
-
- /**
- * Constructor for the test case
- */
- public TmfAsyncSequenceDiagramEventTest() {
- fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content", null);
- fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference);
-
- fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some other content", null);
- fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType, fContent2, fReference);
- }
-
- /**
- * Main test
- */
- @Test
- public void testTmfAsyncSequenceDiagramEvent() {
- TmfAsyncSequenceDiagramEvent event = null;
-
- // Check for illegal arguments (i.e. null for the parameters)
- try {
- event = new TmfAsyncSequenceDiagramEvent(null, null, null, null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null"));
- }
-
- try {
- event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("sender=null"));
- }
-
- try {
- event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("receiver=null"));
- }
-
- try {
- event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, "sender", null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("name=null"));
- }
-
- try {
- event = new TmfAsyncSequenceDiagramEvent(fEvent1, null, "sender", "receiver", "signal");
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("endEvent=null"));
- }
-
- try {
- event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, "sender", "receiver", "signal");
- // success
- assertEquals("testTmfAsyncSequenceDiagramEvent", 0, event.getStartTime().compareTo(fTimestamp1, true));
- assertEquals("testTmfAsyncSequenceDiagramEvent", 0, event.getEndTime().compareTo(fTimestamp2, true));
- assertEquals("testTmfAsyncSequenceDiagramEvent", "sender", event.getSender());
- assertEquals("testTmfAsyncSequenceDiagramEvent", "receiver", event.getReceiver());
- assertEquals("testTmfAsyncSequenceDiagramEvent", "signal", event.getName());
-
- } catch (IllegalArgumentException e) {
- fail();
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java
deleted file mode 100644
index b8a6b157d4..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.uml2sd;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent;
-
-import org.junit.Test;
-
-/**
- * TmfSyncSequenceDiagramEventTest
- */
-public class TmfSyncSequenceDiagramEventTest {
-
- private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
- private final String fTypeId = "Some type";
- private final String fLabel0 = "label1";
- private final String fLabel1 = "label2";
- private final String[] fLabels = new String[] { fLabel0, fLabel1 };
-
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
- private final String fSource = "Source";
- private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
- private final String fReference = "Some reference";
-
- private final ITmfEvent fEvent1;
- private final TmfEventField fContent1;
-
- /**
- * Constructor for the test case
- */
- public TmfSyncSequenceDiagramEventTest() {
- fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content", null);
- fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference);
- }
-
- /**
- * Main test
- */
- @Test
- public void testTmfSyncSequenceDiagramEvent() {
- TmfSyncSequenceDiagramEvent event = null;
- try {
- event = new TmfSyncSequenceDiagramEvent(null, null, null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null"));
- }
-
- try {
- event = new TmfSyncSequenceDiagramEvent(fEvent1, null, null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("sender=null"));
- }
-
- try {
- event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", null, null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("receiver=null"));
- }
-
- try {
- event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", "receiver", null);
- fail();
- } catch (IllegalArgumentException e) {
- // success
- assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("name=null"));
- }
-
- try {
- event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", "receiver", "signal");
- // success
- assertEquals("testTmfSyncSequenceDiagramEvent", 0, event.getStartTime().compareTo(fTimestamp1, true));
- assertEquals("testTmfSyncSequenceDiagramEvent", "sender", event.getSender());
- assertEquals("testTmfSyncSequenceDiagramEvent", "receiver", event.getReceiver());
- assertEquals("testTmfSyncSequenceDiagramEvent", "signal", event.getName());
-
- } catch (IllegalArgumentException e) {
- fail();
- }
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/AllTests.java
deleted file mode 100644
index 172d2b44a1..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.util;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Unit tests for tmf.core.util
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- PairTest.class
-})
-public class AllTests {
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/PairTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/PairTest.java
deleted file mode 100644
index 9230525f63..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/PairTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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:
- * Bernd Hufmann - Initial design and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.tmf.core.util.Pair;
-import org.junit.Test;
-
-/**
- * Test case for Pair class.
- *
- * @author Bernd Hufmann
- */
-@SuppressWarnings("javadoc")
-public class PairTest {
-
- // ------------------------------------------------------------------------
- // Field(s)
- // ------------------------------------------------------------------------
-
- Pair<String, Long> fPair1 = new Pair<>("String 1", 1L);
- Pair<String, Long> fPair2 = new Pair<>("String 2", 2L);
-
- // ------------------------------------------------------------------------
- // to String
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String result = fPair1.toString();
- assertEquals("(String 1, 1)", result);
- }
-
- // ------------------------------------------------------------------------
- // Setters/Getters
- // ------------------------------------------------------------------------
-
- @Test
- public void testAccessors() {
- Pair<String, Long> myPair = new Pair<>("String 1", 1L);
- assertEquals("String 1", myPair.getFirst());
- assertEquals(Long.valueOf(1L), myPair.getSecond());
-
- myPair.setFirst("Hello");
- assertEquals("Hello", myPair.getFirst());
-
- myPair.setSecond(123L);
- assertEquals(Long.valueOf(123L), myPair.getSecond());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fPair1.equals(fPair1));
- assertTrue("equals", fPair2.equals(fPair2));
-
- assertTrue("equals", !fPair1.equals(fPair2));
- assertTrue("equals", !fPair2.equals(fPair1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- Pair<String, Long> info1 = new Pair<>(fPair1.getFirst(), fPair1.getSecond().longValue());
- Pair<String, Long> info2 = new Pair<>(fPair2.getFirst(), fPair2.getSecond().longValue());
-
- assertTrue("equals", info1.equals(fPair1));
- assertTrue("equals", fPair1.equals(info1));
-
- assertTrue("equals", info2.equals(fPair2));
- assertTrue("equals", fPair2.equals(info2));
- }
-
- @Test
- public void testEqualsTransivity() {
- Pair<String, Long> info1 = new Pair<>(fPair1.getFirst(), fPair1.getSecond().longValue());
- Pair<String, Long> info2 = new Pair<>(fPair1.getFirst(), fPair1.getSecond().longValue());
- Pair<String, Long> info3 = new Pair<>(fPair1.getFirst(), fPair1.getSecond().longValue());
-
- assertTrue("equals", info1.equals(info2));
- assertTrue("equals", info2.equals(info3));
- assertTrue("equals", info1.equals(info3));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !fPair1.equals(null));
- assertTrue("equals", !fPair2.equals(null));
- }
-
- @Test
- public void testEqualsDifferentObj() {
- Pair<Long, String> info = new Pair<>(1L, "String1");
- assertTrue("equals", !fPair1.equals(info));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- Pair<String, Long> info1 = new Pair<>(fPair1.getFirst(), fPair1.getSecond().longValue());
- Pair<String, Long> info2 = new Pair<>(fPair2.getFirst(), fPair2.getSecond().longValue());
-
- assertTrue("hashCode", fPair1.hashCode() == info1.hashCode());
- assertTrue("hashCode", fPair2.hashCode() == info2.hashCode());
-
- assertTrue("hashCode", fPair1.hashCode() != info2.hashCode());
- assertTrue("hashCode", fPair2.hashCode() != info1.hashCode());
- }
-}

Back to the top