com.jayway.restassured.response.Response.asByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中com.jayway.restassured.response.Response.asByteArray方法的一些代码示例,展示了Response.asByteArray的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.asByteArray方法的具体详情如下:
包路径:com.jayway.restassured.response.Response
类名称:Response
方法名:asByteArray

Response.asByteArray介绍

暂无

代码示例

代码示例来源:origin: com.jayway.restassured/rest-assured

public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
  long start = System.currentTimeMillis();
  Response response = ctx.next(requestSpec, responseSpec);
  if (shouldConsumeStream && response instanceof RestAssuredResponseImpl && ((RestAssuredResponseImpl) response).isInputStream()) {
    // Consume the body of the request (important if measure time also should include downloading of body)
    response.asByteArray();
  }
  long end = System.currentTimeMillis();
  long responseTime = end - start;
  ctx.setValue(RESPONSE_TIME_MILLISECONDS, responseTime);
  return response;
}

代码示例来源:origin: com.jayway.restassured/rest-assured

public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
  Response response = ctx.next(requestSpec, responseSpec);
  final int statusCode = response.statusCode();
  if (matcher.matches(statusCode)) {
    ResponsePrinter.print(response, response, stream, logDetail, shouldPrettyPrint);
    final byte[] responseBody;
    if (logDetail == BODY || logDetail == ALL) {
      responseBody = response.asByteArray();
    } else {
      responseBody = null;
    }
    response = cloneResponseIfNeeded(response, responseBody);
  }
  return response;
}

代码示例来源:origin: org.w3/ldp-testsuite

.header(IF_MATCH, getResponse.getHeader(ETAG))
  .contentType(getResponse.contentType())
  .body(getResponse.asByteArray())
.when()
  .put(resourceUri);
  .body(getResponse.asByteArray())
.when()
  .put(resourceUri);

代码示例来源:origin: org.w3/ldp-testsuite

@Test(
    groups = {SHOULD},
    description = "LDP clients SHOULD use the HTTP If-Match header and HTTP ETags "
        + "to ensure it isn’t modifying a resource that has changed since the "
        + "client last retrieved its representation. LDP servers SHOULD require "
        + "the HTTP If-Match header and HTTP ETags to detect collisions.")
@SpecTest(
    specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-put-precond",
    testMethod = METHOD.AUTOMATED,
    approval = STATUS.WG_APPROVED,
    comment = "Covers only part of the specification requirement. "
        + "testConditionFailedStatusCode, testPreconditionRequiredStatusCode "
        + "and testPutBadETag covers the rest.")
public void testPutRequiresIfMatch() throws URISyntaxException {
  skipIfMethodNotAllowed(HttpMethod.PUT);
  String resourceUri = getResourceUri();
  Response response = buildBaseRequestSpecification()
    .expect()
      .statusCode(isSuccessful())
      .header(ETAG, isValidEntityTag())
    .when()
      .get(resourceUri);
  buildBaseRequestSpecification()
      .contentType(response.getContentType())
      .body(response.asByteArray())
    .expect()
      .statusCode(not(isSuccessful()))
    .when()
      .put(resourceUri);
}

代码示例来源:origin: org.w3/ldp-testsuite

.contentType(response.getContentType())
  .header(IF_MATCH, "\"This is not the ETag you're looking for\"") // bad ETag value
  .body(response.asByteArray())
.expect()
  .statusCode(HttpStatus.SC_PRECONDITION_FAILED)

代码示例来源:origin: org.w3/ldp-testsuite

.contentType(contentType)
  .header(IF_MATCH, "\"These aren't the ETags you're looking for.\"")
  .body(response.asByteArray())
.expect()
  .statusCode(HttpStatus.SC_PRECONDITION_FAILED)

相关文章