So I have gotten a bit further, but not all the way. It appears that if I have a unit test that is overloaded as I can do in TestNG, then I can seemingly re-use the same mock endpoints. Here is a valid test that is overloaded 3 different times:
[EMAIL PROTECTED](groups = {"functional"}) @Parameters({"startEndpointUri", "successEndpointUri", "errorEndpointUri", "messageInputBody"}) public void testCreateInvalidChangeRequest(String startEndpointUri, String successEndpointUri, String errorEndpointUri, String messageInputBody ) throws Exception { MockEndpoint mockSuccessEndpoint = getMockEndpoint(successEndpointUri); MockEndpoint mockFailureEndpoint = getMockEndpoint(errorEndpointUri); mockFailureEndpoint.expectedBodiesReceived(messageInputBody); mockFailureEndpoint.expectedMessageCount(1); mockSuccessEndpoint.expectedMessageCount(0); try { // Create and Send message to input queue camelContext.addRoutes( createRoute(startEndpointUri, changeRequestProcessor, successEndpointUri, errorEndpointUri ) ); producerTemplate.sendBody(startEndpointUri, messageInputBody); Assert.fail("Should have thrown a RuntimeCamelException"); } catch (RuntimeCamelException e) { assertIsInstanceOf(e, RuntimeCamelException.class); } // this is optional. testMocksAreValid(); MockEndpoint.assertIsSatisfied(mockFailureEndpoint, mockSuccessEndpoint); } * Now here is the kicker, when I have another test method in this class running with the same endpoint values: [EMAIL PROTECTED](groups = {"functional"}) @Parameters({"startEndpointUri", "successEndpointUri", "errorEndpointUri", "messageInputBody"}) public void testCreateValidRequest(String startEndpointUri, String successEndpointUri, String errorEndpointUri, String messageInputBody ) throws Exception { MockEndpoint mockSuccessEndpoint = getMockEndpoint(successEndpointUri); MockEndpoint mockFailureEndpoint = getMockEndpoint(errorEndpointUri); mockSuccessEndpoint.expectedMessageCount(1); mockSuccessEndpoint.message(0).header(Constants.REQUEST_DESTINATION).isEqualTo(Constants.CHANNEL_GG_CS_COMMAND_CLUSTER); mockFailureEndpoint.expectedMessageCount(0); try { // setup RouteBuilder... // Create and Send message to input queue camelContext.addRoutes( createRoute(startEndpointUri, changeRequestProcessor, successEndpointUri, errorEndpointUri ) ); // Create and Send message to input queue producerTemplate.sendBodyAndHeader(startEndpointUri, messageInputBody, Constants.COMMAND_TYPE, Constants.PROVISION); } catch (RuntimeCamelException e) { Assert.fail("Should have thrown a RuntimeCamelException"); } testMocksAreValid(); MockEndpoint.assertIsSatisfied(mockSuccessEndpoint, mockFailureEndpoint); } * * I get the following errors:* *<test name="InvalidChangeRequest-bad-commandType"> ..... <exception class="java.lang.AssertionError"> <message> <![CDATA[mock:error Received message count. Expected: <1> but was: <2>]]> </message> * So the mock:error queue is not getting cleaned up and there is an extra message. So how on earth do I DELETE or RESET or CLEAR this mock? I have spun through each one and ran mock.reset() but that did not help.