当前位置: 首页>>代码示例>>Java>>正文


Java HttpProxyServer.start方法代码示例

本文整理汇总了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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SftpSimpleProduceThroughProxyTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SftpSimpleProduceThroughProxyTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:SftpSimpleProduceThroughProxyTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:SftpSimpleConsumeThroughProxyTest.java


注:本文中的org.littleshoot.proxy.HttpProxyServer.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。