*/
public void testInitializeWithResourceInitializationException() throws Exception {
int documentCount = 20; // number of documents processed
int exceptionSequence = 1; // the sequence in which errors are produced
boolean exceptionThrown = false;
TestStatusCallbackListener listener = null;
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 (NullPointerException e) {
exceptionThrown = true;
} finally {
// check the results, if everything worked as expected
ManageOutputDevice.setAllSystemOutputToDefault();
assertEquals("The expected NullPointerException wasn't thrown!", true, exceptionThrown);
assertEquals(
"The cpm called the listener, that the cpm has finished - which normally could not be.",
false, listener.isFinished());
assertEquals("The aborted-method of the listener was called. (new behaviour?)", false,
listener.isAborted());
assertEquals("There are not as much exceptions as expected! ", 1, FunctionErrorStore
.getCount());
}
}