本文整理汇总了Java中org.springframework.test.web.client.ResponseCreator类的典型用法代码示例。如果您正苦于以下问题:Java ResponseCreator类的具体用法?Java ResponseCreator怎么用?Java ResponseCreator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResponseCreator类属于org.springframework.test.web.client包,在下文中一共展示了ResponseCreator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: withHalJsonResponse
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
private ResponseCreator withHalJsonResponse(String fileName) {
Resource jsonResponse = new ClassPathResource(fileName);
return withSuccess(jsonResponse, APPLICATION_HAL_JSON);
}
开发者ID:hotblac,项目名称:spanners,代码行数:5,代码来源:SpannersServiceTest.java
示例2: testInject
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void testInject() {
String url = "http://localhost:4000/foo";
mockServer.expect(MockRestRequestMatchers.requestTo(url))
.andExpect(MockRestRequestMatchers.method(HttpMethod.GET))
.andRespond(new ResponseCreator() {
@Override
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException {
MockClientHttpResponse response =
new MockClientHttpResponse(new byte[1], HttpStatus.OK);
response.getHeaders().add("traceId", request.getHeaders()
.getFirst("traceId"));
response.getHeaders().add("spanId", request.getHeaders()
.getFirst("spanId"));
return response;
}
});
ResponseEntity<String> responseEntity = client.getForEntity(url, String.class);
List<MockSpan> mockSpans = mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
Assert.assertEquals(mockSpans.get(0).context().traceId(),
Long.parseLong(responseEntity.getHeaders().getFirst("traceId")));
Assert.assertEquals(mockSpans.get(0).context().spanId(),
Long.parseLong(responseEntity.getHeaders().getFirst("spanId")));
}
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:29,代码来源:AbstractTracingClientTest.java
示例3: postBadRequestTest_400
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void postBadRequestTest_400() throws Exception {
ResponseCreator response = withBadRequest();
this.mockServer.expect(requestTo("http://localhost:8080/kaaTest/post")).andExpect(method(HttpMethod.POST)).andRespond(response);
String result = testMessage.getMessage(kaaRestTemplate, TestHttpMethods.POST);
this.mockServer.verify();
assertThat(result, allOf(containsString("FAILED")));
}
开发者ID:kaaproject,项目名称:kaa,代码行数:9,代码来源:KaaRestTemplateTest.java
示例4: putBadRequestTest_400
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void putBadRequestTest_400() throws Exception {
ResponseCreator response = withBadRequest();
this.mockServer.expect(requestTo("http://localhost:8080/kaaTest/put")).andExpect(method(HttpMethod.PUT)).andRespond(response);
String result = testMessage.getMessage(kaaRestTemplate, TestHttpMethods.PUT);
this.mockServer.verify();
assertThat(result, allOf(containsString("FAILED")));
}
开发者ID:kaaproject,项目名称:kaa,代码行数:9,代码来源:KaaRestTemplateTest.java
示例5: putSuccessRequestTest
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void putSuccessRequestTest() throws Exception {
ResponseCreator response = withSuccess();
this.mockServer.expect(requestTo("http://localhost:8080/kaaTest/put")).andExpect(method(HttpMethod.PUT)).andRespond(response);
String result = testMessage.getMessage(kaaRestTemplate, TestHttpMethods.PUT);
this.mockServer.verify();
assertThat(result, allOf(containsString("SUCCESS")));
}
开发者ID:kaaproject,项目名称:kaa,代码行数:9,代码来源:KaaRestTemplateTest.java
示例6: deleteSuccessRequestTest
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void deleteSuccessRequestTest() throws Exception {
ResponseCreator response = withSuccess();
this.mockServer.expect(requestTo("http://localhost:8080/kaaTest/delete")).andExpect(method(HttpMethod.DELETE)).andRespond(response);
String result = testMessage.getMessage(kaaRestTemplate, TestHttpMethods.DELETE);
this.mockServer.verify();
assertThat(result, allOf(containsString("SUCCESS")));
}
开发者ID:kaaproject,项目名称:kaa,代码行数:9,代码来源:KaaRestTemplateTest.java
示例7: deleteBadRequestTest_400
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
@Test
public void deleteBadRequestTest_400() throws Exception {
ResponseCreator response = withBadRequest();
this.mockServer.expect(requestTo("http://localhost:8080/kaaTest/delete")).andExpect(method(HttpMethod.DELETE)).andRespond(response);
String result = testMessage.getMessage(kaaRestTemplate, TestHttpMethods.DELETE);
this.mockServer.verify();
assertThat(result, allOf(containsString("FAILED"), containsString("400")));
}
开发者ID:kaaproject,项目名称:kaa,代码行数:9,代码来源:KaaRestTemplateTest.java
示例8: mockServerRequest
import org.springframework.test.web.client.ResponseCreator; //导入依赖的package包/类
/**
* Set the mock REST server to expect a GET request with the specified URL, and to return the specified response.
* @param url The URL to expect
* @param responseCreator Used to create the response to return
*/
private void mockServerRequest(String url, ResponseCreator responseCreator) {
server.expect(requestTo(url)).andExpect(method(HttpMethod.GET)).andRespond(responseCreator);
}
开发者ID:dvsa,项目名称:mot-automated-testsuite,代码行数:9,代码来源:ClientDataProviderTest.java
注:本文中的org.springframework.test.web.client.ResponseCreator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论