Java 8 Proxy - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Proxy class.

This code example shows how to use the following methods: address, type
		factoryBean.setPort(port);
		factoryBean.afterPropertiesSet();
 
		Proxy result = factoryBean.getObject();
 
		assertEquals(type, result.type());
		InetSocketAddress address = (InetSocketAddress) result.address();
		assertEquals(hostname, address.getHostName());
		assertEquals(port, address.getPort());
	} 
 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    if (strs.length != 2)
      throw new RuntimeException("Bad SOCKS proxy parameter: " + proxyStr);
    String host = strs[0];
    int port = Integer.parseInt(strs[1]);
    this.proxy =
        new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(host,
            port));
  } 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: address, toString, type
 
	/** 
	 * @tests java.net.Proxy#toString() 
	 */ 
	public void test_toString() { 
		Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
		// include type String 
		assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);
		// include address String 
		assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);
 
		proxy = new Proxy(Proxy.Type.SOCKS, address);
		// include type String 
		assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);
		// include address String 
		assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);
 
		proxy = Proxy.NO_PROXY;
		// include type String 
		assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: address, type
    } 
    return null; 
  } 
 
  private InetAddress getConnectToInetAddress(Proxy proxy, URL url) throws IOException {
    return (proxy != null && proxy.type() != Proxy.Type.DIRECT)
        ? ((InetSocketAddress) proxy.address()).getAddress()
        : InetAddress.getByName(url.getHost());
  } 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		Assert.notNull(type, "'type' must not be null"); 
		Assert.hasLength(hostname, "'hostname' must not be empty"); 
		Assert.isTrue(port >= 0 && port <= 65535, "'port' out of range: " + port); 
 
		SocketAddress socketAddress = new InetSocketAddress(hostname, port); 
		this.proxy = new Proxy(type, socketAddress); 
 
	} 
 
	@Override 
	public Proxy getObject() { 
		return proxy; 
	} 
 
	@Override 
	public Class<?> getObjectType() { 
		return Proxy.class; 
	} 
 
	@Override 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        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));
        assertEquals(Arrays.asList(new Proxy(Proxy.Type.HTTP, createUnresolved("b", 80))),
                proxySelector.select(httpUri));
        assertEquals(Arrays.asList(new Proxy(Proxy.Type.HTTP, createUnresolved("c", 443))),
                proxySelector.select(httpsUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(otherUri));
        assertEquals(Arrays.asList(Proxy.NO_PROXY), proxySelector.select(socketUri));
    } 
 
    public void testProxyHostPort() throws URISyntaxException { 
        System.setProperty("ftp.proxyHost", "a");
        System.setProperty("ftp.proxyPort", "1001");
        System.setProperty("http.proxyHost", "b");
        System.setProperty("http.proxyPort", "1002");
        System.setProperty("https.proxyHost", "c");
        System.setProperty("https.proxyPort", "1003");
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    assertTrue(getResponseAsString(client).contains("<body>"));
 
    target = new URL("https://www.google.com/selenium-server/core/Blank.html");
    client =
        target.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", port)));
    TrustEverythingSSLTrustManager.trustAllSSLCertificates((HttpsURLConnection) client);
 
    assertTrue(getResponseAsString(client).contains("<body>"));
  } 
 
  private String getResponseAsString(URLConnection client) {
    try { 
      byte[] bytes = ByteStreams.toByteArray(client.getInputStream());
      return new String(bytes);
    } catch (IOException e) {
      throw Throwables.propagate(e);
    } 
  } 
} 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: type
  /** 
   * Returns true if this route tunnels HTTPS through an HTTP proxy. See <a 
   * href="http://www.ietf.org/rfc/rfc2817.txt">RFC 2817, Section 5.2</a>. 
   */ 
  public boolean requiresTunnel() { 
    return address.sslSocketFactory != null && proxy.type() == Proxy.Type.HTTP;
  } 
 
  @Override public boolean equals(Object obj) { 
    if (obj instanceof Route) { 
      Route other = (Route) obj;
      return address.equals(other.address)
          && proxy.equals(other.proxy)
          && inetSocketAddress.equals(other.inetSocketAddress)
          && connectionSpec.equals(other.connectionSpec);
    } 
    return false; 
  } 
 
  @Override public int hashCode() { 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * @param proxyPort the port of the proxy. 
	 ************************************************************************/ 
	 
	public FixedSocksSelector(String proxyHost, int proxyPort) {
		super(new Proxy(Proxy.Type.SOCKS, 
				InetSocketAddress.createUnresolved(proxyHost, proxyPort)));
	} 
 
} 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: type
    public void test_type() { 
 
        Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
        assertEquals(Proxy.Type.HTTP, proxy.type());
 
        proxy = new Proxy(Proxy.Type.SOCKS, address);
        assertEquals(Proxy.Type.SOCKS, proxy.type());
 
        proxy = Proxy.NO_PROXY;
        assertEquals(Proxy.Type.DIRECT, proxy.type());
    } 
} 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Proxy Methods: