/** * Create an Annotation resource. * @return the location of the new resource */ default String createAnnotationResource() { // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(getResourceAsString(ANNOTATION_RESOURCE), TEXT_TURTLE))) { assertAll("Check for an LDP-RS", checkRdfResponse(res, LDP.RDFSource, null)); return res.getLocation().toString(); } } }
/** * Create an Annotation resource. * @return the location of the new resource */ default String createAnnotationResource() { // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(getResourceAsString(ANNOTATION_RESOURCE), TEXT_TURTLE))) { assertAll("Check for an LDP-RS", checkRdfResponse(res, LDP.RDFSource, null)); return res.getLocation().toString(); } } }
/** * Initialize the RDF tests. */ @BeforeAll @DisplayName("Initialize RDF tests") default void beforeAllTests() { final String content = getResourceAsString(SIMPLE_RESOURCE); // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(content, TEXT_TURTLE))) { setResourceLocation(checkCreateResponseAssumptions(res, LDP.RDFSource)); } }
/** * Initialize the RDF tests. */ @BeforeAll @DisplayName("Initialize RDF tests") default void beforeAllTests() { final String content = getResourceAsString(SIMPLE_RESOURCE); // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(content, TEXT_TURTLE))) { setResourceLocation(checkCreateResponseAssumptions(res, LDP.RDFSource)); } }
/** * Test creating resource with syntactically invalid RDF. */ @Test @DisplayName("Test creating resource with syntactically invalid RDF") default void testInvalidRDF() { final String rdf = "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \n" + "PREFIX dc: <http://purl.org/dc/terms/> \n\n" + "<> a skos:Concept \n" + " skos:prefLabel \"Resource Name\"@eng \n" + " dc:subject <http://example.org/subject/1> ."; // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(rdf, TEXT_TURTLE))) { assertEquals(CLIENT_ERROR, res.getStatusInfo().getFamily(), "Syntactically invalid RDF produces a 4xx"); } }
/** * Test creating resource with syntactically invalid RDF. */ @Test @DisplayName("Test creating resource with syntactically invalid RDF") default void testInvalidRDF() { final String rdf = "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \n" + "PREFIX dc: <http://purl.org/dc/terms/> \n\n" + "<> a skos:Concept \n" + " skos:prefLabel \"Resource Name\"@eng \n" + " dc:subject <http://example.org/subject/1> ."; // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(rdf, TEXT_TURTLE))) { assertEquals(CLIENT_ERROR, res.getStatusInfo().getFamily(), "Syntactically invalid RDF produces a 4xx"); } }
/** * Test creating resource with invalid RDF. */ @Test @DisplayName("Test creating resource with invalid RDF") default void testWeirdRDF() { final String rdf = getResourceAsString(SIMPLE_RESOURCE) + "<> a \"skos concept\" ."; // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(rdf, TEXT_TURTLE))) { assertEquals(CLIENT_ERROR, res.getStatusInfo().getFamily(), "Semantically invalid RDF should throw a 4xx error"); assertTrue(getLinks(res).stream().anyMatch(hasConstrainedBy(Trellis.InvalidRange)), "Check for an InvalidRange constraint for weird rdf:type constructs"); } }
/** * Test creating resource with invalid RDF. */ @Test @DisplayName("Test creating resource with invalid RDF") default void testWeirdRDF() { final String rdf = getResourceAsString(SIMPLE_RESOURCE) + "<> a \"skos concept\" ."; // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(rdf, TEXT_TURTLE))) { assertEquals(CLIENT_ERROR, res.getStatusInfo().getFamily(), "Semantically invalid RDF should throw a 4xx error"); assertTrue(getLinks(res).stream().anyMatch(hasConstrainedBy(Trellis.InvalidRange)), "Check for an InvalidRange constraint for weird rdf:type constructs"); } }
/** * Test POSTing an RDF resource. */ @Test @DisplayName("Test POSTing an RDF resource") default void testPostRDF() { final String content = getResourceAsString(SIMPLE_RESOURCE); // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(content, TEXT_TURTLE))) { assertAll("Check POSTing an RDF resource", checkRdfResponse(res, LDP.RDFSource, null)); final String location = res.getLocation().toString(); assertTrue(location.startsWith(getBaseURL()), "Check the Location header"); assertTrue(location.length() > getBaseURL().length(), "Re-check the Location header"); } }
/** * Test POSTing an RDF resource. */ @Test @DisplayName("Test POSTing an RDF resource") default void testPostRDF() { final String content = getResourceAsString(SIMPLE_RESOURCE); // POST an LDP-RS try (final Response res = target().request().header(SLUG, generateRandomValue(getClass().getSimpleName())) .post(entity(content, TEXT_TURTLE))) { assertAll("Check POSTing an RDF resource", checkRdfResponse(res, LDP.RDFSource, null)); final String location = res.getLocation().toString(); assertTrue(location.startsWith(getBaseURL()), "Check the Location header"); assertTrue(location.length() > getBaseURL().length(), "Re-check the Location header"); } }