Package org.apache.camel.builder

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


            }
        });

        context.start();

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

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

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

        Configuration conf = new Configuration();
        Path file1 = new Path("file:///" + file.toUri());
        FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
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-batch3", "CIAO", "CamelFileName", "CIAO" + i);
        }

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

        Configuration conf = new Configuration();
        Path file1 = new Path("file:///" + file.toUri());
        FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
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-batch4", "CIAO" + i, "CamelFileName", "CIAO" + i);
        }

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

        Configuration conf = new Configuration();
        Path file1 = new Path("file:///" + file.toUri());
        FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
View Full Code Here

            }
        });

        context.start();

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

        ByteBuffer bb = ByteBuffer.allocate(8 * 1024 * 1024);
        for (int i = 0; i < 8 * 1024 * 512; ++i) {
            bb.putChar('A');
        }
        for (int i = 0; i < 2; ++i) {
            template.sendBodyAndHeader("file://target/file-batch5", bb, "CamelFileName", "CIAO" + i);
        }

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

        Configuration conf = new Configuration();
        Path file1 = new Path("file:///" + file.toUri() + '/' + HdfsConstants.DEFAULT_SEGMENT_PREFIX + 0);
        FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
View Full Code Here

    protected String componentName = "activemq";

    @Test
    public void testRouteFileToFile() throws Exception {
        deleteDirectory("target/file2file");
        NotifyBuilder notify = new NotifyBuilder(context).from("activemq:queue:hello").whenDone(1).create();

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

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

        assertMockEndpointsSatisfied();

        notify.matchesMockWaitTime();

        File file = new File("./target/file2file/out/hello.txt");
        file = file.getAbsoluteFile();
        assertTrue("The file should exists", file.exists());
    }
View Full Code Here


            }
        });

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

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

        notify.matchesMockWaitTime();

        assertTrue("Expected only 1 calls to process() (1 failure) but encountered "
                   + getConditionalExceptionProcessor().getCount() + "."
                   , getConditionalExceptionProcessor().getCount() == 1);
    }
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);

        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 testRetryUntilRecipientListOkAndFail() throws Exception {
        invoked.set(0);

        NotifyBuilder event = event().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 = event.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 event = event().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 = event.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 event = event().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 = event.matches(10, TimeUnit.SECONDS);
        assertTrue(matches);

        context.stop();

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

TOP

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

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.