use of org.littleshoot.proxy.ProxyAuthorizationHandler in project camel by apache.
the class SftpSimpleProduceThroughProxyTest method testSftpSimpleTwoSubPathProduceThroughProxy.
@Test
public void testSftpSimpleTwoSubPathProduceThroughProxy() throws Exception {
if (!canTest()) {
return;
}
// start http proxy
HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
@Override
public boolean authenticate(String userName, String password) {
return "user".equals(userName) && "password".equals(password);
}
});
proxyServer.start();
template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub/myother?username=admin&password=admin&proxy=#proxy", "Farewell World", Exchange.FILE_NAME, "farewell.txt");
File file = new File(FTP_ROOT_DIR + "/mysub/myother/farewell.txt");
assertTrue("File should exist: " + file, file.exists());
assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class, file));
proxyServer.stop();
}
use of org.littleshoot.proxy.ProxyAuthorizationHandler in project camel by apache.
the class SftpSimpleConsumeThroughProxyTest method testSftpSimpleConsumeThroughProxy.
@Test
public void testSftpSimpleConsumeThroughProxy() throws Exception {
if (!canTest()) {
return;
}
// start http proxy
HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
@Override
public boolean authenticate(String userName, String password) {
return "user".equals(userName) && "password".equals(password);
}
});
proxyServer.start();
String expected = "Hello World";
// create file using regular file
template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt");
mock.expectedBodiesReceived(expected);
context.startRoute("foo");
assertMockEndpointsSatisfied();
proxyServer.stop();
}
use of org.littleshoot.proxy.ProxyAuthorizationHandler in project camel by apache.
the class SftpSimpleProduceThroughProxyTest method testSftpSimpleSubPathProduceThroughProxy.
@Test
public void testSftpSimpleSubPathProduceThroughProxy() throws Exception {
if (!canTest()) {
return;
}
// start http proxy
HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
@Override
public boolean authenticate(String userName, String password) {
return "user".equals(userName) && "password".equals(password);
}
});
proxyServer.start();
template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub?username=admin&password=admin&proxy=#proxy", "Bye World", Exchange.FILE_NAME, "bye.txt");
File file = new File(FTP_ROOT_DIR + "/mysub/bye.txt");
assertTrue("File should exist: " + file, file.exists());
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
proxyServer.stop();
}
use of org.littleshoot.proxy.ProxyAuthorizationHandler in project camel by apache.
the class SftpSimpleProduceThroughProxyTest method testSftpSimpleProduceThroughProxy.
@Test
public void testSftpSimpleProduceThroughProxy() throws Exception {
if (!canTest()) {
return;
}
// start http proxy
HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
@Override
public boolean authenticate(String userName, String password) {
return "user".equals(userName) && "password".equals(password);
}
});
proxyServer.start();
template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&proxy=#proxy", "Hello World", Exchange.FILE_NAME, "hello.txt");
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));
proxyServer.stop();
}
Aggregations