当前位置: 首页>>代码示例>>Java>>正文


Java HttpClientOption类代码示例

本文整理汇总了Java中org.springframework.boot.test.TestRestTemplate.HttpClientOption的典型用法代码示例。如果您正苦于以下问题:Java HttpClientOption类的具体用法?Java HttpClientOption怎么用?Java HttpClientOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpClientOption类属于org.springframework.boot.test.TestRestTemplate包,在下文中一共展示了HttpClientOption类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_authenticate_success

import org.springframework.boot.test.TestRestTemplate.HttpClientOption; //导入依赖的package包/类
@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));
}
 
开发者ID:auslides,项目名称:stateless-shiro,代码行数:15,代码来源:UserControllerTest.java

示例2: test_authenticate_failure

import org.springframework.boot.test.TestRestTemplate.HttpClientOption; //导入依赖的package包/类
@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));
}
 
开发者ID:auslides,项目名称:stateless-shiro,代码行数:15,代码来源:UserControllerTest.java

示例3: options

import org.springframework.boot.test.TestRestTemplate.HttpClientOption; //导入依赖的package包/类
@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));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:TestRestTemplateTests.java

示例4: test_authenticate_failure

import org.springframework.boot.test.TestRestTemplate.HttpClientOption; //导入依赖的package包/类
@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));
}
 
开发者ID:pires,项目名称:spring-boot-shiro-orientdb,代码行数:15,代码来源:UserControllerTest.java


注:本文中的org.springframework.boot.test.TestRestTemplate.HttpClientOption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。