Search in sources :

Example 11 with SendEmail

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);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SendEmail(org.apache.camel.examples.SendEmail) Test(org.junit.Test)

Example 12 with SendEmail

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();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SendEmail(org.apache.camel.examples.SendEmail) Test(org.junit.Test)

Example 13 with SendEmail

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();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SendEmail(org.apache.camel.examples.SendEmail) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 14 with SendEmail

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);
}
Also used : SendEmail(org.apache.camel.examples.SendEmail) Test(org.junit.Test)

Example 15 with SendEmail

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());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SendEmail(org.apache.camel.examples.SendEmail) Test(org.junit.Test)

Aggregations

SendEmail (org.apache.camel.examples.SendEmail)16 Test (org.junit.Test)15 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)13 EntityManager (javax.persistence.EntityManager)3 Exchange (org.apache.camel.Exchange)3 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 JpaComponent (org.apache.camel.component.jpa.JpaComponent)2 JpaEndpoint (org.apache.camel.component.jpa.JpaEndpoint)2 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 Processor (org.apache.camel.Processor)1 ValueBuilder (org.apache.camel.builder.ValueBuilder)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1