001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.integration.rdf; 019 020import org.apache.jena.query.Dataset; 021import org.apache.http.HttpResponse; 022import org.apache.http.client.methods.HttpGet; 023import org.apache.http.client.methods.HttpPost; 024import org.junit.Test; 025 026import java.io.IOException; 027 028import static javax.ws.rs.core.Response.Status.CREATED; 029import static org.junit.Assert.assertFalse; 030 031/** 032 * @author cabeer 033 */ 034public class LdpIT extends AbstractIntegrationRdfIT { 035 @Test 036 public void testExample10() throws IOException { 037 final String pid = getRandomUniqueId(); 038 final HttpResponse response = createObject(pid); 039 final String location = response.getFirstHeader("Location").getValue(); 040 041 final String body = "\n" + 042 "@prefix ldp: <http://www.w3.org/ns/ldp#>.\n" + 043 "@prefix dcterms: <http://purl.org/dc/terms/>.\n" + 044 "@prefix o: <http://example.org/ontology#>.\n" + 045 "<> a ldp:DirectContainer ;" + 046 " dcterms:title \"The liabilities of JohnZSmith\";\n" + 047 " ldp:membershipResource <" + location + ">;\n" + 048 " ldp:hasMemberRelation o:liability;\n"; 049 050 createLDPRSAndCheckResponse(pid + "/liabilities", body); 051 052 final HttpPost httpPost1 = new HttpPost(serverAddress + pid + "/liabilities"); 053 httpPost1.setHeader("Slug", "l1"); 054 checkResponse(execute(httpPost1), CREATED); 055 056 final HttpPost httpPost2 = new HttpPost(serverAddress + pid + "/liabilities"); 057 httpPost2.setHeader("Slug", "l2"); 058 checkResponse(execute(httpPost2), CREATED); 059 060 final HttpPost httpPost3 = new HttpPost(serverAddress + pid + "/liabilities"); 061 httpPost3.setHeader("Slug", "l3"); 062 checkResponse(execute(httpPost3), CREATED); 063 064 final HttpGet httpGet = new HttpGet(location); 065 httpGet.addHeader("Prefer", "return=representation; " + 066 "include=\"http://www.w3.org/ns/ldp#PreferMembership " + 067 "http://www.w3.org/ns/ldp#PreferMinimalContainer\"; " + 068 "omit=\"http://fedora.info/definitions/v4/repository#ServerManaged\""); 069 final Dataset dataset = getDataset(httpGet); 070 071 assertFalse(dataset.asDatasetGraph().isEmpty()); 072 } 073}