use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaProducerRemoveTest method testRouteJpa.
@Test
public void testRouteJpa() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
context.startRoute("foo");
context.startRoute("foo1");
JpaEndpoint jpa = context.getEndpoint("jpa://" + SendEmail.class.getName(), JpaEndpoint.class);
EntityManagerFactory emf = jpa.getEntityManagerFactory();
EntityManager entityManager = emf.createEntityManager();
template.sendBody("direct:start", new SendEmail("foo@beer.org"));
Exchange exchange = mock.getReceivedExchanges().get(0);
SendEmail persistedEntity = exchange.getIn().getBody(SendEmail.class);
SendEmail emfindEntity = entityManager.find(SendEmail.class, persistedEntity.getId());
assertNotSame(emfindEntity, persistedEntity);
entityManager.close();
mock.reset();
entityManager = emf.createEntityManager();
template.sendBody("direct:remove", persistedEntity);
exchange = mock.getReceivedExchanges().get(0);
persistedEntity = exchange.getIn().getBody(SendEmail.class);
emfindEntity = entityManager.find(SendEmail.class, persistedEntity.getId());
assertNull(emfindEntity);
entityManager.close();
}
Aggregations