@Override public String getContentType() { return response.getContentType(); }
@Override public String getContentType() { return response.getContentType(); }
/** * Clone an already existing response. * * @return Builder. */ public ResponseBuilder clone(Response response) { if (isRestAssuredResponse(response)) { final RestAssuredResponseImpl raResponse = raResponse(response); restAssuredResponse.setContent(raResponse.getContent()); restAssuredResponse.setHasExpectations(raResponse.getHasExpectations()); restAssuredResponse.setDefaultContentType(raResponse.getDefaultContentType()); restAssuredResponse.setDecoderConfig(raResponse.getDecoderConfig()); restAssuredResponse.setSessionIdName(raResponse.getSessionIdName()); restAssuredResponse.setConnectionManager(raResponse.getConnectionManager()); restAssuredResponse.setConfig(raResponse.getConfig()); restAssuredResponse.setRpr(raResponse.getRpr()); restAssuredResponse.setLogRepository(raResponse.getLogRepository()); restAssuredResponse.setFilterContextProperties(raResponse.getFilterContextProperties()); } else { restAssuredResponse.setContent(response.asInputStream()); } restAssuredResponse.setContentType(response.getContentType()); restAssuredResponse.setCookies(response.getDetailedCookies()); restAssuredResponse.setResponseHeaders(response.getHeaders()); restAssuredResponse.setStatusCode(response.getStatusCode()); restAssuredResponse.setStatusLine(response.getStatusLine()); return this; }
@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); }
.when() .get(resourceUri); String contentType = response.getContentType();
.contentType(response.getContentType()) .header(IF_MATCH, "\"This is not the ETag you're looking for\"") // bad ETag value .body(response.asByteArray())