use of org.apache.camel.component.file.remote.SftpEndpoint in project camel by apache.
the class SftpSetCipherTest method testSftpSetCipherName.
@Test
public void testSftpSetCipherName() throws Exception {
if (!canTest()) {
return;
}
String cipher = "blowfish-cbc";
String uri = "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&ciphers=" + cipher;
template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "hello.txt");
// test setting the cipher doesn't interfere with message payload
File file = new File(FTP_ROOT_DIR + "/hello.txt");
assertTrue("File should exist: " + file, file.exists());
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
// did we actually set the correct cipher?
SftpEndpoint endpoint = context.getEndpoint(uri, SftpEndpoint.class);
assertEquals(cipher, endpoint.getConfiguration().getCiphers());
}
use of org.apache.camel.component.file.remote.SftpEndpoint in project camel by apache.
the class SftpSetOperationsTest method testSftpSetOperations.
@Test
public void testSftpSetOperations() throws Exception {
if (!canTest()) {
return;
}
String preferredAuthentications = "password,publickey";
String uri = "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&ciphers=blowfish-cbc" + "&preferredAuthentications=password,publickey";
template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "hello.txt");
// test setting the cipher doesn't interfere with message payload
File file = new File(FTP_ROOT_DIR + "/hello.txt");
assertTrue("File should exist: " + file, file.exists());
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
// did we actually set the preferedAuthentifications
SftpEndpoint endpoint = context.getEndpoint(uri, SftpEndpoint.class);
assertEquals(preferredAuthentications, endpoint.getConfiguration().getPreferredAuthentications());
}
use of org.apache.camel.component.file.remote.SftpEndpoint in project camel by apache.
the class SftpConsumerAutoCreateTest method testNoAutoCreate.
@Test
public void testNoAutoCreate() throws Exception {
SftpEndpoint endpoint = (SftpEndpoint) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=false");
endpoint.start();
try {
endpoint.getExchanges();
fail("Should fail with 550 No such directory.");
} catch (GenericFileOperationFailedException ignored) {
// ignore
}
}
use of org.apache.camel.component.file.remote.SftpEndpoint in project camel by apache.
the class SftpConsumerAutoCreateTest method testAutoCreate.
@Test
public void testAutoCreate() throws Exception {
if (!canTest()) {
return;
}
SftpEndpoint endpoint = (SftpEndpoint) this.getMandatoryEndpoint(getFtpUrl());
endpoint.start();
endpoint.getExchanges();
assertTrue(new File(FTP_ROOT_DIR + "/foo/bar/baz/xxx").exists());
// producer should create necessary subdirs
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "sub1/sub2/hello.txt");
assertTrue(new File(FTP_ROOT_DIR + "/foo/bar/baz/xxx/sub1/sub2").exists());
// to see if another connect causes problems with autoCreate=true
endpoint.stop();
endpoint.start();
endpoint.getExchanges();
}
Aggregations