List of usage examples for org.springframework.web.client RestTemplate getForObject
@Override @Nullable public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException
From source file:nodequeryclient.Account.java
private String getAccount() { String uri = "https://nodequery.com/api/account?api_key=" + api; RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject(uri, String.class); System.out.println(result);//from w ww .j av a2 s .com return result; }
From source file:bq.tutorial.netflix.hystrix.StatusPressureTest.java
/** * more test thread pool size than command thread pool, to cause many rejected error *//*from w ww . ja v a2 s.co m*/ @Test(invocationCount = 2000, threadPoolSize = 20) public void testStatusRejected() { RestTemplate client = new RestTemplate(); String result = client.getForObject("http://localhost:8080/netflix_hystrix/mvc/pressure", String.class); System.out.println(result); }
From source file:bq.tutorial.netflix.hystrix.StatusPressureTest.java
/** * less test thread pool size, to avoid service rejected error and make shortcircuit error *//*from w ww . ja v a2 s .c om*/ @Test(invocationCount = 2000, threadPoolSize = 5) public void testStatusCircuited() { RestTemplate client = new RestTemplate(); String result = client.getForObject("http://localhost:8080/netflix_hystrix/mvc/pressure", String.class); System.out.println(result); }
From source file:dk.sublife.docker.integration.ContainerRestAdapter.java
/** * Check if rest service is up and return response. * * @param url of the service to call//from ww w . java2 s . c o m * @return response * @throws Exception */ protected String isUp(URL url) throws Exception { final RestTemplate restTemplate = new RestTemplate(); return restTemplate.getForObject(url.toString(), String.class); }
From source file:bq.tutorial.netflix.hystrix.DynamicTest.java
@Test(invocationCount = 2000, threadPoolSize = 20) public void testStatusRejected() { String commandName = "name" + (int) (Math.random() * 100); float failPercent = (float) Math.random(); float timeoutPercent = (float) Math.random(); int percentToBreakCircuit = (int) (Math.random() * 50 + 50); String queryString = "?name=" + commandName + "&failPercent=" + failPercent + "&timeoutPercent=" + timeoutPercent + "&percentToBreakCircuit=" + percentToBreakCircuit; RestTemplate client = new RestTemplate(); String result = client.getForObject("http://localhost:8080/netflix_hystrix/mvc/dynamic" + queryString, String.class); System.out.println(result);/*from w w w.j a v a 2s . c o m*/ }
From source file:org.cbioportal.genome_nexus.annotation.service.internal.VEPVariantAnnotationService.java
public String getRawAnnotation(String variant) { //http://grch37.rest.ensembl.org/vep/human/hgvs/VARIANT?content-type=application/json&xref_refseq=1&ccds=1&canonical=1&domains=1&hgvs=1&numbers=1&protein=1 String uri = vepURL.replace("VARIANT", variant); RestTemplate restTemplate = new RestTemplate(); return restTemplate.getForObject(uri, String.class); }
From source file:io.spring.initializr.web.support.SpringBootMetadataReader.java
/** * Parse the content of the metadata at the specified url */// w ww . j a va2s .com public SpringBootMetadataReader(RestTemplate restTemplate, String url) { this.content = new JSONObject(restTemplate.getForObject(url, String.class)); }
From source file:com.ge.predix.acs.monitoring.UaaHealthIndicatorTest.java
private RestTemplate mockRestWithUp() { RestTemplate restTemplate = Mockito.mock(RestTemplate.class); Mockito.when(restTemplate.getForObject(this.uaaCheckHealthUrl, String.class)).thenReturn("OK"); return restTemplate; }
From source file:net.longfalcon.newsj.service.RegexService.java
public void checkRegexesUptoDate(String latestRegexUrl, int latestRegexRevision) { RestTemplate restTemplate = new RestTemplate(); String responseString = restTemplate.getForObject(latestRegexUrl, String.class); Pattern pattern = Pattern.compile("\\/\\*\\$Rev: (\\d{3,4})", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(responseString); if (matcher.find()) { int revision = Integer.parseInt(matcher.group(1)); if (revision > latestRegexRevision) { _log.info(//from w w w . ja va 2 s .c o m "URL " + latestRegexUrl + " reports new regexes. Run the following SQL at your own risk:"); _log.info(responseString); } } }
From source file:com.ge.predix.acs.monitoring.UaaHealthIndicatorTest.java
private RestTemplate mockRestWithException() { RestTemplate restTemplate = Mockito.mock(RestTemplate.class); Mockito.when(restTemplate.getForObject(this.uaaCheckHealthUrl, String.class)) .thenThrow(new RuntimeException()); return restTemplate; }