* @throws Exception
*/
public void testAeErrorRateThresholdTerminateModified2() throws Exception {
int exceptionSequence = 5;
int documentCount = 100; // number of documents processed
TestStatusCallbackListener listener = new TestStatusCallbackListener();
String functionName = "process";
String exceptionName = "AnnotatorProcessException";
ManageOutputDevice.setAllSystemOutputToNirvana();
// setup CPM
Object[] objs = setupConfigurableCpm(documentCount, exceptionName, exceptionSequence,
functionName);
CpeDescription cpeDesc = (CpeDescription) objs[0];
cpeDesc.setProcessingUnitThreadCount(1);
CpeIntegratedCasProcessor integratedProcessor = (CpeIntegratedCasProcessor) objs[1];
integratedProcessor.setActionOnMaxError("terminate");
integratedProcessor.setMaxErrorCount(5);
integratedProcessor.setMaxErrorSampleSize(10);
CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, null,
null);
// Create and register a Status Callback Listener
// listener = new CollectionReaderStatusCallbackListener(cpe);
cpe.addStatusCallbackListener(listener);
cpeProcessNoMsg(cpe, listener);
ManageOutputDevice.setAllSystemOutputToDefault();
// check the results, if everything worked as expected
assertEquals(
"The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
true, listener.isFinished());
assertEquals("The cpm didn't finish correctly! Abort in the listener was called.", false,
listener.isAborted());
assertEquals("There are not as much exceptions as expected! ", countExceptions(documentCount,
exceptionSequence), FunctionErrorStore.getCount());
// that's it.
}