Package org.springframework.boot.test

Examples of org.springframework.boot.test.TestRestTemplate


    assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
  }

  @Test
  public void testHealth() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate()
        .getForEntity(
            "http://localhost:" + this.managementPort + "/admin/health",
            String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body: " + entity.getBody(),
View Full Code Here


  private int port;

  @Test
  public void testErrorPath() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate("user", "password")
        .getForEntity("http://localhost:" + this.port + "/spring/error",
            Map.class);
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
View Full Code Here

    assertEquals(999, body.get("status"));
  }

  @Test
  public void testHealth() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/spring/health", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body: " + entity.getBody(),
        entity.getBody().contains("\"status\":\"UP\""));
  }
View Full Code Here

  }

  @Test
  public void testHomeIsSecure() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/spring/", Map.class);
    assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertEquals("Wrong body: " + body, "Unauthorized", body.get("error"));
View Full Code Here

  @Value("${local.server.port}")
  private int port;

  @Test
  public void testVelocityTemplate() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port, String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body:\n" + entity.getBody(),
        entity.getBody().contains("Hello, Andy"));
  }
View Full Code Here

  public void testVelocityErrorTemplate() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    HttpEntity<String> requestEntity = new HttpEntity<String>(headers);

    ResponseEntity<String> responseEntity = new TestRestTemplate().exchange(
        "http://localhost:" + this.port + "/does-not-exist", HttpMethod.GET,
        requestEntity, String.class);

    assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
    assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody()
View Full Code Here

  private int port;

  @Test
  public void testHome() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/spring/", Map.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertEquals("Hello Phil", body.get("message"));
View Full Code Here

  }

  @Test
  public void testMetricsIsSecure() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/spring/metrics", Map.class);
    assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
  }
View Full Code Here

  @Value("${local.server.port}")
  private int port;

  @Test
  public void testHome() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port, String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals("Hello World", entity.getBody());
  }
View Full Code Here

  @Value("${local.management.port}")
  private int managementPort = 9011;

  @Test
  public void testHome() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port, String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
  }
View Full Code Here

TOP

Related Classes of org.springframework.boot.test.TestRestTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.