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.Ignore; 025import org.junit.Test; 026 027import java.io.IOException; 028import java.util.HashMap; 029import java.util.Map; 030 031import static javax.ws.rs.core.Response.Status.CREATED; 032import static org.junit.Assert.assertFalse; 033 034/** 035 * @author cabeer 036 */ 037@Ignore // TODO FIX THESE TESTS 038public class LdpIT extends AbstractIntegrationRdfIT { 039 @Test 040 public void testExample10() throws IOException { 041 final String pid = getRandomUniqueId(); 042 final HttpResponse response = createObject(pid); 043 final String location = response.getFirstHeader("Location").getValue(); 044 045 final String body = "\n" + 046 "@prefix ldp: <http://www.w3.org/ns/ldp#>.\n" + 047 "@prefix dcterms: <http://purl.org/dc/terms/>.\n" + 048 "@prefix o: <http://example.org/ontology#>.\n" + 049 "<> dcterms:title \"The liabilities of JohnZSmith\";\n" + 050 " ldp:membershipResource <" + location + ">;\n" + 051 " ldp:hasMemberRelation o:liability;\n"; 052 053 final Map<String, String> headers = new HashMap(); 054 headers.put("Link", "<http://www.w3.org/ns/ldp#DirectContainer>;rel=type"); 055 createLDPRSAndCheckResponse(pid + "/liabilities", body, headers); 056 057 final HttpPost httpPost1 = new HttpPost(serverAddress + pid + "/liabilities"); 058 httpPost1.setHeader("Slug", "l1"); 059 checkResponse(execute(httpPost1), CREATED); 060 061 final HttpPost httpPost2 = new HttpPost(serverAddress + pid + "/liabilities"); 062 httpPost2.setHeader("Slug", "l2"); 063 checkResponse(execute(httpPost2), CREATED); 064 065 final HttpPost httpPost3 = new HttpPost(serverAddress + pid + "/liabilities"); 066 httpPost3.setHeader("Slug", "l3"); 067 checkResponse(execute(httpPost3), CREATED); 068 069 final HttpGet httpGet = new HttpGet(location); 070 httpGet.addHeader("Prefer", "return=representation; " + 071 "include=\"http://www.w3.org/ns/ldp#PreferMembership " + 072 "http://www.w3.org/ns/ldp#PreferMinimalContainer\"; " + 073 "omit=\"http://fedora.info/definitions/v4/repository#ServerManaged\""); 074 final Dataset dataset = getDataset(httpGet); 075 076 assertFalse(dataset.asDatasetGraph().isEmpty()); 077 } 078}