Java 类org.springframework.boot.test.TestRestTemplate.HttpClientOption 实例源码

项目:stateless-shiro    文件:UserControllerTest.java   
@Test
public void test_authenticate_success() throws JsonProcessingException {
    // authenticate
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);
    final String json = new ObjectMapper().writeValueAsString(
            new UsernamePasswordToken(USER_EMAIL, USER_PWD));
    System.out.println(json);
    final ResponseEntity<String> response = new TestRestTemplate(
            HttpClientOption.ENABLE_COOKIES).exchange(BASE_URL.concat("/auth"),
            HttpMethod.POST, new HttpEntity<>(json, headers), String.class);
    assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
}
项目:stateless-shiro    文件:UserControllerTest.java   
@Test
public void test_authenticate_failure() throws JsonProcessingException {
    // authenticate
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);
    final String json = new ObjectMapper().writeValueAsString(
            new UsernamePasswordToken(USER_EMAIL, "wrong password"));
    System.out.println(json);
    final ResponseEntity<String> response = new TestRestTemplate(
            HttpClientOption.ENABLE_COOKIES).exchange(BASE_URL.concat("/auth"),
            HttpMethod.POST, new HttpEntity<>(json, headers), String.class);
    assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
}
项目:contestparser    文件:TestRestTemplateTests.java   
@Test
public void options() throws Exception {
    TestRestTemplate template = new TestRestTemplate(
            HttpClientOption.ENABLE_REDIRECTS);
    CustomHttpComponentsClientHttpRequestFactory factory = (CustomHttpComponentsClientHttpRequestFactory) template
            .getRequestFactory();
    RequestConfig config = factory.getRequestConfig();
    assertThat(config.isRedirectsEnabled(), equalTo(true));
}
项目:spring-boot-shiro-orientdb    文件:UserControllerTest.java   
@Test
public void test_authenticate_success() throws JsonProcessingException {
    // authenticate
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);
    final String json = new ObjectMapper().writeValueAsString(
            new UsernamePasswordToken(USER_EMAIL, USER_PWD));
    System.out.println(json);
    final ResponseEntity<String> response = new TestRestTemplate(
            HttpClientOption.ENABLE_COOKIES).exchange(BASE_URL.concat("/auth"),
            HttpMethod.POST, new HttpEntity<>(json, headers), String.class);
    assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
}
项目:spring-boot-shiro-orientdb    文件:UserControllerTest.java   
@Test
public void test_authenticate_failure() throws JsonProcessingException {
    // authenticate
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);
    final String json = new ObjectMapper().writeValueAsString(
            new UsernamePasswordToken(USER_EMAIL, "wrong password"));
    System.out.println(json);
    final ResponseEntity<String> response = new TestRestTemplate(
            HttpClientOption.ENABLE_COOKIES).exchange(BASE_URL.concat("/auth"),
            HttpMethod.POST, new HttpEntity<>(json, headers), String.class);
    assertThat(response.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
}