assertTrue(idempotentRepository.contains("foo"));
}
@Test
public void testWebserviceExceptionRollsBackTransactionAndIdempotentRepository() throws InterruptedException {
AuditLogDao auditLogDao = getMandatoryBean(AuditLogDao.class, "auditLogDao");
String message = "this message will be OK";
assertEquals(0, auditLogDao.getAuditCount(message));
MockEndpoint mockCompleted = getMockEndpoint("mock:out");
mockCompleted.setExpectedMessageCount(0);
MockEndpoint mockWs = getMockEndpoint("mock:ws");
mockWs.whenAnyExchangeReceived(new ExceptionThrowingProcessor("ws is down"));
try {
template.sendBodyAndHeader("direct:transacted", message, "messageId", "foo");
fail();
} catch (CamelExecutionException cee) {
assertEquals("ws is down", ExceptionUtils.getRootCause(cee).getMessage());
}
assertMockEndpointsSatisfied();
assertEquals(0, auditLogDao.getAuditCount(message)); // the insert was successful
IdempotentRepository idempotentRepository = getMandatoryBean(IdempotentRepository.class, "jdbcIdempotentRepository");
// the repository has not seen this messageId
assertTrue(!idempotentRepository.contains("foo"));
}