/** * Perform a DELETE request to the statically configured path (by default <code>http://localhost:8080</code>). * * @return The response of the request. */ public static Response delete() { return given().delete(); }
/** * Perform a DELETE request to a <code>uri</code>. * * @param uri The uri to send the request to. * @return The response of the request. */ public static Response delete(URI uri) { return given().delete(uri); }
/** * Perform a DELETE request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to * specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>. * * @param path The path to send the request to. * @param pathParams The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do <code>delete("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);</code>. * @return The response of the request. */ public static Response delete(String path, Object... pathParams) { return given().delete(path, pathParams); }
/** * Perform a DELETE request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to * specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>. * * @param path The path to send the request to. * @param pathParams The path parameters. * @return The response of the request. */ public static Response delete(String path, Map<String, ?> pathParams) { return given().delete(path, pathParams); }
/** * Perform a DELETE request to a <code>url</code>. * * @param url The url to send the request to. * @return The response of the request. */ public static Response delete(URL url) { return given().delete(url); }
@AfterSuite(alwaysRun = true) public void tearDown() { // If container isn't null, we created the resource ourselves. To clean up, delete the resource. if (container != null) { buildBaseRequestSpecification().delete(memberResource); } } }
@AfterSuite(alwaysRun = true) public void tearDown() { if (nonRdfSource != null) { buildBaseRequestSpecification().delete(nonRdfSource); } }
@Test( groups = {MAY}, description = "LDP servers MAY choose to allow the creation of new " + "resources using HTTP PUT.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-put-create", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testPutToCreate() { String location = putToCreate(); buildBaseRequestSpecification().delete(location); }
@Test( groups = {MAY}, description = "LDP servers may accept an HTTP POST of non-RDF " + "representations (LDP-NRs) for creation of any kind of " + "resource, for example binary resources.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpc-post-createbins", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED, comment = "Covers only part of the specification requirement. " + "testPostResourceAndGetFromContainer covers the rest.") public void testPostNonRDFSource() throws IOException { // Test constants final String slug = "test", file = slug + ".png", mimeType = "image/png"; // Make sure we can post binary resources Response response = postNonRDFSource(slug, file, mimeType); buildBaseRequestSpecification().delete(response.getHeader(LOCATION)); }
public static Response send(RequestSpecification request, String methodPath, HttpMethodType methodType) { Response response = null; SystemProxy.setupProxy(); switch (methodType) { case HEAD: response = request.head(methodPath); break; case GET: response = request.get(methodPath); break; case PUT: response = request.put(methodPath); break; case POST: response = request.post(methodPath); break; case DELETE: response = request.delete(methodPath); break; case PATCH: response = request.patch(methodPath); break; default: throw new RuntimeException("MethodType is not specified for the API method: " + methodPath); } return response; }
@Test(priority = 12) public void failDeleteParent() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/parent/678") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
@Test(priority = 40) public void testInverseDeleteFromCollection() { // NOTE: This only tests this behavior is correct BECAUSE of the Child4Parent10 check. // It's a bit contrived, but we shouldn't lose the logic. // The problem: when deleting an inverse relation, it checks whether it can update its inverse field back // to the original. This is flawed logic since you're deleting the original in the first place (and that check // succeeded if we got there). given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/parent/10/children/4") .then() .statusCode(204); }
@Test(priority = 11) public void testNoDeleteExcludedRelationship() throws Exception { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body("{\"data\":{\"type\":\"excludedRelationship\",\"id\":\"1\"}}") .delete("/parent/4/children/4/relationships/excludedRelationship") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
@Test(priority = 11) public void testForbiddenDeleteEmptyCollectionRelationship() throws Exception { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body("{\"data\":[]}") .delete("/parent/4/children/4/relationships/parents") .then() .statusCode(HttpStatus.SC_FORBIDDEN); }
@Test( groups = {MUST}, description = "If the resource was created successfully, LDP servers MUST " + "respond with status code 201 (Created) and the Location " + "header set to the new resource’s URL. Clients shall not " + "expect any representation in the response entity body on " + "a 201 (Created) response.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpc-post-created201", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testPostResponseStatusAndLocation() throws URISyntaxException { skipIfMethodNotAllowed(HttpMethod.POST); String location = null; try { Model model = postContent(); Response postResponse = buildBaseRequestSpecification().contentType(TEXT_TURTLE) .body(model, new RdfObjectMapper()).expect() .statusCode(HttpStatus.SC_CREATED).when() .post(getResourceUri()); location = postResponse.getHeader(LOCATION); assertNotNull(location, MSG_LOC_NOTFOUND); } finally { buildBaseRequestSpecification().delete(location); } }
@Test(priority = 11) public void testDeleteParent() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/parent/1") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .body(isEmptyOrNullString()); }
@Test(priority = 11) public void testDeleteWithCascade() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/invoice/1") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .body(isEmptyOrNullString()); }
@Test( groups = {MUST}, description = "LDP servers MUST accept a request entity body with a " + "request header of Content-Type with value of text/turtle [turtle].") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpc-post-turtle", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testAcceptTurtle() { skipIfMethodNotAllowed(HttpMethod.POST); Model model = postContent(); Response postResponse = buildBaseRequestSpecification().contentType(TEXT_TURTLE) .body(model, new RdfObjectMapper()).expect() .statusCode(HttpStatus.SC_CREATED).when() .post(getResourceUri()); // Delete the resource to clean up. String location = postResponse.getHeader(LOCATION); if (location != null) { buildBaseRequestSpecification().delete(location); } }
@Test( groups = {SHOULD}, description = "LDP servers SHOULD assign the URI for the resource to be created " + "using server application specific rules in the absence of a client hint.") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpc-post-serverassignuri", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testPostNoSlug() { skipIfMethodNotAllowed(HttpMethod.POST); // POST content with no Slug and see if the server assigns a URI. Model model = postContent(); Response postResponse = buildBaseRequestSpecification() .contentType(TEXT_TURTLE) .body(model, new RdfObjectMapper()) .expect() .statusCode(HttpStatus.SC_CREATED) .header(LOCATION, HeaderMatchers.headerPresent()) .when() .post(getResourceUri()); // Delete the resource to clean up. buildBaseRequestSpecification().delete(postResponse.getHeader(LOCATION)); }
@Test(priority = 23) public void removeRelationshipChild() { String request = jsonParser.getJson("/ResourceIT/removeRelationshipChild.req.json"); String expected = jsonParser.getJson("/ResourceIT/removeRelationshipChild.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .delete("/parent/5/children/6/relationships/parents") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .header(HttpHeaders.CONTENT_LENGTH, (String) null); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .get("/parent/5/children/6") .then() .statusCode(HttpStatus.SC_OK) .body(equalTo(expected)); }