public Object doInJpa(EntityManager entityManager) throws PersistenceException {
// lets delete any exiting records before the test
entityManager.createQuery("delete from " + entityName).executeUpdate();
// now lets create a dummy entry
MultiSteps dummy = new MultiSteps("cheese");
dummy.setStep(4);
entityManager.persist(dummy);
return null;
}
});
List results = jpaTemplate.find(queryText);
assertEquals("Should have no results: " + results, 0, results.size());
// lets produce some objects
template.send(endpoint, new Processor() {
public void process(Exchange exchange) {
exchange.getIn().setBody(new MultiSteps("foo@bar.com"));
}
});
// now lets assert that there is a result
results = jpaTemplate.find(queryText);
assertEquals("Should have results: " + results, 1, results.size());
MultiSteps mail = (MultiSteps)results.get(0);
assertEquals("address property", "foo@bar.com", mail.getAddress());
// now lets create a consumer to consume it
consumer = endpoint.createConsumer(new Processor() {
public void process(Exchange e) {
LOG.info("Received exchange: " + e.getIn());