### Question:
ServiceSocksProxy extends AbstractIdleService { public InetSocketAddress getBindAddress() { InetSocketAddress addr = this.bindAddress; if (addr == null) { throw new IllegalStateException("Proxy server hasn't been started"); } return addr; } ServiceSocksProxy(DiscoveryServiceClient discoveryServiceClient,
                           ServiceSocksProxyAuthenticator authenticator); InetSocketAddress getBindAddress();  }### Answer:
@Test public void testDelayRegister() throws Exception { URL url = new URL("http: ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture<Cancellable> future = scheduler.schedule( () -> discoveryService.register(ResolvingDiscoverable.of(new Discoverable("test-service-2", httpService.getBindAddress()))), 2, TimeUnit.SECONDS); try { HttpResponse response = HttpRequests.execute(io.cdap.common.http.HttpRequest.get(url).build(), new HttpRequestConfig(5000, 5000)); Assert.assertEquals(200, response.getResponseCode()); } finally { future.get(5, TimeUnit.SECONDS).cancel(); } }
@Test (expected = SocketException.class) public void testAuthFailure() throws Exception { String oldPass = authPass; authPass += "xyz"; Cancellable cancellable = discoveryService.register( ResolvingDiscoverable.of(new Discoverable("test-auth-failure", httpService.getBindAddress()))); try { URL url = new URL("http: HttpRequests.execute(io.cdap.common.http.HttpRequest.get(url).build(), new DefaultHttpRequestConfig(false)); } finally { cancellable.cancel(); authPass = oldPass; } }
@Test (expected = SocketException.class) public void testNoAuth() throws Exception { Authenticator.setDefault(null); Cancellable cancellable = discoveryService.register( ResolvingDiscoverable.of(new Discoverable("test-no-auth", httpService.getBindAddress()))); try { URL url = new URL("http: HttpRequests.execute(io.cdap.common.http.HttpRequest.get(url).build(), new DefaultHttpRequestConfig(false)); } finally { cancellable.cancel(); Authenticator.setDefault(authenticator); } }