use of org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter in project rdf4j by eclipse.
the class SPARQLCSVTupleTest method testEndOfLine.
@Test
public void testEndOfLine() throws Exception {
TupleQueryResultFormat format = getTupleFormat();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out);
writer.startDocument();
writer.startHeader();
writer.handleLinks(Arrays.<String>asList());
QueryResults.report(createTupleNoBindingSets(), writer);
assertEquals("\r\n", out.toString("UTF-8").replaceAll("\\S+", ""));
}
use of org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter in project rdf4j by eclipse.
the class SPARQLCSVTupleTest method testEmptyResults.
@Test
public void testEmptyResults() throws Exception {
TupleQueryResultFormat format = getTupleFormat();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out);
writer.startDocument();
writer.startHeader();
writer.handleLinks(Arrays.<String>asList());
QueryResults.report(createTupleNoBindingSets(), writer);
assertRegex("a,b,c(\r\n)?", out.toString("UTF-8"));
}
use of org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter in project rdf4j by eclipse.
the class SPARQLCSVTupleTest method testSingleVarResults.
@Test
public void testSingleVarResults() throws Exception {
TupleQueryResultFormat format = getTupleFormat();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out);
writer.startDocument();
writer.startHeader();
writer.handleLinks(Arrays.<String>asList());
QueryResults.report(createTupleSingleVarMultipleBindingSets(), writer);
System.out.println(out.toString("UTF-8"));
assertRegex("a\r\n" + "foo:bar\r\n" + "2.0(E0)?\r\n" + "_:bnode3\r\n" + "''single-quoted string\r\n" + "\"\"\"\"\"double-quoted string\"\r\n" + "space at the end \r\n" + "space at the end \r\n" + "\"\"\"\"\"double-quoted string with no datatype\"\r\n" + "\"newline at the end \n\"(\r\n)?", out.toString("UTF-8"));
}
use of org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter in project rdf4j by eclipse.
the class SPARQLCSVTupleTest method testmultipleVarResults.
@Test
public void testmultipleVarResults() throws Exception {
TupleQueryResultFormat format = getTupleFormat();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out);
writer.startDocument();
writer.startHeader();
writer.handleLinks(Arrays.<String>asList());
QueryResults.report(createTupleMultipleBindingSets(), writer);
assertRegex("a,b,c\r\n" + "foo:bar,_:bnode,baz\r\n" + "1,,Hello World!\r\n" + "http://example.org/test/ns/bindingA,http://example.com/other/ns/bindingB,\"http://example.com/other/ns/binding,C\"\r\n" + "\"string with newline at the end \n\",string with space at the end , \r\n" + "''single-quoted string,\"\"\"\"\"double-quoted string\",\t\tunencoded tab characters followed by encoded \t\t(\r\n)?", out.toString("UTF-8"));
}
use of org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter in project rdf4j by eclipse.
the class SPARQLCSVTupleBackgroundTest method testSingleVarResults.
@Test
public void testSingleVarResults() throws Exception {
TupleQueryResultFormat format = getTupleFormat();
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out);
writer.startDocument();
writer.startHeader();
writer.handleLinks(Arrays.<String>asList());
QueryResults.report(createTupleSingleVarMultipleBindingSets(), writer);
System.out.println(out.toString("UTF-8"));
assertRegex("a\r\n" + "foo:bar\r\n" + "2.0(E0)?\r\n" + "_:bnode3\r\n" + "''single-quoted string\r\n" + "\"\"\"\"\"double-quoted string\"\r\n" + "space at the end \r\n" + "space at the end \r\n" + "\"\"\"\"\"double-quoted string with no datatype\"\r\n" + "\"newline at the end \n\"(\r\n)?", out.toString("UTF-8"));
}
Aggregations