@Test public void noProxyConfiguration () { Properties oldProperties = System.getProperties(); Optional<ProxyConfiguration> proxyConfiguration; try { System.clearProperty("https.proxyHost"); System.clearProperty("https.proxyPort"); proxyConfiguration = cloudFoundryService.proxyConfiguration(); } finally { System.setProperties(oldProperties); } assertTrue(proxyConfiguration.isEmpty()); }
Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); }
CloudFoundryService implements CloudService { Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); } }
CloudFoundryService implements CloudService { Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); }  }
CloudFoundryService implements CloudService { Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); }  void setApiHost(String apiHost); void setPort(Integer port); void setUsername(String username); void setPassword(String password); void setOrganization(String organization); void setSpace(String space); }
CloudFoundryService implements CloudService { Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); }  void setApiHost(String apiHost); void setPort(Integer port); void setUsername(String username); void setPassword(String password); void setOrganization(String organization); void setSpace(String space);  }