Skip to content

Commit

Permalink
Fix #320
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Dec 17, 2022
1 parent 401e44c commit db77bf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private static void executeQuery(String outputFormat, Dataset kb, Query query, P
} else if (format.equals("CSV")) {
ResultSetFormatter.outputAsCSV(pw, QueryExecutionFactory.create(q, kb).execAsk());
} else if (format.equals("TEXT")) {
ResultSetFormatter.outputAsCSV(pw, QueryExecutionFactory.create(q, kb).execAsk());
pw.print(QueryExecutionFactory.create(q, kb).execAsk());
//ResultSetFormatter.outputAsCSV(pw, QueryExecutionFactory.create(q, kb).execAsk());
} else {
throw new RuntimeException("Unsupported format: " + format);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.basilapi.basil.sparql.UnknownQueryTypeException;
import org.apache.commons.io.IOUtils;
import org.apache.jena.query.ResultSetFormatter;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -35,15 +36,12 @@ public class TestIssue320 {
@Test
public void testIssue320() throws Exception {
// This is to reproduce Issue #320
// No output form below
ResultSetFormatter.outputAsCSV(System.err,true);
ResultSetFormatter.outputAsCSV(System.err,false);

String str = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("./ask.sparql"), StandardCharsets.UTF_8);
String output = SPARQLAnything.callMain(new String[]{"-q", str, "-f", "text"});
System.out.println(output);
//
// while (it.hasNext()) {
// QuerySolution qs = parameters.nextSolution();
// }
Assert.assertTrue(output.equals("false"));
}
}

0 comments on commit db77bf6

Please sign in to comment.