targetMethod = "index",
action = "throw new RuntimeException(\"Byteman said: Error in document creation!\")",
name = "testErrorInBuildingLuceneDocumentGetsCaughtByErrorHandler")
public void testErrorInBuildingLuceneDocumentGetsCaughtByErrorHandler() throws Exception {
MockErrorHandler mockErrorHandler = getErrorHandlerAndAssertCorrectTypeIsUsed();
AssertingMassIndexerProgressMonitor progressMonitor = new AssertingMassIndexerProgressMonitor( 0, 1 );
indexSingleFooInstance();
massIndexFooInstances( progressMonitor );
String errorMessage = mockErrorHandler.getErrorMessage();
Assert.assertTrue( "Wrong error code: " + errorMessage, errorMessage.startsWith( "HSEARCH000183" ) );
Throwable exception = mockErrorHandler.getLastException();
Assert.assertTrue( exception instanceof RuntimeException );
Assert.assertEquals( "Byteman said: Error in document creation!", exception.getMessage() );
progressMonitor.assertExpectedProgressMade();
}