use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FromFileToHdfsTest method testTwoFilesToHdfs.
@Test
public void testTwoFilesToHdfs() throws Exception {
if (!canTest()) {
return;
}
NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
template.sendBodyAndHeader("file:target/inbox", "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader("file:target/inbox", "Bye World", Exchange.FILE_NAME, "bye.txt");
notify.matchesMockWaitTime();
File delete = new File("target/inbox/hello.txt");
assertTrue("File should be deleted " + delete, !delete.exists());
delete = new File("target/inbox/bye.txt");
assertTrue("File should be deleted " + delete, !delete.exists());
File create = new File(TEMP_DIR + "/output.txt");
assertTrue("File should be created " + create, create.exists());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FromFileToHdfsTest method testFileToHdfs.
@Test
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");
assertTrue("File should be created " + create, create.exists());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FromFileToHdfsTest method testTwoFilesToHdfs.
@Test
public void testTwoFilesToHdfs() throws Exception {
if (!canTest()) {
return;
}
NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
template.sendBodyAndHeader("file:target/inbox", "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader("file:target/inbox", "Bye World", Exchange.FILE_NAME, "bye.txt");
notify.matchesMockWaitTime();
File delete = new File("target/inbox/hello.txt");
assertTrue("File should be deleted " + delete, !delete.exists());
delete = new File("target/inbox/bye.txt");
assertTrue("File should be deleted " + delete, !delete.exists());
File create = new File(TEMP_DIR + "/output.txt");
assertTrue("File should be created " + create, create.exists());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FileIdempotentReadLockTest method testIdempotentReadLock.
public void testIdempotentReadLock() throws Exception {
assertEquals(0, myRepo.getCacheSize());
NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
template.sendBodyAndHeader("file:target/changed/in", "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader("file:target/changed/in", "Bye World", Exchange.FILE_NAME, "bye.txt");
assertMockEndpointsSatisfied();
assertTrue(notify.matches(5, TimeUnit.SECONDS));
// the files are kept on commit
// if you want to remove them then the idempotent repo need some way to evict idle keys
assertEquals(2, myRepo.getCacheSize());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FromFilePollThirdTimeOkTest method testPollFileAndShouldBeDeletedAtThirdPoll.
public void testPollFileAndShouldBeDeletedAtThirdPoll() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
template.sendBodyAndHeader("file://target/deletefile", body, Exchange.FILE_NAME, "hello.txt");
context.startRoute("FromFilePollThirdTimeOkTest");
getMockEndpoint("mock:result").expectedBodiesReceived(body);
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
assertEquals(3, counter);
// assert the file is deleted
File file = new File("target/deletefile/hello.txt");
assertFalse("The file should have been deleted", file.exists());
}
Aggregations