List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:org.ohdsi.webapi.test.CohortAnalysisServiceIT.java
private void assertOk(final ResponseEntity<?> entity) { Assert.state(entity.getStatusCode() == HttpStatus.OK); }
From source file:com.github.sebhoss.identifier.usecases.IndexPagesIT.java
/** * Ensures that the index page can be access at <code>/</code>. * * @throws Exception/*from ww w .ja va 2 s. c om*/ * In case something goes wrong. */ @Test public void shouldGetIndexPage() throws Exception { final ResponseEntity<String> response = fetchString("/"); //$NON-NLS-1$ assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); }
From source file:sample.jsp.SampleWebJspApplicationTests.java
@Test public void testJspWithEl() throws Exception { ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("/resources/text.txt"); }
From source file:sparklr.common.AbstractProtectedResourceTests.java
@Test public void testHomePageIsProtected() throws Exception { ResponseEntity<String> response = http.getForString("/"); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); assertTrue("Wrong header: " + response.getHeaders(), response.getHeaders().getFirst("WWW-Authenticate").startsWith("Bearer realm=")); }
From source file:com.ewerk.prototype.api.GlobalErrorHandlerTest.java
@Test public void testHandleException() { GlobalErrorHandler handler = new GlobalErrorHandler(); final ResponseEntity<String> responseEntity = handler.handleException(new RuntimeException("Test")); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); assertThat(responseEntity.getBody()).isEqualTo("Test"); }
From source file:org.cloudfoundry.community.servicebroker.vrealize.service.TokenService.java
public String getToken() { try {/*from w w w.j av a 2 s. c o m*/ ResponseEntity<Map<String, String>> m = vraRepository.getToken(creds); if (!m.getStatusCode().equals(HttpStatus.OK)) { throw new ServiceBrokerException(m.getStatusCode().toString()); } if (m.getBody().containsKey("id")) { return m.getBody().get("id"); } else { throw new ServiceBrokerException("unable to get token from response."); } } catch (FeignException e) { LOG.error(e); throw new ServiceBrokerException("Unable to retrieve token.", e); } }
From source file:com.github.harti2006.Neo4jServerIT.java
@Test public void testNeo4jServerIsRunning() throws Exception { final RestTemplate restTemplate = new RestTemplate(); final RequestEntity<Void> request = RequestEntity.get(create(System.getProperty("neo4j-server.url"))) .accept(APPLICATION_JSON).build(); final ResponseEntity<String> responseEntity = restTemplate.exchange(request, String.class); assertEquals(OK, responseEntity.getStatusCode()); System.out.println(responseEntity); }
From source file:cherry.foundation.springmvc.ExceptionControllerTest.java
@Test public void testHandleNotFoundException() { ExceptionController c = new ExceptionController(); ResponseEntity<String> response = c.handleNotFoundException(new NotFoundException()); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); assertNull(response.getBody());//from w w w .jav a2s .c o m }
From source file:sparklr.common.AbstractProtectedResourceTests.java
@Test public void testBeansResourceIsProtected() throws Exception { ResponseEntity<String> response = http.getForString("/admin/beans"); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); assertTrue("Wrong header: " + response.getHeaders(), response.getHeaders().getFirst("WWW-Authenticate").startsWith("Bearer realm=")); }
From source file:com.recursivechaos.clearent.controller.SaleControllerIntegrationTest.java
@Test public void testPostSale() throws Exception { Sale saleRequest = TestUtil.createSaleRequest(); ResponseEntity<Void> responseEntity = saleController.postSale(saleRequest); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertEquals("/sales/1", responseEntity.getHeaders().getLocation().getPath()); }