/** * purgeRelationship should be idempotent with respect to the returned HTTP status code. The * response body however, should indicate "false" for successive deletes of the same resource. * * @throws Exception */ @Test public void testIdempotency() throws Exception { FedoraResponse response = null; Model model = null; Statement s = null; String subject = String.format("info:fedora/%s", testPid); String predicate = "urn:foo/p"; String object = "你好"; // first add a relationship response = addRelationship(testPid).predicate(predicate).object(object, true).execute(); assertEquals(200, response.getStatus()); // verify it was added response = getRelationships(testPid).predicate(predicate).execute(); assertEquals(200, response.getStatus()); model = ModelFactory.createDefaultModel(); model.read(response.getEntityInputStream(), null, FileUtils.langXML); StmtIterator it = model.listStatements(); while (it.hasNext()) { s = it.next(); assertEquals(subject, s.getSubject().toString()); assertEquals(predicate, s.getPredicate().toString()); assertEquals(object, s.getObject().toString()); } // now delete it response = purgeRelationship(testPid).predicate(predicate).object(object, true).execute(); assertEquals(200, response.getStatus()); assertEquals("true", response.getEntity(String.class)); // verify it's gone response = getRelationships(testPid).predicate(predicate).execute(); assertEquals(200, response.getStatus()); model = ModelFactory.createDefaultModel(); model.read(response.getEntityInputStream(), null, FileUtils.langXML); it = model.listStatements(); while (it.hasNext()) { s = it.next(); assertFalse(predicate.equals(s.getPredicate().toString())); assertFalse(object.equals(s.getObject().toString())); } response = purgeRelationship(testPid).predicate(predicate).object(object, true).execute(); assertEquals(200, response.getStatus()); assertEquals("false", response.getEntity(String.class)); }
protected void naiveGetDatastreams(Set<String> pids, Set<String> dsids) throws Exception { FedoraResponse response = null; for (String pid : pids) { for (String dsid : dsids) { response = getDatastreamDissemination(pid, dsid).execute(); assertEquals(200, response.getStatus()); response.getEntity(String.class); response.close(); } } }