use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FileToFtpTempFileNameTest method testFileToFtp.
@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());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FromFileToFtpDeleteTest method testFromFileToFtpDelete.
@Test
public void testFromFileToFtpDelete() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBodyAndHeader("file:target/delete", "Hello World", Exchange.FILE_NAME, "hello.txt");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
// file should be deleted
File file = new File("target/delete/hello.txt");
assertFalse("File should be deleted", file.exists());
// file should exists on ftp server
file = new File(FTP_ROOT_DIR + "/hello.txt");
assertTrue("File should exist on ftp server", file.exists());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FtpConsumerIdempotentMemoryRefTest method testIdempotent.
@Test
public void testIdempotent() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
getMockEndpoint("mock:result").expectedMessageCount(5);
sendFile(getFtpUrl(), "Hello A", "a.txt");
sendFile(getFtpUrl(), "Hello B", "b.txt");
sendFile(getFtpUrl(), "Hello C", "c.txt");
sendFile(getFtpUrl(), "Hello D", "d.txt");
sendFile(getFtpUrl(), "Hello E", "e.txt");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
assertEquals(5, repo.getCache().size());
assertTrue(repo.contains("a.txt"));
assertTrue(repo.contains("b.txt"));
assertTrue(repo.contains("c.txt"));
assertTrue(repo.contains("d.txt"));
assertTrue(repo.contains("e.txt"));
resetMocks();
notify = new NotifyBuilder(context).whenDone(2).create();
getMockEndpoint("mock:result").expectedMessageCount(2);
// duplicate
sendFile(getFtpUrl(), "Hello A", "a.txt");
sendFile(getFtpUrl(), "Hello B", "b.txt");
// new files
sendFile(getFtpUrl(), "Hello F", "f.txt");
sendFile(getFtpUrl(), "Hello G", "g.txt");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
assertEquals(5, repo.getCache().size());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FtpConsumerLocalWorkDirectoryDirectTest method testLocalWorkDirectory.
@Test
public void testLocalWorkDirectory() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
assertTrue("Should process one file", notify.matchesMockWaitTime());
// and the out file should exists
File out = new File("target/out/hello.txt");
assertTrue("file should exists", out.exists());
assertEquals("Hello World", IOConverter.toString(out, null));
// now the lwd file should be deleted
File local = new File("target/lwd/hello.txt");
assertFalse("Local work file should have been deleted", local.exists());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FileConsumeDoneFileIssueTest method testFileConsumeDoneFileIssue.
public void testFileConsumeDoneFileIssue() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
template.sendBodyAndHeader("file:target/done", "A", Exchange.FILE_NAME, "foo-a.txt");
template.sendBodyAndHeader("file:target/done", "B", Exchange.FILE_NAME, "foo-b.txt");
template.sendBodyAndHeader("file:target/done", "C", Exchange.FILE_NAME, "foo-c.txt");
template.sendBodyAndHeader("file:target/done", "D", Exchange.FILE_NAME, "foo-d.txt");
template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo-e.txt");
template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo.done");
assertTrue("Done file should exists", new File("target/done/foo.done").exists());
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A", "B", "C", "D", "E");
context.startRoute("foo");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
Thread.sleep(250);
// the done file should be deleted
assertFalse("Done file should be deleted", new File("target/done/foo.done").exists());
}
Aggregations