Skip to content

Commit

Permalink
Add IT for preserving properties on federated filesystem moves
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles authored and Andrew Woods committed Sep 12, 2014
1 parent f1e2a7c commit e1cfab0
Showing 1 changed file with 41 additions and 0 deletions.
Expand Up @@ -1562,6 +1562,47 @@ public void testFederatedDatastream() throws IOException {
assertEquals("Couldn't link to external datastream!", 204, getStatus(patch));
}

/**
* I should be able to move a node within a federated filesystem with
* properties preserved.
**/
@Test
public void testFederatedMoveWithProperties() throws Exception {
// create object on federation
final String pid = getRandomUniquePid();
final String source = serverAddress + "files/" + pid + "/src";
createObject("files/" + pid + "/src");

// add properties
final HttpPatch patch = new HttpPatch(source);
patch.addHeader("Content-Type", "application/sparql-update");
final BasicHttpEntity e = new BasicHttpEntity();
final String sparql = "insert { <> <http://purl.org/dc/elements/1.1/identifier> \"identifier.123\" . "
+ "<> <http://purl.org/dc/elements/1.1/title> \"title.123\" } where {}";
e.setContent(new ByteArrayInputStream(sparql.getBytes()));
patch.setEntity(e);
final HttpResponse response = client.execute(patch);
assertEquals(NO_CONTENT.getStatusCode(), response.getStatusLine().getStatusCode());

// move object
final String destination = serverAddress + "files/" + pid + "/dst";
final HttpMove request = new HttpMove(source);
request.addHeader("Destination", destination);
final HttpResponse moveRequest = client.execute(request);
assertEquals(CREATED.getStatusCode(), moveRequest.getStatusLine().getStatusCode());

// check properties
final HttpGet get = new HttpGet(destination);
get.addHeader("Accept", "application/n-triples");
final GraphStore graphStore = getGraphStore(get);
assertTrue(graphStore.contains(Node.ANY, NodeFactory.createURI(destination),
NodeFactory.createURI("http://purl.org/dc/elements/1.1/identifier"),
NodeFactory.createLiteral("identifier.123")));
assertTrue(graphStore.contains(Node.ANY, NodeFactory.createURI(destination),
NodeFactory.createURI("http://purl.org/dc/elements/1.1/title"),
NodeFactory.createLiteral("title.123")));
}

@Test
public void testPaging() throws Exception {
// create a node with 4 children
Expand Down

0 comments on commit e1cfab0

Please sign in to comment.