本文整理汇总了Java中org.apache.maven.settings.Proxy.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java Proxy.setHost方法的具体用法?Java Proxy.setHost怎么用?Java Proxy.setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Proxy
的用法示例。
在下文中一共展示了Proxy.setHost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例4: testProxy
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
@Test
public void testProxy() {
Proxy proxy = new Proxy();
proxy.setActive(true);
proxy.setProtocol("http");
proxy.setHost("myhost");
Settings settings = new Settings();
settings.setProxies(Collections.singletonList(proxy));
when(mavenSession.getSettings()).thenReturn(settings);
Log log = mock(Log.class);
ScannerFactory factory = new ScannerFactory(logOutput, log, runtimeInformation, mojoExecution, mavenSession, envProps, propertyDecryptor);
factory.create();
assertThat(System.getProperty("http.proxyHost")).isEqualTo("myhost");
}
示例5: 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));
}