【发布时间】:2015-01-26 15:00:39
【问题描述】:
我正在尝试构建一个需要联系外部服务器的 Junit/Integration 测试。但是,我无法通过代理。我收到 407 空白身份验证页面错误。
我使用的测试设置
@Before
public void onSetUp() throws Exception {
System.setProperty("http.proxyHost", "webproxy-nl.test.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("https.proxyHost", "webproxy-nl.test.com");
System.setProperty("https.proxyPort", "8080");
System.setProperty("http.proxyUser", "DOM\\lalal");
System.setProperty("http.proxyPassword", "tesssst");
System.setProperty("https.proxyUser", "DOM\\lalala");
System.setProperty("https.proxyPassword", "sldjsdkl");
}
现在所有代理设置都是 100% 正确的。我还添加了一些非代理主机。
我不知道我还能在这里配置什么。
返回信息是:
Http request failed: HTTP/1.1 407 BlankAuthenticationPage [status code 407]
更新
我构建了一个使用 CloseableHttpClient 的测试存根。这仍然给了我 http 407 错误。
private CloseableHttpClient httpClient;
public IDealHttpClientStub() {
LOG.debug("Creating IDealHttpClientStub");
System.setProperty("http.proxyHost", "webproxy-nl.test.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("https.proxyHost", "webproxy-nl.test.com");
System.setProperty("https.proxyPort", "8080");
System.setProperty("http.proxyUser", "DOM\\lalal");
System.setProperty("http.proxyPassword", "tesssst");
System.setProperty("https.proxyUser", "DOM\\lalala");
System.setProperty("https.proxyPassword", "sldjsdkl");
this.httpClient = HttpClients.custom().useSystemProperties().build();
}
【问题讨论】:
标签: apache junit4 apache-httpclient-4.x http-proxy