Search in sources :

Example 1 with ITmfStateProvider

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider in project tracecompass by tracecompass.

the class CounterStateProviderTest method testGetNewInstance.

/**
 * Test the cloning of a <code>CounterStateProvider</code> object.
 */
@Test
public void testGetNewInstance() {
    ITmfStateProvider clone = fStateProvider.getNewInstance();
    assertNotSame("The original CounterStateProvider and its clone do not share the same reference.", fStateProvider, clone);
    assertEquals(fStateProvider.getVersion(), clone.getVersion());
    assertEquals(fStateProvider.getTrace(), clone.getTrace());
}
Also used : ITmfStateProvider(org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider) Test(org.junit.Test)

Example 2 with ITmfStateProvider

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider in project tracecompass by tracecompass.

the class StateSystemAnalysisModuleTest method testFaultyStateProvider.

/**
 * Test the behavior of a state provider that causes a runtime exception at
 * different moments of the analysis. The analyses should be marked as
 * failed
 *
 * @throws TmfAnalysisException
 *             An exception when setting the trace
 */
@Test
public void testFaultyStateProvider() throws TmfAnalysisException {
    ITmfTrace trace = fTrace;
    assertNotNull(trace);
    // Test failure on the last event
    TmfStateSystemAnalysisModule module = new TestStateSystemModule() {

        @Override
        @NonNull
        protected ITmfStateProvider createStateProvider() {
            return new BreakingTest(trace, 7, "Expected exception: should be caught by the analysis itself");
        }
    };
    try {
        module.setTrace(trace);
        module.schedule();
        assertFalse(module.waitForCompletion());
    } finally {
        module.dispose();
    }
    // Test failure when the analysis the request finishes before the queue
    // is full
    module = new TestStateSystemModule() {

        @Override
        @NonNull
        protected ITmfStateProvider createStateProvider() {
            return new BreakingTest(trace, 5, "Expected exception: should be caught by either the analysis or the event request");
        }
    };
    try {
        module.setTrace(trace);
        module.schedule();
        assertFalse(module.waitForCompletion());
    } finally {
        module.dispose();
    }
    // Test failure when the queue should be full
    module = new TestStateSystemModule() {

        @Override
        @NonNull
        protected ITmfStateProvider createStateProvider() {
            return new BreakingTest(trace, 1, "Expected exception: should be caught by the event request thread");
        }
    };
    try {
        module.setTrace(trace);
        module.schedule();
        assertFalse(module.waitForCompletion());
    } finally {
        module.dispose();
    }
}
Also used : TmfStateSystemAnalysisModule(org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule) ITmfStateProvider(org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TestStateSystemModule(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemModule) NonNull(org.eclipse.jdt.annotation.NonNull) Test(org.junit.Test)

Aggregations

ITmfStateProvider (org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider)2 Test (org.junit.Test)2 NonNull (org.eclipse.jdt.annotation.NonNull)1 TmfStateSystemAnalysisModule (org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TestStateSystemModule (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemModule)1