001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.integration.rdf; 007 008import org.apache.jena.query.Dataset; 009import org.apache.http.HttpResponse; 010import org.apache.http.client.methods.HttpGet; 011import org.apache.http.client.methods.HttpPost; 012import org.junit.Ignore; 013import org.junit.Test; 014 015import java.io.IOException; 016import java.util.HashMap; 017import java.util.Map; 018 019import static javax.ws.rs.core.Response.Status.CREATED; 020import static org.junit.Assert.assertFalse; 021 022/** 023 * @author cabeer 024 */ 025@Ignore // TODO FIX THESE TESTS 026public class LdpIT extends AbstractIntegrationRdfIT { 027 @Test 028 public void testExample10() throws IOException { 029 final String pid = getRandomUniqueId(); 030 final HttpResponse response = createObject(pid); 031 final String location = response.getFirstHeader("Location").getValue(); 032 033 final String body = "\n" + 034 "@prefix ldp: <http://www.w3.org/ns/ldp#>.\n" + 035 "@prefix dcterms: <http://purl.org/dc/terms/>.\n" + 036 "@prefix o: <http://example.org/ontology#>.\n" + 037 "<> dcterms:title \"The liabilities of JohnZSmith\";\n" + 038 " ldp:membershipResource <" + location + ">;\n" + 039 " ldp:hasMemberRelation o:liability;\n"; 040 041 final Map<String, String> headers = new HashMap(); 042 headers.put("Link", "<http://www.w3.org/ns/ldp#DirectContainer>;rel=type"); 043 createLDPRSAndCheckResponse(pid + "/liabilities", body, headers); 044 045 final HttpPost httpPost1 = new HttpPost(serverAddress + pid + "/liabilities"); 046 httpPost1.setHeader("Slug", "l1"); 047 checkResponse(execute(httpPost1), CREATED); 048 049 final HttpPost httpPost2 = new HttpPost(serverAddress + pid + "/liabilities"); 050 httpPost2.setHeader("Slug", "l2"); 051 checkResponse(execute(httpPost2), CREATED); 052 053 final HttpPost httpPost3 = new HttpPost(serverAddress + pid + "/liabilities"); 054 httpPost3.setHeader("Slug", "l3"); 055 checkResponse(execute(httpPost3), CREATED); 056 057 final HttpGet httpGet = new HttpGet(location); 058 httpGet.addHeader("Prefer", "return=representation; " + 059 "include=\"http://www.w3.org/ns/ldp#PreferMembership " + 060 "http://www.w3.org/ns/ldp#PreferMinimalContainer\"; " + 061 "omit=\"http://fedora.info/definitions/v4/repository#ServerManaged\""); 062 final Dataset dataset = getDataset(httpGet); 063 064 assertFalse(dataset.asDatasetGraph().isEmpty()); 065 } 066}