*/
public void testInitializeWithResourceInitializationException()
throws Exception {
int documentCount = 20; // number of documents processed
int exceptionSequence = 1; // the sequence in which errors are produced
TestStatusCallbackListener listener = null; // listener with which the
// status information are
// made available
boolean exceptionThrown = false; // flag, if the expected exception was
// thrown
ManageOutputDevice.setAllSystemOutputToNirvana();
try {
// setup CPM
CollectionProcessingEngine cpe = setupCpm(documentCount,
"ResourceInitializationException", exceptionSequence,
"initialize");
// Create and register a Status Callback Listener
listener = new CollectionReaderStatusCallbackListener(cpe);
cpe.addStatusCallbackListener(listener);
cpe.process();
// wait until cpm has finished
while (!listener.isFinished() && !listener.isAborted()) {
Thread.sleep(5);
}
} catch (ResourceInitializationException e) {
exceptionThrown = true;
} finally {
ManageOutputDevice.setAllSystemOutputToDefault();
// check the results, if everything worked as expected
assertEquals("The cpm didn't finish correctly! Abort was called.",
false, listener.isAborted());
assertEquals(
"The cpm called the listener, that the cpm has finished - which normally could not be.",
false, listener.isFinished());
assertEquals("There are not as much exceptions as expected! ", 1,
FunctionErrorStore.getCount());
assertEquals(
"The expected ResourceInitializationException was not fiven back to the programm. ",
true, exceptionThrown);