/** * Test creating a child resource via PUT. */ @Test @DisplayName("Test creating a child resource via PUT") default void testCreateContainerViaPut() { final RDF rdf = getInstance(); final String containerContent = getResourceAsString(BASIC_CONTAINER); final String child4 = getContainerLocation() + "/child4"; // First fetch the container headers to get the initial ETag final EntityTag initialETag = getETag(getContainerLocation()); try (final Response res = target(child4).request() .header(LINK, fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build()) .put(entity(containerContent, TEXT_TURTLE))) { assertAll("Check PUTting an LDP-BC", checkRdfResponse(res, LDP.BasicContainer, null)); } // Now fetch the resource try (final Response res = target(getContainerLocation()).request().get()) { assertAll("Check an LDP-BC after PUT", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getContainerLocation()); final EntityTag etag = res.getEntityTag(); assertAll("Check the resulting graph", checkRdfGraph(g, identifier)); assertFalse(g.contains(identifier, LDP.contains, rdf.createIRI(child4)), "Check for an ldp:contains triple"); assertTrue(etag.isWeak(), "Check for a weak ETag"); assertEquals(initialETag, etag, "Check ETags"); } }
/** * Test creating a child resource via PUT. */ @Test @DisplayName("Test creating a child resource via PUT") default void testCreateContainerViaPut() { final RDF rdf = getInstance(); final String containerContent = getResourceAsString(BASIC_CONTAINER); final String child4 = getContainerLocation() + "/child4"; // First fetch the container headers to get the initial ETag final EntityTag initialETag = getETag(getContainerLocation()); try (final Response res = target(child4).request() .header(LINK, fromUri(LDP.BasicContainer.getIRIString()).rel(TYPE).build()) .put(entity(containerContent, TEXT_TURTLE))) { assertAll("Check PUTting an LDP-BC", checkRdfResponse(res, LDP.BasicContainer, null)); } // Now fetch the resource try (final Response res = target(getContainerLocation()).request().get()) { assertAll("Check an LDP-BC after PUT", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getContainerLocation()); final EntityTag etag = res.getEntityTag(); assertAll("Check the resulting graph", checkRdfGraph(g, identifier)); assertFalse(g.contains(identifier, LDP.contains, rdf.createIRI(child4)), "Check for an ldp:contains triple"); assertTrue(etag.isWeak(), "Check for a weak ETag"); assertEquals(initialETag, etag, "Check ETags"); } }