use of java.net.ProxySelector in project sonarqube by SonarSource.
the class DefaultHttpDownloaderTest method shouldGetProxySynthesis.
@Test
public void shouldGetProxySynthesis() throws URISyntaxException {
ProxySelector proxySelector = mock(ProxySelector.class);
when(proxySelector.select(any(URI.class))).thenReturn(Arrays.asList(new FakeProxy()));
assertThat(DefaultHttpDownloader.BaseHttpDownloader.getProxySynthesis(new URI("http://an_url"), proxySelector)).isEqualTo("HTTP proxy: /123.45.67.89:4040");
}
use of java.net.ProxySelector in project dbeaver by serge-rider.
the class SocksProxyImpl method setupProxyHandler.
private static void setupProxyHandler() {
if (ProxySelector.getDefault() instanceof GlobalProxySelector) {
return;
}
activateProxyService();
// Init default network settings
ProxySelector defProxySelector = GeneralUtils.adapt(DBWorkbench.getPlatform(), ProxySelector.class);
if (defProxySelector == null) {
defProxySelector = new GlobalProxySelector(ProxySelector.getDefault());
}
ProxySelector.setDefault(defProxySelector);
}
use of java.net.ProxySelector in project zm-mailbox by Zimbra.
the class TestSocks method testSystemProxy.
public void testSystemProxy() throws Exception {
ProxySelector ps = ProxySelectors.nativeProxySelector();
assertNotNull(ps);
List<Proxy> proxies = ps.select(new URI("socket://www.vmware.com"));
assertEquals(1, proxies.size());
Proxy proxy = proxies.get(0);
assertEquals(Proxy.Type.SOCKS, proxy.type());
assertEquals(PROXY_ADDR, proxy.address());
}
use of java.net.ProxySelector in project zm-mailbox by Zimbra.
the class TestSocks method testHttpProxy.
public void testHttpProxy() throws Exception {
ProxySelector ps = ProxySelectors.defaultProxySelector();
List<Proxy> proxies = ps.select(new URI(HTTP_URL));
for (Proxy proxy : proxies) {
System.out.println("proxy = " + proxy);
}
URLConnection conn = new URL(HTTPS_URL).openConnection();
conn.setConnectTimeout(3000);
conn.connect();
conn.getInputStream().read();
}
use of java.net.ProxySelector in project grpc-java by grpc.
the class ProxyDetectorImplTest method setUp.
@Before
public void setUp() throws Exception {
proxySelectorSupplier = new Supplier<ProxySelector>() {
@Override
public ProxySelector get() {
return proxySelector;
}
};
proxyDetector = new ProxyDetectorImpl(proxySelectorSupplier, authenticator, null);
unresolvedProxy = InetSocketAddress.createUnresolved("10.0.0.1", proxyPort);
proxySocketAddress = HttpConnectProxiedSocketAddress.newBuilder().setTargetAddress(destination).setProxyAddress(new InetSocketAddress(InetAddress.getByName(unresolvedProxy.getHostName()), proxyPort)).build();
}
Aggregations