Package org.apache.camel.builder

Examples of org.apache.camel.builder.NotifyBuilder$ExchangeNotifier


    /**
     * Convenient api to create a NotifyBuilder to be notified of a specific event
     */
    protected NotifyBuilder event() {
        return new NotifyBuilder(context);
    }
View Full Code Here


        deleteDirectory("./target/deletefile");
        super.setUp();
    }

    public void testPollFileAndShouldBeDeletedAtThirdPoll() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();

        template.sendBodyAndHeader("file://target/deletefile", body, Exchange.FILE_NAME, "hello.txt");

        getMockEndpoint("mock:result").expectedBodiesReceived(body);
        // 2 first attempt should fail
        getMockEndpoint("mock:error").expectedMessageCount(2);

        assertMockEndpointsSatisfied();
        notify.matchesMockWaitTime();

        assertEquals(3, counter);

        // assert the file is deleted
        File file = new File("./target/deletefile/hello.txt");
View Full Code Here

    }

    public void testRetryUntilRecipientListFailOnly() throws Exception {
        invoked.set(0);

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        getMockEndpoint("mock:result").expectedMessageCount(0);
        getMockEndpoint("mock:foo").expectedMessageCount(0);

        template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "fail");

        assertMockEndpointsSatisfied();

        // wait until its done before we stop and check that retry was invoked
        boolean matches = notify.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

        assertEquals(3, invoked.get());
View Full Code Here

    }

    public void testRetryUntilRecipientListFailAndOk() throws Exception {
        invoked.set(0);

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        getMockEndpoint("mock:result").expectedMessageCount(0);
        getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);

        template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "fail,direct:foo");

        assertMockEndpointsSatisfied();

        // wait until its done before we stop and check that retry was invoked
        boolean matches = notify.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

        assertEquals(3, invoked.get());
View Full Code Here

    }

    public void testRetryUntilRecipientListOkAndFail() throws Exception {
        invoked.set(0);

        NotifyBuilder notify = new NotifyBuilder(context).whenFailed(1).create();

        getMockEndpoint("mock:result").expectedMessageCount(0);
        getMockEndpoint("mock:foo").expectedMessageCount(1);

        template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "direct:foo,fail");

        assertMockEndpointsSatisfied();

        // wait until its done before we stop and check that retry was invoked
        boolean matches = notify.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

        assertEquals(3, invoked.get());
View Full Code Here

    }

    public void testRetryUntilRecipientFailAndNotFail() throws Exception {
        invoked.set(0);

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        getMockEndpoint("mock:result").expectedMessageCount(0);
        getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);

        template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "fail,not-fail");

        assertMockEndpointsSatisfied();

        // wait until its done before we stop and check that retry was invoked
        boolean matches = notify.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

        assertEquals(3, invoked.get());
View Full Code Here

    }

    public void testRetryUntilRecipientNotFailAndFail() throws Exception {
        invoked.set(0);

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        getMockEndpoint("mock:result").expectedMessageCount(0);
        getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);

        template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "not-fail,fail");

        assertMockEndpointsSatisfied();

        // wait until its done before we stop and check that retry was invoked
        boolean matches = notify.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

        assertEquals(3, invoked.get());
View Full Code Here

*/
public class FileToFtpTempFileNameTest extends FtpServerTestSupport {

    @Test
    public void testFileToFtp() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        template.sendBodyAndHeader("file:target/in", "Hello World", Exchange.FILE_NAME, "sub/hello.txt");

        assertTrue(notify.matchesMockWaitTime());

        File file = new File(FTP_ROOT_DIR + "out/sub/hello.txt");
        assertTrue("File should exists " + file, file.exists());
    }
View Full Code Here

        return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/tx/JavaDSLTransactionTest.xml");
    }

    protected void assertResult() throws InterruptedException {
        // should be 1 completed and 1 failed
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();

        template.sendBody("activemq:queue:foo", "blah");

        notify.matchesMockWaitTime();

        assertTrue("Expected only 2 calls to process() (1 failure, 1 success) but encountered "
                   + getConditionalExceptionProcessor().getCount() + "."
                   , getConditionalExceptionProcessor().getCount() == 2);
    }
View Full Code Here

            }
        });

        context.start();

        NotifyBuilder nb = new NotifyBuilder(context).whenDone(10).create();

        for (int i = 0; i < 10; ++i) {
            template.sendBodyAndHeader("file://target/file-batch1/", "CIAO", "CamelFileName", "CIAO" + i);
        }

        Assert.assertTrue("Timeout waiting for match" + nb.toString(), nb.matchesMockWaitTime());
        context.stop();

        InputStream in = null;
        try {
            in = new URL("file:///" + file.toUri()).openStream();
View Full Code Here

TOP

Related Classes of org.apache.camel.builder.NotifyBuilder$ExchangeNotifier

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.