use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class AnalysisModuleTest method testWaitForCompletionCancelled.
/**
* Test suite for {@link TmfAbstractAnalysisModule#waitForCompletion} with
* cancellation
*/
@Test
public void testWaitForCompletionCancelled() {
TestAnalysis module = setUpAnalysis();
try {
/* Set a stub trace for analysis */
ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
try {
assertTrue(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());
} finally {
module.dispose();
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class AnalysisModuleTest method testSetWrongTrace.
/**
* Test the {@link TmfAbstractAnalysisModule#setTrace(ITmfTrace)} method
* with wrong trace
*/
@Test
public void testSetWrongTrace() {
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());
try {
assertFalse(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
} catch (TmfAnalysisException e) {
fail();
}
module.dispose();
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class AnalysisModuleTest method testWaitForCompletionSuccess.
/**
* Test suite for analysis module
* {@link TmfAbstractAnalysisModule#waitForCompletion} with successful
* execution
*/
@Test
public void testWaitForCompletionSuccess() {
TestAnalysis module = setUpAnalysis();
IStatus status = module.schedule();
assertEquals(IStatus.ERROR, status.getSeverity());
/* Set a stub trace for analysis */
try {
assertTrue(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());
module.dispose();
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class AnalysisModuleTest method testCancel.
/**
* Test suite for the {@link TmfAbstractAnalysisModule#cancel()} method
*/
@Test
public void testCancel() {
TestAnalysis module = setUpAnalysis();
module.setParameter(TestAnalysis.PARAM_TEST, 999);
try {
assertTrue(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
} catch (TmfAnalysisException e) {
fail(e.getMessage());
}
IStatus schedule = module.schedule();
assertEquals(Status.OK_STATUS, 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());
module.dispose();
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class AnalysisModuleTest method testParameterChanged.
/**
* Test suite for the {@link IAnalysisModule#notifyParameterChanged(String)}
* method
*/
@Test
public void testParameterChanged() {
TestAnalysis module = setUpAnalysis();
try {
assertTrue(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
*/
module.dispose();
}
Aggregations