Package org.springframework.boot.test

Examples of org.springframework.boot.test.TestRestTemplate


        entity.getHeaders().get("Set-Cookie"));
  }

  private HttpHeaders getHeaders() {
    HttpHeaders headers = new HttpHeaders();
    ResponseEntity<String> page = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/login", String.class);
    assertEquals(HttpStatus.OK, page.getStatusCode());
    String cookie = page.getHeaders().getFirst("Set-Cookie");
    headers.set("Cookie", cookie);
    Matcher matcher = Pattern.compile("(?s).*name=\"_csrf\".*?value=\"([^\"]+).*")
 
View Full Code Here


    return headers;
  }

  @Test
  public void testCss() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port + "/css/bootstrap.min.css", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
  }
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());
    assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
        .getBody().contains("<title>Messages"));
    assertFalse("Wrong body (found layout:fragment):\n" + entity.getBody(), entity
View Full Code Here

  @Test
  public void testCreate() throws Exception {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.set("text", "FOO text");
    map.set("summary", "FOO");
    URI location = new TestRestTemplate().postForLocation("http://localhost:"
        + this.port, map);
    assertTrue("Wrong location:\n" + location,
        location.toString().contains("localhost:" + this.port));
  }
View Full Code Here

        location.toString().contains("localhost:" + this.port));
  }

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

            new TrustSelfSignedStrategy()).build());

    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
        .build();

    TestRestTemplate testRestTemplate = new TestRestTemplate();
    ((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory())
        .setHttpClient(httpClient);
    ResponseEntity<String> entity = testRestTemplate.getForEntity(
        "https://localhost:" + this.port, String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals("Hello, world", entity.getBody());
  }
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.server.port}")
  private int port = 0;

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

        .getBody().contains("<title>Static"));
  }

  @Test
  public void testCss() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port
            + "/webjars/bootstrap/3.0.3/css/bootstrap.min.css", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
    assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(),
View Full Code Here

  private int managementPort = 9011;

  @Test
  public void testHome() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + this.port, Map.class);
    assertEquals(HttpStatus.UNAUTHORIZED, 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.