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


Java Proxy.setPort方法代码示例

本文整理汇总了Java中org.apache.maven.settings.Proxy.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java Proxy.setPort方法的具体用法?Java Proxy.setPort怎么用?Java Proxy.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.settings.Proxy的用法示例。


在下文中一共展示了Proxy.setPort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUnAuthorizedProxyRequest

import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
@Test
public void testUnAuthorizedProxyRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello Proxy!")));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello Proxy!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:17,代码来源:HttpClientFactoryTest.java

示例2: testAuthorixedProxyRequest

import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
@Test
public void testAuthorixedProxyRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).withHeader("Proxy-Authorization", matching("Basic Zm9vOmJhcg=="))
            .willReturn(aResponse().withBody("Hello Proxy!"))
            .atPriority(1));
    proxyServer.stubFor(any(urlMatching(".*"))
            .willReturn(aResponse().withStatus(407).withHeader("Proxy-Authenticate", "Basic"))
            .atPriority(2));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");
    proxy.setUsername("foo");
    proxy.setPassword("bar");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello Proxy!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:24,代码来源:HttpClientFactoryTest.java

示例3: testNonProxiedHostRequest

import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
@Test
public void testNonProxiedHostRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello Proxy!")));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");
    proxy.setNonProxyHosts("localhost|example.com");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello World!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:18,代码来源:HttpClientFactoryTest.java

示例4: testConstructorWithProxy

import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
@Test
public void testConstructorWithProxy() {
    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(8080);
    proxy.setProtocol("http");

    assertNotNull(new CoverallsProxyClient("http://test.com/coveralls", proxy));
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:10,代码来源:CoverallsProxyClientTest.java


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