use of org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis in project tracecompass by tracecompass.
the class TmfExperimentUtilsTest method testGetModuleByClass.
/**
* Test the
* {@link TmfExperimentUtils#getAnalysisModuleOfClassForHost(TmfExperiment, String, Class)}
* method
*/
@Test
public void testGetModuleByClass() {
Class<@NonNull TestAnalysis> commonClass = TestAnalysis.class;
Class<@NonNull TestAnalysis2> notCommonClass = TestAnalysis2.class;
String host1 = TmfTestTrace.A_TEST_10K.getPath();
String host2 = TmfTestTrace.A_TEST_10K2.getPath();
TmfExperiment experiment = fExperiment;
assertNotNull(experiment);
/* Common module for trace 1 */
TestAnalysis module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, commonClass);
assertNotNull(module1);
/* Make sure this module belongs to the trace */
IAnalysisModule sameModule = null;
for (IAnalysisModule mod : fTraces[0].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
/* Uncommon module from trace 1 */
TestAnalysis2 module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, notCommonClass);
assertNull(module2);
/* Common module for trace 1 */
module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, commonClass);
assertNotNull(module1);
/* Make sure this module belongs to the trace */
sameModule = null;
for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
/* Uncommon module from trace 1 */
module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, notCommonClass);
assertNotNull(module2);
/* Make sure this module belongs to the trace */
sameModule = null;
for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
}
use of org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis in project tracecompass by tracecompass.
the class TmfTraceTest method testGetModules.
// ------------------------------------------------------------------------
// State system, statistics and modules methods
// ------------------------------------------------------------------------
@Test
public void testGetModules() {
/* 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();
assertTrue(modules.iterator().hasNext());
/*
* Make sure all modules of type TestAnalysis are returned in the second
* call
*/
int count = 0;
for (IAnalysisModule module : modules) {
if (module instanceof TestAnalysis) {
count++;
IAnalysisModule otherModule = fTrace.getAnalysisModule(module.getId());
assertNotNull(otherModule);
assertEquals(otherModule, module);
}
}
/*
* FIXME: The exact count depends on the context the test is run (full
* test suite or this file only), but there must be at least 2 modules
*/
assertTrue(count >= 2);
}
use of org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis in project tracecompass by tracecompass.
the class TmfTraceUtilsTest method testGetModulesByClassForHost.
/**
* Test the {@link TmfTraceUtils#getAnalysisModuleOfClass} method.
*/
@Test
public void testGetModulesByClassForHost() {
TmfTrace trace = fTrace;
assertNotNull(trace);
/*
* Open the trace, the modules should be populated and make sure the signal is
* received by the trace manager
*/
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
trace.traceOpened(signal);
TmfTraceManager.getInstance().traceOpened(signal);
Iterable<TestAnalysis> testModules = TmfTraceUtils.getAnalysisModulesOfClass(trace.getHostId(), TestAnalysis.class);
assertTrue(testModules.iterator().hasNext());
/*
* FIXME: The exact count depends on the context the test is run (full test
* suite or this file only), but there must be at least 2 modules
*/
assertTrue(Iterables.size(testModules) >= 2);
}
use of org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis in project tracecompass by tracecompass.
the class AnalysisListenerTest method testNewModuleListener.
/**
* Test if the listener was created by using a manually created module
*/
@Test
public void testNewModuleListener() {
TestAnalysis module = new TestAnalysis();
module.setName(MODULE_GENERIC_NAME);
module.setId(MODULE_GENERIC_ID);
int countBefore = NewModuleListenerStub.getModuleCount();
TmfAnalysisManager.analysisModuleCreated(module);
/*
* The listener should have run on this module and the count increment
* by 1
*/
assertEquals(countBefore + 1, NewModuleListenerStub.getModuleCount());
module.dispose();
}
use of org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis in project tracecompass by tracecompass.
the class AnalysisModuleHelperTest method testNewModule.
/**
* Test the
* {@link TmfAnalysisModuleHelperConfigElement#newModule(ITmfTrace)} method
* for the 2 modules
*/
@Test
public void testNewModule() {
/* Test analysis module with traceStub */
IAnalysisModule module = null;
try {
module = fModule.newModule(TmfTestTrace.A_TEST_10K.getTrace());
assertNotNull(module);
assertTrue(module instanceof TestAnalysis);
} catch (TmfAnalysisException e) {
fail();
} finally {
if (module != null) {
module.dispose();
}
}
/* TestAnalysis2 module with trace, should return an exception */
try {
module = fModuleOther.newModule(TmfTestTrace.A_TEST_10K.getTrace());
assertNull(module);
} catch (TmfAnalysisException e) {
fail();
} finally {
if (module != null) {
module.dispose();
}
}
/* TestAnalysis2 module with a TraceStub2 */
ITmfTrace trace = fTrace;
assertNotNull(trace);
try {
module = fModuleOther.newModule(trace);
assertNotNull(module);
assertTrue(module instanceof TestAnalysis2);
} catch (TmfAnalysisException e) {
fail();
} finally {
if (module != null) {
module.dispose();
}
}
}
Aggregations