Search in sources :

Example 1 with TupleQueryResultWriter

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+", ""));
}
Also used : TupleQueryResultWriter(org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter) TupleQueryResultFormat(org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AbstractQueryResultIOTupleTest(org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest) Test(org.junit.Test)

Example 2 with TupleQueryResultWriter

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"));
}
Also used : TupleQueryResultWriter(org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter) TupleQueryResultFormat(org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AbstractQueryResultIOTupleTest(org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest) Test(org.junit.Test)

Example 3 with TupleQueryResultWriter

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"));
}
Also used : TupleQueryResultWriter(org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter) TupleQueryResultFormat(org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AbstractQueryResultIOTupleTest(org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest) Test(org.junit.Test)

Example 4 with TupleQueryResultWriter

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"));
}
Also used : TupleQueryResultWriter(org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter) TupleQueryResultFormat(org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AbstractQueryResultIOTupleTest(org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest) Test(org.junit.Test)

Example 5 with TupleQueryResultWriter

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"));
}
Also used : TupleQueryResultWriter(org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter) TupleQueryResultFormat(org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AbstractQueryResultIOTupleTest(org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 TupleQueryResultFormat (org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat)10 TupleQueryResultWriter (org.eclipse.rdf4j.query.resultio.TupleQueryResultWriter)10 AbstractQueryResultIOTupleTest (org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest)8 Test (org.junit.Test)8