Package org.apache.camel.examples

Examples of org.apache.camel.examples.SendEmail


    @Test
    public void testRouteJpa() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);

        template.sendBody("direct:start", new SendEmail("one@somewhere.org"));

        assertMockEndpointsSatisfied();
    }
View Full Code Here


    @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();
    }
View Full Code Here

    protected JpaTemplate jpaTemplate;

    @Test
    public void testTXRollback() 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 rollback the entire
        MockEndpoint mock = getMockEndpoint("mock:result");
        // we should retry and try again
        mock.expectedMinimumMessageCount(4);
View Full Code Here

            public void configure() throws Exception {
                from("jpa://" + SendEmail.class.getName() + "?consumer.transacted=true&delay=1000").routeId("foo").noAutoStartup()
                        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange) throws Exception {
                                SendEmail send = exchange.getIn().getBody(SendEmail.class);
                                if ("kaboom@beer.org".equals(send.getAddress())) {
                                    throw new IllegalArgumentException("Forced");
                                }

                                if ("foo@beer.org".equals(send.getAddress())) {
                                    foo.incrementAndGet();
                                } else if ("bar@beer.org".equals(send.getAddress())) {
                                    bar.incrementAndGet();
                                }
                            }
                        })
                        .to("mock:result");
View Full Code Here

    @Test
    public void testRouteJpa() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);

        template.sendBody("direct:start", new SendEmail("someone@somewhere.org"));

        assertMockEndpointsSatisfied();
        assertEntityInDB();
    }
View Full Code Here

        assertNotNull("Should have been auto assigned", jpa.getTransactionManager());

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);

        template.sendBody("direct:start", new SendEmail("someone@somewhere.org"));

        assertMockEndpointsSatisfied();
        assertEntityInDB();
    }
View Full Code Here

        Map<Integer, Future<Object>> responses = new ConcurrentHashMap<Integer, Future<Object>>();
        for (int i = 0; i < files; i++) {
            final int index = i;
            Future<Object> out = executor.submit(new Callable<Object>() {
                public Object call() throws Exception {
                    template.sendBody("direct:start", new SendEmail("user" + index + "@somewhere.org"));
                    return null;
                }
            });
            responses.put(index, out);
        }
View Full Code Here

    protected JpaTemplate jpaTemplate;

    @Test
    public void testBatchConsumer() throws Exception {
        // first create two records
        template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("foo@beer.org"));
        template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("bar@beer.org"));

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(2);
        mock.message(0).property(Exchange.BATCH_INDEX).isEqualTo(0);
        mock.message(0).property(Exchange.BATCH_COMPLETE).isEqualTo(false);
View Full Code Here

    @Test
    public void testRouteJpa() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMinimumMessageCount(1);

        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();

        // should not consume 3 at once
View Full Code Here

    protected JpaTemplate jpaTemplate;

    @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);
View Full Code Here

TOP

Related Classes of org.apache.camel.examples.SendEmail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.