List of usage examples for org.springframework.http ResponseEntity getStatusCodeValue
public int getStatusCodeValue()
From source file:com.github.ljtfreitas.restify.http.spring.client.request.EndpointResponseConverter.java
@Override public EndpointResponse<Object> convert(ResponseEntity<Object> source) { StatusCode status = StatusCode.of(source.getStatusCodeValue()); Headers headers = headersOf(source.getHeaders()); return new EndpointResponse<>(status, headers, source.getBody()); }
From source file:net.nfpj.webcounter.api.HealthIT.java
/** * Test of health method./*from w ww . j av a 2 s .c o m*/ */ @Test public void testHealthGet() { ResponseEntity<String> entity = restTemplate.getForEntity("/health", String.class); assertEquals("Unexpected response status: " + entity.getStatusCodeValue(), 200, entity.getStatusCodeValue()); assertEquals("{ \"status\": \"up\" }", entity.getBody()); }
From source file:net.nfpj.webcounter.api.HealthIT.java
@Test public void testHealthPost() { ResponseEntity<String> entity = restTemplate.postForEntity("/health", "", String.class); assertEquals("Unexpected response status: " + entity.getStatusCodeValue(), 200, entity.getStatusCodeValue()); assertEquals("{ \"status\": \"up\" }", entity.getBody()); }
From source file:example.pki.SslPkiTests.java
/** * The configured client truststore contains just the Root CA certificate. The * intermediate and server certificates are provided by the server SSL configuration. *///from w w w . ja v a2s . c o m @Test public void shouldWorkWithGeneratedSslCertificate() { RestTemplate restTemplate = new RestTemplate(configuredWrapper.getClientHttpRequestFactory()); ResponseEntity<String> response = restTemplate.getForEntity("https://localhost:" + port, String.class); assertThat(response.getStatusCodeValue()).isEqualTo(200); assertThat(response.getBody()).isEqualTo("Hello, World"); }
From source file:org.schedoscope.metascope.controller.MetascopeAdminControllerTest.java
@Test public void sometest() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.set("Referer", "/test"); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); ResponseEntity<String> response = this.restTemplate.exchange("/admin/sync", HttpMethod.POST, entity, String.class); assertEquals(302, response.getStatusCodeValue()); assertTrue(response.getHeaders().get("Location").get(0).endsWith("/test")); }
From source file:net.nfpj.webcounter.api.HealthIT.java
@Test public void testNotFound() { ResponseEntity<String> entity = restTemplate.getForEntity("/health/invalid/", String.class); System.out.println(entity.getBody()); assertEquals("Unexpected response status: " + entity.getStatusCodeValue(), 404, entity.getStatusCodeValue()); }
From source file:com.saasovation.collaboration.port.adapter.service.HttpUserInRoleAdapter.java
public <T extends Collaborator> T toCollaborator(Tenant aTenant, String anIdentity, String aRoleName, Class<T> aCollaboratorClass) { T collaborator = null;/*w ww .j a va2 s . c o m*/ try { ResponseEntity<String> response = restTemplate.getForEntity(this.buildURLFor(URL_TEMPLATE), String.class, aTenant.id(), anIdentity, aRoleName); if (response.getStatusCodeValue() == 200) { collaborator = new CollaboratorTranslator().toCollaboratorFromRepresentation(response.getBody(), aCollaboratorClass); } else if (response.getStatusCodeValue() == 204) { // not an error, return null } else { throw new IllegalStateException("There was a problem requesting the user: " + anIdentity + " in role: " + aRoleName + " with resulting status: " + response.getStatusCode()); } } catch (Throwable t) { throw new IllegalStateException("Failed because: " + t.getMessage(), t); } return collaborator; }
From source file:org.schedoscope.metascope.controller.MetascopeDataDistributionControllerTest.java
@Test public void sometest() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.set("Referer", "/test"); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); ResponseEntity<String> response = this.restTemplate.exchange("/datadistribution/start?fqdn=test", HttpMethod.POST, entity, String.class); assertEquals(302, response.getStatusCodeValue()); assertTrue(response.getHeaders().get("Location").get(0).endsWith("/test#datadistributionContent")); }
From source file:net.nfpj.webcounter.api.CounterIT.java
/** * Test of health method, of class TestService. *//*from w w w. ja va 2 s . c o m*/ @Test public void testStatus() { ResponseEntity<String> entity = restTemplate.getForEntity("/counter/status", String.class); assertEquals("Unexpected response status: " + entity.getStatusCodeValue(), 200, entity.getStatusCodeValue()); assertEquals("ok", entity.getBody()); }
From source file:net.nfpj.webcounter.api.CounterIT.java
@Test public void testGetCounterMissing() { String name = "C1Missing"; ResponseEntity<String> entity = restTemplate.getForEntity("/counter/" + name + "/", String.class); assertEquals("Unexpected response status: " + entity.getStatusCodeValue(), HttpStatus.SC_NOT_FOUND, entity.getStatusCodeValue()); }