*
* @return CollectionProcessingEngine - initialized cpe
*/
private CollectionProcessingEngine setupCpm(int documentCount, String exceptionName,
int exceptionSequence, String functionName) {
CpeDescription cpeDesc = null;
CollectionProcessingEngine cpe = null;
try {
String colReaderBase = JUnitExtension.getFile("CpmTests" + FS + "ErrorTestCollectionReader.xml").getAbsolutePath();
String taeBase = JUnitExtension.getFile("CpmTests" + FS + "ErrorTestAnnotator.xml").getAbsolutePath();
String casConsumerBase = JUnitExtension.getFile("CpmTests" + FS + "ErrorTestCasConsumer.xml").getAbsolutePath();
// first, prepare all descriptors as needed
String colReaderDesc = DescriptorMakeUtil.makeCollectionReader(colReaderBase, documentCount);
String taeDesc = DescriptorMakeUtil.makeAnalysisEngine(taeBase);
String casConsumerDesc = DescriptorMakeUtil.makeCasConsumer(casConsumerBase, true,
functionName, exceptionSequence, exceptionName);
// secondly, create the cpm based on the descriptors
cpeDesc = CpeDescriptorFactory.produceDescriptor();
// managing the default behaviour of this client
CpeIntegratedCasProcessor integratedProcessor = CpeDescriptorFactory
.produceCasProcessor("ErrorTestAnnotator");
integratedProcessor.setDescriptor(taeDesc);
integratedProcessor.setActionOnMaxError("terminate");
CpeIntegratedCasProcessor casConsumer = CpeDescriptorFactory
.produceCasProcessor("ErrorTest CasConsumer");
casConsumer.setDescriptor(casConsumerDesc);
// - add all descriptors
cpeDesc.addCollectionReader(colReaderDesc);
cpeDesc.addCasProcessor(integratedProcessor);
cpeDesc.addCasProcessor(casConsumer);
cpeDesc.setInputQueueSize(2);
cpeDesc.setOutputQueueSize(2);
cpeDesc.setProcessingUnitThreadCount(1);
// - Create a new CPE
cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, null, null);
} catch (Exception e) {
e.printStackTrace();
}