use of org.apache.camel.processor.idempotent.MemoryIdempotentRepository in project camel by apache.
the class FtpBrowsableEndpointTest method testBrowsableTwoFiles.
@Test
public void testBrowsableTwoFiles() throws Exception {
template.sendBodyAndHeader(getFtpUrl(), "A", Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(getFtpUrl(), "B", Exchange.FILE_NAME, "b.txt");
FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl() + "&sortBy=file:name", FtpEndpoint.class);
assertNotNull(endpoint);
MemoryIdempotentRepository repo = (MemoryIdempotentRepository) endpoint.getInProgressRepository();
assertEquals(0, repo.getCacheSize());
List<Exchange> list = endpoint.getExchanges();
assertNotNull(list);
assertEquals(2, list.size());
assertEquals("a.txt", list.get(0).getIn().getHeader(Exchange.FILE_NAME));
assertEquals("b.txt", list.get(1).getIn().getHeader(Exchange.FILE_NAME));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the files is still there
File fileA = new File(FTP_ROOT_DIR + "/browse/a.txt");
assertTrue("File should exist " + fileA, fileA.exists());
File fileB = new File(FTP_ROOT_DIR + "/browse/b.txt");
assertTrue("File should exist " + fileB, fileB.exists());
}
use of org.apache.camel.processor.idempotent.MemoryIdempotentRepository in project camel by apache.
the class FtpConsumerIdempotentMemoryRefTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
repo = new MemoryIdempotentRepository();
repo.setCacheSize(5);
jndi.bind("myRepo", repo);
return jndi;
}
use of org.apache.camel.processor.idempotent.MemoryIdempotentRepository in project camel by apache.
the class FtpBrowsableEndpointTest method testBrowsableThreeFilesRecursive.
@Test
public void testBrowsableThreeFilesRecursive() throws Exception {
template.sendBodyAndHeader(getFtpUrl(), "A", Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(getFtpUrl(), "B", Exchange.FILE_NAME, "foo/b.txt");
template.sendBodyAndHeader(getFtpUrl(), "C", Exchange.FILE_NAME, "bar/c.txt");
FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl() + "&recursive=true&sortBy=file:name", FtpEndpoint.class);
assertNotNull(endpoint);
MemoryIdempotentRepository repo = (MemoryIdempotentRepository) endpoint.getInProgressRepository();
assertEquals(0, repo.getCacheSize());
List<Exchange> list = endpoint.getExchanges();
assertNotNull(list);
assertEquals(3, list.size());
assertEquals("a.txt", list.get(0).getIn().getHeader(Exchange.FILE_NAME));
assertEquals("c.txt", list.get(1).getIn().getHeader(Exchange.FILE_NAME_ONLY));
assertEquals("b.txt", list.get(2).getIn().getHeader(Exchange.FILE_NAME_ONLY));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the files is still there
File fileA = new File(FTP_ROOT_DIR + "/browse/a.txt");
assertTrue("File should exist " + fileA, fileA.exists());
File fileB = new File(FTP_ROOT_DIR + "/browse/foo/b.txt");
assertTrue("File should exist " + fileB, fileB.exists());
File fileC = new File(FTP_ROOT_DIR + "/browse/bar/c.txt");
assertTrue("File should exist " + fileC, fileC.exists());
}
use of org.apache.camel.processor.idempotent.MemoryIdempotentRepository in project camel by apache.
the class FtpBrowsableEndpointTest method testBrowsableOneFile.
@Test
public void testBrowsableOneFile() throws Exception {
template.sendBodyAndHeader(getFtpUrl(), "A", Exchange.FILE_NAME, "a.txt");
FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class);
assertNotNull(endpoint);
MemoryIdempotentRepository repo = (MemoryIdempotentRepository) endpoint.getInProgressRepository();
assertEquals(0, repo.getCacheSize());
List<Exchange> list = endpoint.getExchanges();
assertNotNull(list);
assertEquals(1, list.size());
assertEquals("a.txt", list.get(0).getIn().getHeader(Exchange.FILE_NAME));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the file is still there
File file = new File(FTP_ROOT_DIR + "/browse/a.txt");
assertTrue("File should exist " + file, file.exists());
}
use of org.apache.camel.processor.idempotent.MemoryIdempotentRepository in project camel by apache.
the class FileBrowsableEndpointTest method testBrowsableOneFile.
public void testBrowsableOneFile() throws Exception {
template.sendBodyAndHeader("file:target/browse", "A", Exchange.FILE_NAME, "a.txt");
FileEndpoint endpoint = context.getEndpoint("file:target/browse", FileEndpoint.class);
assertNotNull(endpoint);
MemoryIdempotentRepository repo = (MemoryIdempotentRepository) endpoint.getInProgressRepository();
assertEquals(0, repo.getCacheSize());
List<Exchange> list = endpoint.getExchanges();
assertNotNull(list);
assertEquals(1, list.size());
assertEquals("a.txt", list.get(0).getIn().getHeader(Exchange.FILE_NAME));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the file is still there
File file = new File("target/browse/a.txt");
assertTrue("File should exist " + file, file.exists());
}
Aggregations