Package org.apache.camel.builder

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


    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


        RoutesDefinition routes = resource.getRoutesResource().getRouteDefinitions();
        List<RouteDefinition> list = routes.getRoutes();
        Object exchangesCompleted = statistics.getRouteStatistic(camelContext, list.get(0).getId(), "ExchangesCompleted");
        assertEquals("JMX value incorrect, should be 0", new Long(0), exchangesCompleted);

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

        ProducerTemplate template = camelContext.createProducerTemplate();
        template.sendBody("seda:foo", "test");

        notify.matchesMockWaitTime();

        exchangesCompleted = statistics.getRouteStatistic(camelContext, list.get(0).getId(), "ExchangesCompleted");
        assertEquals("JMX value incorrect, should be 1", new Long(1), exchangesCompleted);
    }
View Full Code Here

    }

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

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

        context.stop();

        assertEquals(3, invoked.get());
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

            }
        });

        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(1).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 < 1; ++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

    public void testFileToHdfs() throws Exception {
        if (!canTest()) {
            return;
        }

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

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

        notify.matchesMockWaitTime();

        File delete = new File("target/inbox/hello.txt");
        assertTrue("File should be deleted " + delete, !delete.exists());

        File create = new File(TEMP_DIR + "/output.txt");
View Full Code Here

TOP

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

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.