|
From: Jeremy J C. <jj...@sy...> - 2013-08-06 23:33:56
|
Hi I have fixed trac 704 concerning ASK and JSON
Underlying problem was sesame support for this was missing.
I added it to ConnegUtil with:
static {
// Work-around for sesame not handling ask and json (see trac 704)
final BooleanQueryResultFormat askJsonFormat = BooleanQueryResultFormat.register("SPARQL/JSON","application/sparql-results+json","srj");
BooleanQueryResultWriterRegistry.getInstance().add(new BooleanQueryResultWriterFactory(){
@Override
public BooleanQueryResultFormat getBooleanQueryResultFormat() {
return askJsonFormat;
}
@Override
public BooleanQueryResultWriter getWriter(final OutputStream out) {
return new BooleanQueryResultWriter(){
@Override
public BooleanQueryResultFormat getBooleanQueryResultFormat() {
return askJsonFormat;
}
@Override
public void write(boolean arg0) throws IOException {
String answer = "{ \"head\":{ } , \"boolean\": " + Boolean.toString(arg0) + " }";
out.write(answer.getBytes("utf-8"));
}};
}});
}
The test framework additions allow mocking a HttpRequest and Responses to a servlet, to test for such protocol issues. I used easy mock 3.2, apache 2.0 license, to help do this.
I am running
com.bigdata.rdf.sail.TestAll
to verify
The changes are in a patch on the trac ticket, and can also be seen in Git at:
https://github.com/jeremycarroll/bigdata/compare/base-for-servlet-testing...trac-704-ask-json
Jeremy
Jeremy J Carroll
Principal Architect
Syapse, Inc.
|