Search in sources :

Example 1 with TestAnalysis

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);
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) TestAnalysis2(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 2 with TestAnalysis

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);
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Test(org.junit.Test)

Example 3 with TestAnalysis

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);
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 4 with TestAnalysis

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();
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) Test(org.junit.Test)

Example 5 with TestAnalysis

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();
        }
    }
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TestAnalysis2(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Aggregations

TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)16 Test (org.junit.Test)15 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)10 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)8 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)6 IStatus (org.eclipse.core.runtime.IStatus)3 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)3 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)3 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)2 TestAnalysis2 (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2)2 HashSet (java.util.HashSet)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)1