use of org.springframework.web.client.RestTemplate in project steve by RWTH-i5-IDSG.
the class GithubReleaseCheckService method init.
@PostConstruct
private void init() {
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setReadTimeout(API_TIMEOUT_IN_MILLIS);
factory.setConnectTimeout(API_TIMEOUT_IN_MILLIS);
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.SnakeCaseStrategy());
restTemplate = new RestTemplate(Collections.singletonList(new MappingJackson2HttpMessageConverter(mapper)));
restTemplate.setRequestFactory(factory);
}
use of org.springframework.web.client.RestTemplate in project lavagna by digitalfondue.
the class ApiHooksService method executeScript.
private static boolean executeScript(String name, CompiledScript script, Map<String, Object> scope) {
try {
ScriptContext newContext = new SimpleScriptContext();
Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
engineScope.putAll(scope);
engineScope.put("log", LOG);
engineScope.put("GSON", Json.GSON);
engineScope.put("restTemplate", new RestTemplate());
script.eval(newContext);
return true;
} catch (ScriptException ex) {
LOG.warn("Error while executing script " + name, ex);
return false;
}
}
use of org.springframework.web.client.RestTemplate in project selenium_java by sergueik.
the class TestSteps method checkHomePage.
@Then("Home page is accessible")
public void checkHomePage() throws IOException {
String baseUrl = System.getProperty("docker.url");
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(baseUrl, String.class);
assertThat("Default 'Hello World!' string expected", result, is("Hello World!"));
}
use of org.springframework.web.client.RestTemplate in project tutorials by eugenp.
the class ApiClient method buildRestTemplate.
/**
* Build the RestTemplate used to make HTTP requests.
* @return RestTemplate
*/
protected RestTemplate buildRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
// This allows us to read the response more than once - Necessary for debugging.
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
return restTemplate;
}
use of org.springframework.web.client.RestTemplate in project tutorials by eugenp.
the class RestTemplateBasicLiveTest method givenResourceUrl_whenSendGetForRequestEntity_thenBodyCorrect.
@Test
public void givenResourceUrl_whenSendGetForRequestEntity_thenBodyCorrect() throws IOException {
final RestTemplate template = new RestTemplate();
final ResponseEntity<String> response = template.getForEntity(fooResourceUrl + "/1", String.class);
final ObjectMapper mapper = new ObjectMapper();
final JsonNode root = mapper.readTree(response.getBody());
final JsonNode name = root.path("name");
assertThat(name.asText(), notNullValue());
}
Aggregations