Best code examples for Java 8 ProxySelector class (java.net.ProxySelector)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ProxySelector class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 ProxySelector examples from Open Source projects
This code example shows how to use the following methods: select
        System.clearProperty("socksProxyHost");
        System.clearProperty("socksProxyPort");
    } 
 
    public void testNoProxySystemProperty() throws URISyntaxException { 
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(ftpUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(httpUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(httpsUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(socketUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(otherUri));
    } 
 
    public void testProxyHostOnly() throws URISyntaxException { 
        System.setProperty("ftp.proxyHost", "a");
        System.setProperty("http.proxyHost", "b");
        System.setProperty("https.proxyHost", "c");
        System.setProperty("other.proxyHost", "d");
        System.setProperty("socket.proxyHost", "d");
        assertEquals(Arrays.asList(new Proxy(Proxy.Type.HTTP, createUnresolved("a", 80))),
                proxySelector.select(ftpUri));
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: select
        System.clearProperty("proxyHost");
        System.clearProperty("proxyPort");
    } 
 
    public void testNoProxySystemProperty() throws URISyntaxException { 
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(ftpUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(httpUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(httpsUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(socketUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(otherUri));
    } 
 
    public void testProxyHostOnly() throws URISyntaxException { 
        System.setProperty("ftp.proxyHost", "a");
        System.setProperty("http.proxyHost", "b");
        System.setProperty("https.proxyHost", "c");
        System.setProperty("other.proxyHost", "d");
        System.setProperty("socket.proxyHost", "d");
        assertEquals(Arrays.asList(new Proxy(Proxy.Type.HTTP, createUnresolved("a", 80))),
                proxySelector.select(ftpUri));
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: select
 
  private List<Proxy> selectDefault(final URI uri)
  { 
    if (defaultSelector != null)
    { 
      return defaultSelector.select(uri);
    } 
 
    final List<Proxy> list = new ArrayList<Proxy>();
    list.add(Proxy.NO_PROXY);
    return list;
  } 
 
  /** 
   * Called to indicate that a connection could not be established 
   * to a proxy/socks server. An implementation of this method can 
   * temporarily remove the proxies or reorder the sequence of 
   * proxies returned by select(String, String), using the address 
   * and they kind of IOException given. 
   * 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: select
  private void resetNextProxy(URI uri, Proxy proxy) {
    this.hasNextProxy = true; // This includes NO_PROXY!
    if (proxy != null) {
      this.userSpecifiedProxy = proxy;
    } else { 
      List<Proxy> proxyList = proxySelector.select(uri);
      if (proxyList != null) {
        this.proxySelectorProxies = proxyList.iterator();
      } 
    } 
  } 
 
  /** Returns true if there's another proxy to try. */ 
  private boolean hasNextProxy() { 
    return hasNextProxy;
  } 
 
  /** Returns the next proxy to try. May be PROXY.NO_PROXY but never null. */ 
  private Proxy nextProxy() {
    // If the user specifies a proxy, try that and only that. 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: select
See Code Examples for Java 8 ProxySelector Methods: