use of org.eclipse.ceylon.common.config.Proxies in project ceylon by eclipse.
the class ProxiesTest method testProxyWithNonProxyHosts.
@Test
public void testProxyWithNonProxyHosts() throws Exception {
CeylonConfig testConfig = loadTestConfig("proxy+non-proxy-hosts.config");
Proxies proxies = getProxies(testConfig);
Proxy proxy = proxies.getProxy();
Assert.assertEquals("myproxy", proxy.getHost());
Assert.assertEquals(1234, proxy.getPort());
Authentication auth = Authentication.fromConfig(testConfig);
Assert.assertNull(auth.getProxyAuthenticator());
auth.installProxy();
Assert.assertEquals(null, auth.getProxyAuthenticator());
InetSocketAddress address = (InetSocketAddress) auth.getProxy().address();
Assert.assertEquals("myproxy", address.getHostName());
Assert.assertEquals(1234, address.getPort());
List<java.net.Proxy> selectedProxies = auth.getProxySelector().select(URI.create("http://anything"));
Assert.assertEquals(1, selectedProxies.size());
Assert.assertEquals(java.net.Proxy.Type.HTTP, selectedProxies.get(0).type());
Assert.assertEquals("myproxy", ((InetSocketAddress) selectedProxies.get(0).address()).getHostName());
Assert.assertEquals(1234, ((InetSocketAddress) selectedProxies.get(0).address()).getPort());
selectedProxies = auth.getProxySelector().select(URI.create("http://foo"));
Assert.assertEquals(1, selectedProxies.size());
Assert.assertEquals(java.net.Proxy.Type.DIRECT, selectedProxies.get(0).type());
Assert.assertNull(selectedProxies.get(0).address());
mockPrompt.assertSeenOnlyGivenPrompts();
}
Aggregations