@Test(expected = IOException.class) public void failedRequest() throws Exception { HttpClient client = TestHttpClient.empty(400); EurekaLoader loader = new EurekaLoader(client, uri, v -> true); loader.call(); }
@Override public List<ServerGroup> call() throws Exception { HttpResponse response = client.get(uri) .customizeLogging(entry -> entry.withEndpoint("/eureka/v2/apps")) .acceptGzip() .acceptJson() .send(); if (response.status() != 200) { throw new IOException("request failed with status " + response.status()); } String enc = response.header("Content-Encoding"); JsonParser jp = (enc != null && enc.contains("gzip")) ? jsonFactory.createParser(new GZIPInputStream(new ByteArrayInputStream(response.entity()))) : jsonFactory.createParser(response.entity()); return decodeApps(jp); }
EurekaLoader implements Loader { @Override public List<ServerGroup> call() throws Exception { HttpResponse response = client.get(uri) .customizeLogging(entry -> entry.withEndpoint("/eureka/v2/apps")) .acceptGzip() .acceptJson() .send(); if (response.status() != 200) { throw new IOException("request failed with status " + response.status()); } String enc = response.header("Content-Encoding"); JsonParser jp = (enc != null && enc.contains("gzip")) ? jsonFactory.createParser(new GZIPInputStream(new ByteArrayInputStream(response.entity()))) : jsonFactory.createParser(response.entity()); return decodeApps(jp); } }
EurekaLoader implements Loader { @Override public List<ServerGroup> call() throws Exception { HttpResponse response = client.get(uri) .customizeLogging(entry -> entry.withEndpoint("/eureka/v2/apps")) .acceptGzip() .acceptJson() .send(); if (response.status() != 200) { throw new IOException("request failed with status " + response.status()); } String enc = response.header("Content-Encoding"); JsonParser jp = (enc != null && enc.contains("gzip")) ? jsonFactory.createParser(new GZIPInputStream(new ByteArrayInputStream(response.entity()))) : jsonFactory.createParser(response.entity()); return decodeApps(jp); } EurekaLoader(HttpClient client, URI uri, Predicate<String> accounts); }
EurekaLoader implements Loader { @Override public List<ServerGroup> call() throws Exception { HttpResponse response = client.get(uri) .customizeLogging(entry -> entry.withEndpoint("/eureka/v2/apps")) .acceptGzip() .acceptJson() .send(); if (response.status() != 200) { throw new IOException("request failed with status " + response.status()); } String enc = response.header("Content-Encoding"); JsonParser jp = (enc != null && enc.contains("gzip")) ? jsonFactory.createParser(new GZIPInputStream(new ByteArrayInputStream(response.entity()))) : jsonFactory.createParser(response.entity()); return decodeApps(jp); } EurekaLoader(HttpClient client, URI uri, Predicate<String> accounts); @Override List<ServerGroup> call(); }
EurekaLoader implements Loader { @Override public List<ServerGroup> call() throws Exception { HttpResponse response = client.get(uri) .customizeLogging(entry -> entry.withEndpoint("/eureka/v2/apps")) .acceptGzip() .acceptJson() .send(); if (response.status() != 200) { throw new IOException("request failed with status " + response.status()); } String enc = response.header("Content-Encoding"); JsonParser jp = (enc != null && enc.contains("gzip")) ? jsonFactory.createParser(new GZIPInputStream(new ByteArrayInputStream(response.entity()))) : jsonFactory.createParser(response.entity()); return decodeApps(jp); } EurekaLoader(HttpClient client, URI uri, Predicate<String> accounts); @Override List<ServerGroup> call();  }