Example usage for org.springframework.http ResponseEntity getStatusCode

List of usage examples for org.springframework.http ResponseEntity getStatusCode

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity getStatusCode.

Prototype

public HttpStatus getStatusCode() 

Source Link

Document

Return the HTTP status code of the response.

Usage

From source file:de.rahn.finances.server.web.config.HealthConfigurationTest.java

/**
 * Teste die Health-Endpoints.//www.  j av  a2  s  .  com
 */
@Test
public void testHealth() {
    ResponseEntity<String> answer = testRestTemplate.getForEntity("/manage/health", String.class);

    assertThat(answer.getStatusCode()).isEqualTo(OK);
    assertThat(answer.getBody()).contains("\"test\" : \"good\"");
}

From source file:sample.tomcat.SampleWebApplicationTest.java

@Test
public void testHome() throws Exception {

    ResponseEntity<String> entity = testRestTemplate.getForEntity("/", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals("Hello, Secret Property: chupacabras", entity.getBody());
}

From source file:zipkin.autoconfigure.metrics.PrometheusMetricsAutoConfigurationTest.java

@Test
public void correctHttpResponse() throws Exception {
    PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024));
    ResponseEntity<String> response = responseForMetrics(publicMetrics);

    assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
    assertThat(response.getHeaders().getContentType().toString(),
            equalTo("text/plain;version=0.0.4;charset=utf-8"));
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerDocsIndexWithToken() {
    ResponseEntity<String> response = get("/api/v1/index.html", String.class);
    assertThat(response.getStatusCode()).as("swagger docs index.html response code").isEqualTo(HttpStatus.OK);
    assertThat(response.getBody().length()).as("swagger index.html length").isPositive();
    assertThat(response.getBody()).as("swagger index.html example path").contains("/connectors/{id}");
}

From source file:org.cloudfoundry.identity.uaa.integration.HealthzEndpointIntegrationTests.java

/**
 * tests a happy-day flow of the <code>/healthz</code> endpoint
 *///from   w  w w  .j a va 2  s . c  om
@Test
public void testHappyDay() throws Exception {

    HttpHeaders headers = new HttpHeaders();
    ResponseEntity<String> response = serverRunning.getForString("/healthz/", headers);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    String body = response.getBody();
    assertTrue(body.contains("ok"));

}

From source file:org.cloudfoundry.identity.uaa.integration.UserInfoEndpointIntegrationTests.java

/**
 * tests a happy-day flow of the <code>/userinfo</code> endpoint
 *///from  w w w . j av a2  s . com
@Test
public void testHappyDay() throws Exception {

    ResponseEntity<String> user = serverRunning.getForString("/userinfo");
    assertEquals(HttpStatus.OK, user.getStatusCode());

    String map = user.getBody();
    assertTrue(testAccounts.getUserName(), map.contains("user_id"));
    assertTrue(testAccounts.getEmail(), map.contains("email"));

    System.err.println(user.getHeaders());

}

From source file:com.carlomicieli.jtrains.infrastructure.web.ResponsesTests.java

@Test
public void shouldCreateResponsesForNoContent() {
    ResponseEntity<Void> resp = Responses.noContent();
    assertThat(resp).isNotNull();// ww w. j a v a 2s .com
    assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerJsonWithToken() {
    ResponseEntity<JsonNode> response = get("/api/v1/swagger.json", JsonNode.class);
    assertThat(response.getStatusCode()).as("swagger json response code").isEqualTo(HttpStatus.OK);
    assertThat(response.getBody().get("paths").size()).as("swagger json number of paths").isPositive();
}

From source file:com.carlomicieli.jtrains.infrastructure.web.ResponsesTests.java

@Test
public void shouldCreateResponsesForOk() {
    ResponseEntity<String> resp = Responses.ok("Body");
    assertThat(resp).isNotNull();/*ww w.  j av a 2 s .  co m*/
    assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(resp.getBody()).isEqualTo("Body");
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerYamlWithToken() {
    ResponseEntity<Map<String, Map<?, ?>>> response = get("/api/v1/swagger.yaml", TYPE);
    assertThat(response.getStatusCode()).as("swagger yaml response code").isEqualTo(HttpStatus.OK);
    assertThat((response.getBody().get("paths")).size()).as("swagger json number of paths").isPositive();
}