本文整理汇总了Java中io.restassured.filter.FilterContext类的典型用法代码示例。如果您正苦于以下问题:Java FilterContext类的具体用法?Java FilterContext怎么用?Java FilterContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterContext类属于io.restassured.filter包,在下文中一共展示了FilterContext类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec,
FilterableResponseSpecification responseSpec, FilterContext context) {
Map<String, Object> configuration = getConfiguration(requestSpec, context);
configuration.put("contract.jsonPaths", this.jsonPaths.keySet());
Response response = context.next(requestSpec, responseSpec);
if (requestSpec.getBody() != null && !this.jsonPaths.isEmpty()) {
String actual = new String((byte[]) requestSpec.getBody());
for (JsonPath jsonPath : this.jsonPaths.values()) {
new JsonPathValue(jsonPath, actual).assertHasValue(Object.class,
"an object");
}
}
if (this.builder != null) {
this.builder.willReturn(getResponseDefinition(response));
StubMapping stubMapping = this.builder.build();
MatchResult match = stubMapping.getRequest()
.match(new WireMockRestAssuredRequestAdapter(requestSpec));
assertThat(match.isExactMatch()).as("wiremock did not match request")
.isTrue();
configuration.put("contract.stubMapping", stubMapping);
}
return response;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:25,代码来源:RequestVerifierFilter.java
示例2: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
final Response response = ctx.next(requestSpec, responseSpec);
final ByteArrayOutputStream responseLog = new ByteArrayOutputStream();
final PrintStream stream = new PrintStream(responseLog);
ResponsePrinter.print(response, response, stream, LogDetail.ALL, true);
final File logFile = new File(createLogDirectory(new File(reporterConfiguration.getRootDirectory())), "restassuredResponse.log");
writeContent(responseLog, logFile);
final Path rootDir = Paths.get(reporterConfiguration.getRootDirectory());
final Path relativePath = rootDir.relativize(logFile.toPath());
Reporter.createReport(REST_RESPONSE_LOG)
.addKeyValueEntry(LOG_PATH, new FileEntry(relativePath))
.inSection(new DockerLogSection())
.fire(reportEvent);
final byte[] responseBody = response.asByteArray();
return cloneResponseIfNeeded(response, responseBody);
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:24,代码来源:TakeRestAssuredContent.java
示例3: replacesProvidedHostHeader
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Test
public void replacesProvidedHostHeader() throws URISyntaxException, IOException,
RequestSigningException {
RestAssured.given()
.relaxedHTTPSValidation()
.header("Host", "ignored-hostname.com")
.filter(new RestAssuredEdgeGridFilter(credential))
.filter(new Filter() {
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
MatcherAssert.assertThat(requestSpec.getHeaders().getList("Host").size(),
CoreMatchers.equalTo(1));
MatcherAssert.assertThat(requestSpec.getHeaders().get("Host").getValue(),
CoreMatchers.equalTo(credential.getHost()));
return ctx.next(requestSpec, responseSpec);
}
})
.get();
}
开发者ID:akamai,项目名称:AkamaiOPEN-edgegrid-java,代码行数:25,代码来源:RestAssuredEdgeGridFilterTest.java
示例4: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(final FilterableRequestSpecification requestSpec,
final FilterableResponseSpecification responseSpec,
final FilterContext filterContext) {
final Prettifier prettifier = new Prettifier();
final HttpRequestAttachment.Builder requestAttachmentBuilder = create("Request", requestSpec.getURI())
.withMethod(requestSpec.getMethod())
.withHeaders(toMapConverter(requestSpec.getHeaders()))
.withCookies(toMapConverter(requestSpec.getCookies()));
if (Objects.nonNull(requestSpec.getBody())) {
requestAttachmentBuilder.withBody(prettifier.getPrettifiedBodyIfPossible(requestSpec));
}
final HttpRequestAttachment requestAttachment = requestAttachmentBuilder.build();
new DefaultAttachmentProcessor().addAttachment(
requestAttachment,
new FreemarkerAttachmentRenderer("http-request.ftl")
);
final Response response = filterContext.next(requestSpec, responseSpec);
final HttpResponseAttachment responseAttachment = create(response.getStatusLine())
.withResponseCode(response.getStatusCode())
.withHeaders(toMapConverter(response.getHeaders()))
.withBody(prettifier.getPrettifiedBodyIfPossible(response, response.getBody()))
.build();
new DefaultAttachmentProcessor().addAttachment(
responseAttachment,
new FreemarkerAttachmentRenderer("http-response.ftl")
);
return response;
}
开发者ID:allure-framework,项目名称:allure-java,代码行数:38,代码来源:AllureRestAssured.java
示例5: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec,
FilterContext ctx) {
WebCustomRequest request = mapper.map(requestSpec);
trx.addFunction(request);
boolean blockRequests = globalWorldFacade.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS);
if (blockRequests) {
Response response = Mockito.mock(Response.class);
Mockito.when(response.then()).thenReturn(Mockito.mock(ValidatableResponse.class));
return response;
}
return ctx.next(requestSpec, responseSpec);
}
开发者ID:ctco,项目名称:cukes,代码行数:14,代码来源:LoadRunnerFilter.java
示例6: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec,
FilterContext filterContext) {
final Response response = filterContext.next(requestSpec, responseSpec);
final RamlReport report = ramlChecker.check(new RestAssuredRamlRequest(requestSpec), new RestAssuredRamlResponse(response));
reportStore.storeReport(report);
return response;
}
开发者ID:nidi3,项目名称:raml-tester,代码行数:10,代码来源:RamlValidationFilter.java
示例7: replaceProvidedHostHeaderOnlyInApacheClient
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Test
public void replaceProvidedHostHeaderOnlyInApacheClient() throws URISyntaxException, IOException,
RequestSigningException {
wireMockServer.stubFor(get(urlPathEqualTo("/billing-usage/v1/reportSources"))
.withHeader("Authorization", matching(".*"))
.willReturn(aResponse()
.withStatus(200)));
getBaseRequestSpecification()
.header("Host", "ignored-hostname.com")
.filter(new Filter() {
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
MatcherAssert.assertThat(requestSpec.getHeaders().getList("Host").size(),
CoreMatchers.equalTo(1));
MatcherAssert.assertThat(requestSpec.getHeaders().get("Host").getValue(),
CoreMatchers.equalTo("ignored-hostname.com"));
return ctx.next(requestSpec, responseSpec);
}
})
.get("/billing-usage/v1/reportSources");
List<LoggedRequest> loggedRequests = wireMockServer.findRequestsMatching(RequestPattern
.everything()).getRequests();
MatcherAssert.assertThat(loggedRequests.get(0).getHeader("Host"),
CoreMatchers.equalTo(SERVICE_MOCK));
}
开发者ID:akamai,项目名称:AkamaiOPEN-edgegrid-java,代码行数:31,代码来源:RestAssuredIntegrationTest.java
示例8: filter
import io.restassured.filter.FilterContext; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
try {
binding.sign(requestSpec);
} catch (RequestSigningException e) {
throw new RuntimeException(e);
}
return ctx.next(requestSpec, responseSpec);
}
开发者ID:akamai,项目名称:AkamaiOPEN-edgegrid-java,代码行数:10,代码来源:RestAssuredEdgeGridFilter.java
示例9: getConfiguration
import io.restassured.filter.FilterContext; //导入依赖的package包/类
protected Map<String, Object> getConfiguration(
FilterableRequestSpecification requestSpec, FilterContext context) {
Map<String, Object> configuration = context
.<Map<String, Object>>getValue(CONTEXT_KEY_CONFIGURATION);
return configuration;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:7,代码来源:RequestVerifierFilter.java
注:本文中的io.restassured.filter.FilterContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论