Skip to content

Commit

Permalink
Merge pull request #30 from acoburn/sesame-support
Browse files Browse the repository at this point in the history
added sesame support to the SparqlProcessor classes
  • Loading branch information
Andrew Woods committed Jan 6, 2015
2 parents a361ca1 + 6247320 commit 94a936d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Expand Up @@ -56,10 +56,10 @@ public void process(final Exchange exchange) throws IOException {
* too many triples from the triplestore. This command does
* not remove blank nodes.
*/
in.setBody("DELETE WHERE { <" + subject + "> ?p ?o };\n" +
in.setBody("update=DELETE WHERE { <" + subject + "> ?p ?o };\n" +
"DELETE WHERE { <" + subject + "/fcr:export?format=jcr/xml> ?p ?o }");
in.setHeader(HTTP_METHOD, "POST");
in.setHeader(CONTENT_TYPE, "application/sparql-update");
in.setHeader(CONTENT_TYPE, "application/x-www-form-urlencoded");

}
}
Expand Up @@ -56,8 +56,8 @@ public void process(final Exchange exchange) throws IOException {
"application/n-triples".equals(contentType) ? "text/rdf+nt" : contentType, null);
serializer.serialize(serializedGraph, graph.getGraph(), "text/rdf+nt");

exchange.getIn().setBody("INSERT DATA { " + serializedGraph.toString("UTF-8") + " }");
exchange.getIn().setBody("update=INSERT DATA { " + serializedGraph.toString("UTF-8") + " }");
exchange.getIn().setHeader(HTTP_METHOD, "POST");
exchange.getIn().setHeader(CONTENT_TYPE, "application/sparql-update");
exchange.getIn().setHeader(CONTENT_TYPE, "application/x-www-form-urlencoded");
}
}
Expand Up @@ -73,11 +73,11 @@ public void process(final Exchange exchange) throws IOException {
* delete too many triples from the triplestore. This command does
* not delete blank nodes.
*/
exchange.getIn().setBody("DELETE WHERE { <" + subject + "> ?p ?o };\n" +
exchange.getIn().setBody("update=DELETE WHERE { <" + subject + "> ?p ?o };\n" +
"DELETE WHERE { <" + subject + "/fcr:export?format=jcr/xml> ?p ?o };\n" +
"INSERT { " + serializedGraph.toString("UTF-8") + " }\n" +
"WHERE { }");
exchange.getIn().setHeader(HTTP_METHOD, "POST");
exchange.getIn().setHeader(CONTENT_TYPE, "application/sparql-update");
exchange.getIn().setHeader(CONTENT_TYPE, "application/x-www-form-urlencoded");
}
}
4 changes: 2 additions & 2 deletions src/test/java/org/fcrepo/camel/SparqlDeleteProcessorTest.java
Expand Up @@ -83,9 +83,9 @@ public void testDelete() throws IOException, InterruptedException {

// Assertions
resultEndpoint.expectedBodiesReceived(
"DELETE WHERE { <" + base + path + "> ?p ?o };\n" +
"update=DELETE WHERE { <" + base + path + "> ?p ?o };\n" +
"DELETE WHERE { <" + base + path + "/fcr:export?format=jcr/xml> ?p ?o }");
resultEndpoint.expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/sparql-update");
resultEndpoint.expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded");
resultEndpoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");

// Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/fcrepo/camel/SparqlInsertProcessorTest.java
Expand Up @@ -61,8 +61,8 @@ public void testDescribe() throws IOException, InterruptedException {
reverse(lines);

// Assertions
resultEndpoint.expectedBodiesReceived("INSERT DATA { " + join(lines, " ") + " }");
resultEndpoint.expectedHeaderReceived("Content-Type", "application/sparql-update");
resultEndpoint.expectedBodiesReceived("update=INSERT DATA { " + join(lines, " ") + " }");
resultEndpoint.expectedHeaderReceived("Content-Type", "application/x-www-form-urlencoded");
resultEndpoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");

// Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/fcrepo/camel/SparqlUpdateProcessorTest.java
Expand Up @@ -62,11 +62,11 @@ public void testDescribe() throws IOException, InterruptedException {

// Assertions
resultEndpoint.expectedBodiesReceived(
"DELETE WHERE { <" + base + path + "> ?p ?o }; " +
"update=DELETE WHERE { <" + base + path + "> ?p ?o }; " +
"DELETE WHERE { <" + base + path + "/fcr:export?format=jcr/xml> ?p ?o }; " +
"INSERT { " + join(lines, " ") + " } " +
"WHERE { }");
resultEndpoint.expectedHeaderReceived("Content-Type", "application/sparql-update");
resultEndpoint.expectedHeaderReceived("Content-Type", "application/x-www-form-urlencoded");
resultEndpoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");

// Test
Expand Down
Expand Up @@ -99,7 +99,7 @@ public void testUpdateSparql() throws Exception {
sparqlQueryEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);

sparqlUpdateEndpoint.expectedMessageCount(1);
sparqlUpdateEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 204);
sparqlUpdateEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);

deletedEndpoint.expectedMessageCount(2);
deletedEndpoint.expectedBodiesReceived(null, null);
Expand Down Expand Up @@ -142,13 +142,13 @@ public void testUpdateSparql() throws Exception {
public void testInsertDeleteSparql() throws Exception {
// Assertions
resultEndpoint.expectedMessageCount(1);
resultEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 204);
resultEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);

sparqlQueryEndpoint.expectedMessageCount(6);
sparqlQueryEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);

sparqlUpdateEndpoint.expectedMessageCount(4);
sparqlUpdateEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 204);
sparqlUpdateEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);

deletedEndpoint.expectedMessageCount(2);
deletedEndpoint.expectedBodiesReceived(null, null);
Expand Down

0 comments on commit 94a936d

Please sign in to comment.