Skip to content

Commit

Permalink
#511 add test
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Oct 28, 2024
1 parent dcaac92 commit 74dd6de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import java.io.StringReader;
Expand All @@ -37,7 +38,11 @@ public void inlineQuery() throws Exception {
}

private static void query(String f, String q) throws Exception {
String out = SPARQLAnything.callMain(new String[]{"-q", q, "-c", "location=" + f, "-f", "CSV"});
query(new String[]{"-q", q, "-c", "location=" + f, "-f", "CSV"});
}

private static String query(String[] args) throws Exception {
String out = SPARQLAnything.callMain(args);
CSVParser parser = new CSVParser(new StringReader(out), CSVFormat.DEFAULT);
Set<String> actualSet = new HashSet<>();
for (CSVRecord record : parser) {
Expand All @@ -54,8 +59,15 @@ private static void query(String f, String q) throws Exception {
expectedSet.add("http://sparql.xyz/facade-x/data/genre");
expectedSet.add("http://sparql.xyz/facade-x/data/publish_date");
Assert.assertEquals(expectedSet, actualSet);
return out;
}

@Test
public void infileQueryWithValues() throws Exception {
String f = Objects.requireNonNull(getClass().getClassLoader().getResource("books.xml")).toURI().toString();
String queryFile = Objects.requireNonNull(getClass().getClassLoader().getResource("CLITestOnFileQuery1.sparql")).toURI().toString();
query(new String[]{"-q", queryFile, "-v", "loc=" + f, "-f", "CSV"});
}

@Test
public void infileQuery() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PREFIX fx: <http://sparql.xyz/facade-x/ns/> SELECT * { SERVICE <x-sparql-anything:> { fx:properties fx:location ?_loc . ?s ?p ?o OPTIONAL {?s a ?c}} }

0 comments on commit 74dd6de

Please sign in to comment.