use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaRoutemaxMessagesPerPollTest method testRouteJpa.
@Test
public void testRouteJpa() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
template.sendBody("direct:start", new SendEmail("one@somewhere.org"));
template.sendBody("direct:start", new SendEmail("two@somewhere.org"));
template.sendBody("direct:start", new SendEmail("three@somewhere.org"));
assertMockEndpointsSatisfied();
assertEntityInDB(3);
}
use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaRouteConsumeLockEntityTest method testRouteJpa.
@Test
public void testRouteJpa() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBody("direct:start", new SendEmail("one@somewhere.org"));
assertMockEndpointsSatisfied();
}
use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaRouteSharedEntityManagerTest method testRouteJpaShared.
@Test
public void testRouteJpaShared() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
int countStart = getBrokerCount();
assertThat("brokerCount", countStart, equalTo(1));
template.sendBody("direct:startShared", new SendEmail("one@somewhere.org"));
// start route
context.startRoute("jpaShared");
// not the cleanest way to check the number of open connections
int countEnd = getBrokerCount();
assertThat("brokerCount", countEnd, equalTo(1));
latch.countDown();
assertMockEndpointsSatisfied();
}
use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaNonTXRollbackTest method testNonTXRollback.
@Test
public void testNonTXRollback() throws Exception {
// first create three records
template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("foo@beer.org"));
template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("bar@beer.org"));
template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("kaboom@beer.org"));
// should only rollback the failed
getMockEndpoint("mock:start").expectedMinimumMessageCount(5);
// and only the 2 good messages goes here
getMockEndpoint("mock:result").expectedMessageCount(2);
// start route
context.startRoute("foo");
assertMockEndpointsSatisfied();
assertEquals(1, foo.intValue());
assertEquals(1, bar.intValue());
// kaboom fails and we retry it again
assertTrue("Should be >= 2, was: " + kaboom.intValue(), kaboom.intValue() >= 2);
}
use of org.apache.camel.examples.SendEmail in project camel by apache.
the class JpaPreConsumedTest method testPreConsumed.
@Test
public void testPreConsumed() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBody("direct:start", new SendEmail("dummy"));
assertMockEndpointsSatisfied();
// @PreConsumed should change the dummy address
SendEmail email = mock.getReceivedExchanges().get(0).getIn().getBody(SendEmail.class);
assertEquals("dummy@somewhere.org", email.getAddress());
}
Aggregations