本文整理汇总了Java中org.littleshoot.proxy.HttpProxyServer.start方法的典型用法代码示例。如果您正苦于以下问题:Java HttpProxyServer.start方法的具体用法?Java HttpProxyServer.start怎么用?Java HttpProxyServer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.littleshoot.proxy.HttpProxyServer
的用法示例。
在下文中一共展示了HttpProxyServer.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSftpSimpleProduceThroughProxy
import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@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();
}
示例2: testSftpSimpleSubPathProduceThroughProxy
import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@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();
}
示例3: testSftpSimpleTwoSubPathProduceThroughProxy
import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@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();
}
示例4: testSftpSimpleConsumeThroughProxy
import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@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();
}