/* Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved. Contact: SYSTAP, LLC DBA Blazegraph 2501 Calvert ST NW #106 Washington, DC 20008 licenses@blazegraph.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * Created on Jun 19, 2008 */ package com.bigdata.rdf.sail.tck; import info.aduna.io.IOUtil; import info.aduna.iteration.Iterations; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.Set; import junit.framework.Test; import junit.framework.TestSuite; import org.openrdf.model.Resource; import org.openrdf.model.Statement; import org.openrdf.model.URI; import org.openrdf.model.Value; import org.openrdf.model.util.ModelUtil; import org.openrdf.query.BindingSet; import org.openrdf.query.BooleanQuery; import org.openrdf.query.Dataset; import org.openrdf.query.GraphQuery; import org.openrdf.query.GraphQueryResult; import org.openrdf.query.Query; import org.openrdf.query.QueryLanguage; import org.openrdf.query.QueryResults; import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; import org.openrdf.query.impl.MutableTupleQueryResult; import org.openrdf.query.parser.sparql.manifest.ManifestTest; import org.openrdf.query.parser.sparql.manifest.SPARQL11ManifestTest; import org.openrdf.query.parser.sparql.manifest.SPARQLQueryTest; import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryException; import org.openrdf.repository.dataset.DatasetRepository; import org.openrdf.repository.sail.SailRepository; import org.openrdf.rio.helpers.BasicParserSettings; import org.openrdf.sail.memory.MemoryStore; import com.bigdata.BigdataStatics; import com.bigdata.btree.keys.CollatorEnum; import com.bigdata.btree.keys.StrengthEnum; import com.bigdata.journal.BufferMode; import com.bigdata.journal.IIndexManager; import com.bigdata.journal.Journal; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.sail.BigdataSail; import com.bigdata.rdf.sail.BigdataSail.Options; import com.bigdata.rdf.sail.BigdataSailRepository; import com.bigdata.rdf.sail.BigdataSailRepositoryConnection; import com.bigdata.rdf.sail.BigdataSailTupleQuery; import com.bigdata.rdf.sparql.ast.QueryRoot; /** * Test harness for running the SPARQL test suites. This version runs against * a {@link Journal} without full read/write transaction support. * * @author <a href="mailto:thompsonbry@users.sourceforge.net">Bryan Thompson</a> */ public class BigdataSparqlTest extends SPARQLQueryTest // Sesame TupleExpr based evaluation //extends SPARQLASTQueryTest // Bigdata native AST based evaluation { // static private final Logger log = Logger.getLogger(BigdataSparqlTest.class); /** * We cannot use inlining for these test because we do normalization on * numeric values and these tests test for syntactic differences, i.e. * 01 != 1. */ static protected final Collection<String> cannotInlineTests = Arrays.asList(new String[] { "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-01", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-03", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-04", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-1", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-2", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-1", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-simple", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-eq", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-not-eq", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-1", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-2", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#no-distinct-1", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-1", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#no-distinct-9", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-9", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#date-2", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#date-3", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#date-4", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-exists-05", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-exists-06", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#hours", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#timezone", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#tz", }); /** * The tests test things that are no longer in the spec or that use an * illegal syntax. */ static final public Collection<String> badTests = Arrays.asList(new String[] { "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-04", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-05", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-06", /* * These use illegal URIs in the query (missing a ":"). */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/property-path/manifest#pp35", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/exists/manifest#exists03", /* * This one fails because our bnode() function uses a different bnode * id naming scheme than the sesame one. Not technically a failure. */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#bnode01", }); /** * These tests fail but should not. They are conditionally disabled based on * {@link BigdataStatics#runKnownBadTests}. This is done as a convenience to * 'green' up CI. */ static final public Collection<String> knownBadTests = Arrays.asList(new String[] { // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-2", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-cycles-04", //"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-subquery-04", // BLZG-618 /* This query currently works: */ //"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-subquery-06", //"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-order-02", // BLZG-618 //"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-order-03", // BLZG-618 /* This test actually produces correct result (see TestTCK.test_sparql11_sum_02()) * which is deemed incorrect because sparql11-sum-02.srx in * the Sesame Test Suite v2.7.12 is wrong: it specifies {totalPrice=0} * as the correct result (see TestTCK.test_sparql11_sum_02()). Note that * the latest release sesame-sparql-testsuite 4.1.1 still contains * the wrong result file. * See https://openrdf.atlassian.net/browse/SES-884 */ "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sum-02", /* * This test produces no result instead of an empty result. ========================================= Expected results: [] ========================================= Bigdata results: ========================================= Missing results: [] ========================================= Query: PREFIX ex: <http://example.com/> SELECT ?x (MAX(?value) AS ?max) WHERE { ?x ex:p ?value } GROUP BY ?x ========================================= Data: @prefix ex: <http://example.com/> . ========================================= */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#agg-empty-group2", /* * This test produces some extra results. * ========================================= Expected results: [s=http://example.org/a;o1=http://example.org/b;o2=http://example.org/b] [s=http://example.org/a;o1="alan@example.org";o2=http://example.org/b] [s=http://example.org/a;o1="Alan";o2=http://example.org/b] [s=http://example.org/c;o1="alice@example.org";o2=http://example.org/b] [s=http://example.org/c;o1="Alice";o2=http://example.org/b] ========================================= Bigdata results: [o2=http://example.org/b;s=http://example.org/a;o1=http://example.org/b] [o2=http://example.org/b;s=http://example.org/a;o1="alan@example.org"] [o2=http://example.org/b;s=http://example.org/a;o1="Alan"] [o2=http://example.org/b;s=http://example.org/b;o1=http://example.org/c] [o2=http://example.org/b;s=http://example.org/b;o1="bob@example.org"] [o2=http://example.org/b;s=http://example.org/b;o1="Bob"] [o2=http://example.org/b;s=http://example.org/c;o1="alice@example.org"] [o2=http://example.org/b;s=http://example.org/c;o1="Alice"] ========================================= Extra results: [o2=http://example.org/b;s=http://example.org/b;o1=http://example.org/c] [o2=http://example.org/b;s=http://example.org/b;o1="bob@example.org"] [o2=http://example.org/b;s=http://example.org/b;o1="Bob"] ========================================= Query: # bindings with two variables and two sets of values PREFIX : <http://example.org/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?s ?o1 ?o2 { ?s ?p1 ?o1 OPTIONAL { ?s foaf:knows ?o2 } } VALUES (?o2) { (:b) } ========================================= Data: @prefix : <http://example.org/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . :a foaf:name "Alan" . :a foaf:mbox "alan@example.org" . :b foaf:name "Bob" . :b foaf:mbox "bob@example.org" . :c foaf:name "Alice" . :c foaf:mbox "alice@example.org" . :a foaf:knows :b . :b foaf:knows :c . * * We produce solutions for Bob and the test says we shouldn't. I'm * not convinced that we are wrong. ?o2 is bound to :b, and even * though Bob doesn't know :b, that knows is optional. Alice doesn't * know :b either, and she gets a solution. How do we differentiate? */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values7", /* ========================================= Expected results: <http://example.org/s2, http://example.org/p, http://example.org/o1> <http://example.org/s2, http://example.org/p, http://example.org/o2> <http://example.org/s1, http://example.org/p, http://example.org/o1> <http://example.org/s3, http://example.org/p, http://example.org/o3> ========================================= Bigdata results: ========================================= Query: PREFIX : <http://example.org/> CONSTRUCT FROM <data.ttl> WHERE { ?s ?p ?o } ========================================= Data: ========================================= */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/construct/manifest#constructwhere04", /* ========================================= Expected results: [s=http://www.example.org/s;p=http://www.example.org/p] ========================================= Bigdata results: ========================================= Missing results: [s=http://www.example.org/s;p=http://www.example.org/p] ========================================= Query: prefix ex: <http://www.example.org/> select * where { ?s ?p ex:o filter exists { ?s ?p ex:o1 filter exists { ?s ?p ex:o2 } } } ========================================= Data: @prefix : <http://www.example.org/> . :s :p :o, :o1, :o2. :t :p :o1, :o2. ========================================= This query currently works correctly. */ //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/exists/manifest#exists04", /* * These two are the same problem. We drop solutions that do not have * a binding for the group by variable. It seems that these should be * placed into their own individual group. ========================================= Expected results: [w="9"^^<http://www.w3.org/2001/XMLSchema#integer>;S="1"^^<http://www.w3.org/2001/XMLSchema#integer>] [S="2"^^<http://www.w3.org/2001/XMLSchema#integer>] ========================================= Bigdata results: [w="9"^^<http://www.w3.org/2001/XMLSchema#integer>;S="1"^^<http://www.w3.org/2001/XMLSchema#integer>] ========================================= Missing results: [S="2"^^<http://www.w3.org/2001/XMLSchema#integer>] ========================================= Query: PREFIX : <http://example/> SELECT ?w (SAMPLE(?v) AS ?S) { ?s :p ?v . OPTIONAL { ?s :q ?w } } GROUP BY ?w ========================================= Data: @prefix : <http://example/> . :s1 :p 1 . :s1 :q 9 . :s2 :p 2 . ========================================= */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/grouping/manifest#group03", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/grouping/manifest#group05", /* * Complex negation tests. */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/negation/manifest#partial-minuend", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/negation/manifest#full-minuend", /* * Really weird zero-length path failure. ========================================= Missing results: [X=http://example.org/h;Y=http://example.org/h] [X="test";Y="test"] ========================================= Query: PREFIX : <http://example.org/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT * WHERE { ?X foaf:knows* ?Y } ORDER BY ?X ?Y ========================================= Data: @prefix : <http://example.org/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . :a foaf:knows :b . :b foaf:knows :c . :a foaf:knows :c . :d foaf:knows :e . :e foaf:knows :f . :f foaf:knows :e . :f foaf:name "test" . :a foaf:homepage :h . ========================================= */ "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/property-path/manifest#pp16", /* * All five of these appear to be the same problem - subquery nested * inside a graph pattern. ========================================= "sq01 - Subquery within graph pattern" ========================================= Query: prefix ex: <http://www.example.org/schema#> prefix in: <http://www.example.org/instance#> select ?x ?p where { graph ?g { {select * where {?x ?p ?y}} } } ========================================= * * Currently (Apr 13, 2016) only subquery03 fails. * */ //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery01", //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery02", "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery03", //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery04", //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery05", /* The following two are covered by: https://jira.blazegraph.com/browse/BLZG-1721 They are no longer in the black list because they work now, after the completion of https://jira.blazegraph.com/browse/BLZG-618 */ //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#agg03", //"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#agg07", }); /** * The following tests require Unicode configuration for identical * comparisons. This appears to work with {ASCII,IDENTICAL} or * {JDK,IDENTICAL} but not with {ICU,IDENTICAL} for some reason. */ static protected final Collection<String> unicodeStrengthIdentical = Arrays.asList(new String[] { "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-1" }); // private static String datasetTests = "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset"; /** * Skip the dataset tests for now until we can figure out what is wrong with * them. * * FIXME Fix the dataset tests. There is some problem in how the data to be * loaded into the fixture is being resolved in these tests. */ public static Test suite() throws Exception { return suite(true /*hideDatasetTests*/); } public static Test suite(final boolean hideDatasetTests) throws Exception { TestSuite suite1 = suiteLTSWithPipelineJoins(); // Only run the specified tests? if (!testURIs.isEmpty()) { final TestSuite suite = new TestSuite(); for (String s : testURIs) { final SPARQLQueryTest test = getSingleTest(suite1, s); if (test == null) throw new RuntimeException("Could not find test: uri=" + s); suite.addTest(test); } return suite; } if (hideDatasetTests) suite1 = filterOutTests(suite1, "dataset"); suite1 = filterOutTests(suite1, badTests); if (!BigdataStatics.runKnownBadTests) suite1 = filterOutTests(suite1, knownBadTests); /** * BSBM BI use case query 5 * * bsbm-bi-q5 * * We were having a problem with this query which I finally tracked this * down to an error in the logic to decide on a merge join. The story is * documented at the trac issue below. However, even after all that the * predicted result for openrdf differs at the 4th decimal place. I have * therefore filtered out this test from the openrdf TCK. * * <pre> * Missing bindings: * [product=http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer2/Product63; * nrOfReviews="3"^^<http://www.w3.org/2001/XMLSchema#integer>; * avgPrice="4207.426"^^<http://www.w3.org/2001/XMLSchema#float>; * country=http://downlode.org/rdf/iso-3166/countries#RU] * ==================================================== * Unexpected bindings: * [country=http://downlode.org/rdf/iso-3166/countries#RU; * product=http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer2/Product63; * nrOfReviews="3"^^<http://www.w3.org/2001/XMLSchema#integer>; * avgPrice="4207.4263"^^<http://www.w3.org/2001/XMLSchema#float>] * </pre> * * @see <a * href="https://sourceforge.net/apps/trac/bigdata/ticket/534#comment:2"> * BSBM BI Q5 Error when using MERGE JOIN </a> */ suite1 = filterOutTests( suite1, "bsbm" ); // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#bsbm-bi-q5"); return suite1; } /** * Hack filters out the "dataset" tests. * * @param suite1 * The test suite. * * @return The test suite without the data set tests. */ static protected TestSuite filterOutTests(final TestSuite suite1, final String name) { final TestSuite suite2 = new TestSuite(suite1.getName()); final Enumeration<Test> e = suite1.tests(); while (e.hasMoreElements()) { final Test aTest = e.nextElement(); if (aTest instanceof TestSuite) { final TestSuite aTestSuite = (TestSuite) aTest; if (!aTestSuite.getName().equals(name)) { suite2.addTest(filterOutTests(aTestSuite,name)); } } else { suite2.addTest(aTest); } } return suite2; } static protected TestSuite filterOutTests(final TestSuite suite1, final Collection<String> testURIs) { final TestSuite suite2 = new TestSuite(suite1.getName()); final Enumeration<Test> e = suite1.tests(); while (e.hasMoreElements()) { final Test aTest = e.nextElement(); if (aTest instanceof TestSuite) { final TestSuite aTestSuite = (TestSuite) aTest; suite2.addTest(filterOutTests(aTestSuite, testURIs)); } else if (aTest instanceof BigdataSparqlTest) { final BigdataSparqlTest test = (BigdataSparqlTest) aTest; if (!testURIs.contains(test.testURI)) { suite2.addTest(test); } } } return suite2; } /** * An array of URIs for tests to be run. When null or empty the default test * suite is run. When specified, only the tests matching these test URIs are * run. */ static protected final Collection<String> testURIs = Arrays.asList(new String[] { /////* // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strdt01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strdt02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strdt03", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strlang01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strlang02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strlang03", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#isnumeric01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#abs01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#ceil01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#floor01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#round01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#concat01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#concat02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#substring01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#substring02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#length01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#ucase01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#lcase01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#encode01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#contains01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#starts01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#ends01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#plus-1", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#plus-2", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#md5-01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#md5-02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha1-01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha1-02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha256-01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha256-02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha512-01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#sha512-02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#minutes", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#seconds", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#hours", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#month", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#year", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#day", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#timezone", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#tz", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#bnode01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#bnode02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#in01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#in02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#notin01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#notin02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#now01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#rand01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#iri01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#if01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#if02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#coalesce01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strbefore01a", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strbefore02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strafter01a", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#strafter02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#replace01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#replace02", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#replace03", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#uuid01", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#struuid01", ////*/ // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values1", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values2", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values3", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values4", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values5", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values6", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values7", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#values8", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#inline1", // "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bindings/manifest#inline2", // property paths // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-collection-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-collection-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-alternative-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-alternative-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-inverse-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-inverse-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-inverse-03", //// Simple Sequences // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-02", // with inverse // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-03", //// Sequence 04, 05, and 06 use the Property paths forms {...}, which were removed in the July 24th Working Draft //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-04", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-05", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-sequence-07", // with optional // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-negated-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-negated-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-negated-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-negated-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-05", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-cycles-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-cycles-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-cycles-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-cycles-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-wildcard-reflexive-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-05", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-nested-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest# // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-simple" // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-2" // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/cast/manifest#cast-dT" // 8, 9, 14-19, 23-30 // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-in-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-in-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-not-in-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-not-in-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-not-in-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-exists-05", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-exists-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-substr-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-substr-03" // derived numeric types // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-08", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-09", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-14", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-19", // Throwing NotSerializableException - something is dragging in the SPOAccessPath // @see http://sourceforge.net/apps/trac/bigdata/ticket/379 // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/triple-match/manifest#dawg-triple-pattern-003", // Hanging with error locating named subquery solution // @see https://sourceforge.net/apps/trac/bigdata/ticket/380#comment:1 // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#nested-opt-1", // Hanging, presumably due to failure to trigger last pass evaluation for SORT. // @see https://sourceforge.net/apps/trac/bigdata/ticket/380#comment:3 // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/sort/manifest#dawg-sort-3", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#nested-opt-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#nested-opt-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#opt-filter-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#opt-filter-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#opt-filter-3", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-place-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-place-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-place-3", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-nested-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-nested-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-scope-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-scope-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-combo-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-combo-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-05", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-07", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-08", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-09", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-10", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-11", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-12", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-13", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-14", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-15", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-16", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-17", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-18", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-19", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-20", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-21", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-22", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-23", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-24", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-25", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-26", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-27", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-28", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-29", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/type-promotion/manifest#type-promotion-30", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-3", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-4", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-5", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/boolean-effective-value/manifest#dawg-bev-6", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-eq", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-02", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-03", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-04", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-05", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-06", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-07", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-08", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-09", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-10", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-11", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-12", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-cmp-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-cmp-02", /* * working through the new query engine failures: 0 errors, 11 failures */ /* * Basically we are having a lot of problems with our compare * operator, which is supposed to do fuzzy comparisons that * sometimes requires materialized RDF values. These I feel I can * handle on my own. */ // "a" and "a"^^xsd:string have different term ids? also bnodes are different // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-07", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-08", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-10", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-11", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-12", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-cmp-01", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-cmp-02", /* * These tests have to do with that that weird "well designed" * optional nesting P = A OPT (B OPT C) where A and C share * variables not in B. I think I can handle these on my own. */ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#nested-opt-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-scope-1", /* * Everything below this point I need help with. */ /* * This one is truly bizarre - involving a non-optional subquuery * plus an optional subquery. Don't even know where to start on this * guy. */ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-scope-1", /* * Sometimes, a filter is the entire join group, and it should not * be able to see variables outside the group. Frankly I do not * understand this one. */ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-nested-2", // /* // * These demonstrate the problem of where to put non-optional // * filters that need to be evaluated after optional tails and // * optional join groups. // * // * NOTE: These are fixed. // */ //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/bound/manifest#dawg-bound-query-001", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-002", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-003", // /* // * These failures have to do with nested UNIONs - we don't seem to // * be handling them correctly at all. // * // * NOTE: These are fixed. // */ //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-combo-1", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#join-combo-2", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional/manifest#dawg-optional-complex-1", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional/manifest#dawg-optional-complex-2", //// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional/manifest#dawg-optional-complex-4", }); /** * Return the sole test in the suite associated with the specified testURI. * * @param suite * The test suite. * @param testURI * The test URI (these are defined by the DAWG). * * @return An instance of this class which will run just that one test. * * @throws RuntimeException * if there is no test in the suite which is associated with * that testURI. */ static protected SPARQLQueryTest getSingleTest(final TestSuite suite, final String testURI) throws RuntimeException { final Enumeration<Test> e1 = suite.tests(); while (e1.hasMoreElements()) { final Test aTest = e1.nextElement(); // log.warn(aTest.toString()); if (aTest instanceof TestSuite) { final SPARQLQueryTest test = getSingleTest((TestSuite) aTest, testURI); if (test != null) return test; } if (aTest instanceof BigdataSparqlTest) { final BigdataSparqlTest test = (BigdataSparqlTest) aTest; if (testURI.equals(test.testURI)) { return test; } } } return null; } /** * Return the test suite. */ public static TestSuite suiteLTSWithPipelineJoins() throws Exception { final SPARQLQueryTest.Factory factory = new SPARQLQueryTest.Factory() { @Override public SPARQLQueryTest createSPARQLQueryTest(String testURI, String name, String queryFileURL, String resultFileURL, Dataset dataSet, boolean laxCardinality) { return createSPARQLQueryTest(testURI, name, queryFileURL, resultFileURL, dataSet, laxCardinality, true/* checkOrder */); } @Override public SPARQLQueryTest createSPARQLQueryTest(String testURI, String name, String queryFileURL, String resultFileURL, Dataset dataSet, boolean laxCardinality, boolean checkOrder) { return new BigdataSparqlTest(testURI, name, queryFileURL, resultFileURL, dataSet, laxCardinality, checkOrder) { @Override protected Properties getProperties() { final Properties p = new Properties( super.getProperties()); // p.setProperty(AbstractResource.Options.NESTED_SUBQUERY, // "false"); return p; } }; } }; final TestSuite suite = new TestSuite(); // SPARQL 1.0 suite.addTest(ManifestTest.suite(factory)); // Old SPARQL 1.1 test suite suite.addTest(SPARQL11ManifestTest.suite(factory, false, false, false)); // Expanded SPARQL 1.1 test suite suite.addTest(SPARQL11ManifestTest.suite(factory, true, false, false, "service")); return suite; } public BigdataSparqlTest(String testURI, String name, String queryFileURL, String resultFileURL, Dataset dataSet, boolean laxCardinality, boolean checkOrder) { super(testURI, name, queryFileURL, resultFileURL, dataSet, laxCardinality, checkOrder); } // public String getTestURI() { // return testURI; // } /** * Overridden to destroy the backend database and its files on the disk. */ @Override public void tearDown() throws Exception { /* StringBuilder message = new StringBuilder(); message.append("data:\n"); RepositoryConnection cxn = dataRep.getConnection(); try { RepositoryResult<Statement> stmts = cxn.getStatements(null, null, null, true); while (stmts.hasNext()) { Statement stmt = stmts.next(); message.append(stmt+"\n"); } } finally { cxn.close(); } SPARQLQueryTest.logger.error(message.toString()); */ IIndexManager backend = null; Repository delegate = dataRep == null ? null : dataRep; // ((DatasetRepository) dataRep).getDelegate(); if (delegate != null && delegate instanceof BigdataSailRepository) { backend = ((BigdataSailRepository) delegate).getSail() .getIndexManager(); } super.tearDown(); if (backend != null) tearDownBackend(backend); /* * Note: this field MUST be cleared to null or the backing database * instance will be held by a hard reference throughout the execution of * all unit tests in this test suite! */ dataRep = null; queryString = null; } /** * Note: This method may be overridden in order to run the test suite * against other variations of the bigdata backend. * * @see #suiteLTSWithNestedSubquery() * @see #suiteLTSWithPipelineJoins() */ protected Properties getProperties() { final Properties props = new Properties(); // final File journal = BigdataStoreTest.createTempFile(); // // props.setProperty(BigdataSail.Options.FILE, journal.getAbsolutePath()); props.setProperty(Options.BUFFER_MODE, BufferMode.Transient.toString()); // quads mode: quads=true, sids=false, axioms=NoAxioms, vocab=NoVocabulary props.setProperty(Options.QUADS_MODE, "true"); // no justifications props.setProperty(Options.JUSTIFY, "false"); // no query time inference props.setProperty(Options.QUERY_TIME_EXPANDER, "false"); // // auto-commit only there for TCK // props.setProperty(Options.ALLOW_AUTO_COMMIT, "true"); // exact size only there for TCK props.setProperty(Options.EXACT_SIZE, "true"); // props.setProperty(Options.COLLATOR, CollatorEnum.ASCII.toString()); // Force identical unicode comparisons (assuming default COLLATOR setting). // props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString()); /* * disable read/write transactions since this class runs against the * unisolated connection. */ props.setProperty(Options.ISOLATABLE_INDICES, "false"); // disable truth maintenance in the SAIL props.setProperty(Options.TRUTH_MAINTENANCE, "false"); return props; } @Override protected Repository newRepository() throws RepositoryException { if (true) { final Properties props = getProperties(); if (cannotInlineTests.contains(testURI)){ // The test can not be run using XSD inlining. props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false"); props.setProperty(Options.INLINE_DATE_TIMES, "false"); } if(unicodeStrengthIdentical.contains(testURI)) { // Force identical Unicode comparisons. props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString()); props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString()); } final BigdataSail sail = new BigdataSail(props); // return new DatasetRepository(new BigdataSailRepository(sail)); return new BigdataSailRepository(sail); } else { return new DatasetRepository(new SailRepository(new MemoryStore())); } } protected void tearDownBackend(IIndexManager backend) { backend.destroy(); } @Override protected Repository createRepository() throws Exception { Repository repo = newRepository(); repo.initialize(); return repo; } @Override public void setUp() throws Exception { super.setUp(); } public Repository getRepository() { return dataRep; } private String queryString = null; public String getQueryString() throws Exception { if (queryString == null) { InputStream stream = new URL(queryFileURL).openStream(); try { return IOUtil.readString(new InputStreamReader(stream, "UTF-8")); } finally { stream.close(); } } return queryString; } protected String readInputData(Dataset dataset) throws Exception { final StringBuilder sb = new StringBuilder(); if (dataset != null) { Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { URL graphURL = new URL(graphURI.toString()); InputStream in = graphURL.openStream(); sb.append(IOUtil.readString(in)); } } return sb.toString(); } @Override protected void runTest() throws Exception { BigdataSailRepositoryConnection con = getQueryConnection(dataRep); // Some SPARQL Tests have non-XSD datatypes that must pass for the test // suite to complete successfully con.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, Boolean.FALSE); con.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, Boolean.FALSE); try { String queryString = readQueryString(); Query query = con.prepareQuery(QueryLanguage.SPARQL, queryString, queryFileURL); if (dataset != null) { query.setDataset(dataset); } String name = this.getName(); if (name.contains("pp34")) { System.out.println(name); } if (query instanceof TupleQuery) { TupleQueryResult queryResult = ((TupleQuery)query).evaluate(); TupleQueryResult expectedResult = readExpectedTupleQueryResult(); compareTupleQueryResults(queryResult, expectedResult, con); // Graph queryGraph = RepositoryUtil.asGraph(queryResult); // Graph expectedGraph = readExpectedTupleQueryResult(); // compareGraphs(queryGraph, expectedGraph); } else if (query instanceof GraphQuery) { GraphQueryResult gqr = ((GraphQuery)query).evaluate(); Set<Statement> queryResult = Iterations.asSet(gqr); Set<Statement> expectedResult = readExpectedGraphQueryResult(); compareGraphs(queryResult, expectedResult); } else if (query instanceof BooleanQuery) { boolean queryResult = ((BooleanQuery)query).evaluate(); boolean expectedResult = readExpectedBooleanQueryResult(); assertEquals(expectedResult, queryResult); } else { throw new RuntimeException("Unexpected query type: " + query.getClass()); } } finally { con.close(); } } /** * Overridden to use {@link BigdataSail#getReadOnlyConnection()} as a * workaround to the test harness which invokes * {@link BigdataSail#getConnection()} multiple times from within the same * thread. When full transactions are not enabled, that will delegate to * {@link BigdataSail#getUnisolatedConnection()}. Only one unisolated * connection is permitted at a time. While different threads will block to * await the unisolated connection, that method will throw an exception if * there is an attempt by a single thread to obtain more than one instance * of the unisolated connection (since that operation would otherwise * deadlock). */ protected BigdataSailRepositoryConnection getQueryConnection( Repository dataRep) throws Exception { // // See #1196 (Enable BigdataEmbeddedFederationSparqlTest tests in CI) // return ((BigdataSailRepository) ((DatasetRepository) dataRep) // .getDelegate()).getReadOnlyConnection(); return ((BigdataSailRepository) dataRep) .getReadOnlyConnection(); } @Override protected void uploadDataset(Dataset dataset) throws Exception { // RepositoryConnection con = dataRep.getConnection(); // try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } // } // finally { // con.close(); // } } protected final void compareTupleQueryResults(TupleQueryResult queryResult, TupleQueryResult expectedResult, final BigdataSailRepositoryConnection cxn) throws Exception { // Create MutableTupleQueryResult to be able to re-iterate over the // results MutableTupleQueryResult queryResultTable = new MutableTupleQueryResult(queryResult); MutableTupleQueryResult expectedResultTable = new MutableTupleQueryResult(expectedResult); boolean resultsEqual; if (laxCardinality) { resultsEqual = QueryResults.isSubset(queryResultTable, expectedResultTable); } else { resultsEqual = QueryResults.equals(queryResultTable, expectedResultTable); if (checkOrder) { // also check the order in which solutions occur. queryResultTable.beforeFirst(); expectedResultTable.beforeFirst(); while (queryResultTable.hasNext()) { BindingSet bs = queryResultTable.next(); BindingSet expectedBs = expectedResultTable.next(); if (!bs.equals(expectedBs)) { resultsEqual = false; break; } } } } if (!resultsEqual) { queryResultTable.beforeFirst(); expectedResultTable.beforeFirst(); /* * StringBuilder message = new StringBuilder(128); * message.append("\n============ "); message.append(getName()); * message.append(" =======================\n"); * message.append("Expected result: \n"); while * (expectedResultTable.hasNext()) { * message.append(expectedResultTable.next()); message.append("\n"); } * message.append("============="); StringUtil.appendN('=', * getName().length(), message); * message.append("========================\n"); message.append("Query * result: \n"); while (queryResultTable.hasNext()) { * message.append(queryResultTable.next()); message.append("\n"); } * message.append("============="); StringUtil.appendN('=', * getName().length(), message); * message.append("========================\n"); */ List<BindingSet> queryBindings = Iterations.asList(queryResultTable); List<BindingSet> expectedBindings = Iterations.asList(expectedResultTable); List<BindingSet> missingBindings = new ArrayList<BindingSet>(expectedBindings); missingBindings.removeAll(queryBindings); List<BindingSet> unexpectedBindings = new ArrayList<BindingSet>(queryBindings); unexpectedBindings.removeAll(expectedBindings); StringBuilder message = new StringBuilder(128); message.append("\n=========================================\n"); message.append(getName()); message.append("\n"); message.append(testURI); message.append("\n=========================================\n"); message.append("Expected results: \n"); for (BindingSet bs : expectedBindings) { printBindingSet(message, bs); message.append("\n"); } message.append("=========================================\n"); message.append("Bigdata results: \n"); for (BindingSet bs : queryBindings) { printBindingSet(message, bs); message.append("\n"); } message.append("=========================================\n"); if (!missingBindings.isEmpty()) { message.append("Missing results: \n"); for (BindingSet bs : missingBindings) { printBindingSet(message, bs); message.append("\n"); } message.append("=========================================\n"); } if (!unexpectedBindings.isEmpty()) { message.append("Extra results: \n"); for (BindingSet bs : unexpectedBindings) { printBindingSet(message, bs); message.append("\n"); } message.append("=========================================\n"); } if (checkOrder && missingBindings.isEmpty() && unexpectedBindings.isEmpty()) { message.append("Results are not in expected order.\n"); message.append(" =======================\n"); message.append("query result: \n"); for (BindingSet bs : queryBindings) { printBindingSet(message, bs); message.append("\n"); } message.append(" =======================\n"); message.append("expected result: \n"); for (BindingSet bs : expectedBindings) { printBindingSet(message, bs); message.append("\n"); } message.append(" =======================\n"); System.out.print(message.toString()); } else if (missingBindings.isEmpty() && unexpectedBindings.isEmpty()) { message.append("unexpected duplicate in result.\n"); message.append(" =======================\n"); message.append("query result: \n"); for (BindingSet bs : queryBindings) { printBindingSet(message, bs); message.append("\n"); } message.append(" =======================\n"); message.append("expected result: \n"); for (BindingSet bs : expectedBindings) { printBindingSet(message, bs); message.append("\n"); } message.append(" =======================\n"); System.out.print(message.toString()); } final String queryStr = readQueryString(); message.append("Query:\n"+queryStr); message.append("\n=========================================\n"); message.append("Data:\n"+readInputData(dataset)); message.append("\n=========================================\n"); // final BigdataSailRepositoryConnection cxn = getQueryConnection(dataRep); final BigdataSailTupleQuery query = (BigdataSailTupleQuery) cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); final QueryRoot original = query.getASTContainer().getOriginalAST(); message.append("Original AST:\n"+original); message.append("\n=========================================\n"); final QueryRoot optimized = query.optimize(); message.append("Optimized AST:\n"+optimized); message.append("\n=========================================\n"); logger.error(message.toString()); fail(message.toString()); } /* debugging only: print out result when test succeeds else { queryResultTable.beforeFirst(); List<BindingSet> queryBindings = Iterations.asList(queryResultTable); StringBuilder message = new StringBuilder(128); message.append("\n============ "); message.append(getName()); message.append(" =======================\n"); message.append(" =======================\n"); message.append("query result: \n"); for (BindingSet bs: queryBindings) { message.append(bs); message.append("\n"); } System.out.print(message.toString()); } */ } private void printBindingSet(StringBuilder message, BindingSet bs) { // message.append(bs); for (String bn: bs.getBindingNames()) { Value v = bs.getBinding(bn).getValue(); message.append(bn).append('=').append(v); if (v instanceof BigdataValue) { message.append(' ').append(((BigdataValue)v).getIV()).append(' '); } } } @Override protected final void compareGraphs(Set<Statement> queryResult, Set<Statement> expectedResult) throws Exception { if (!ModelUtil.equals(expectedResult, queryResult)) { // Don't use RepositoryUtil.difference, it reports incorrect diffs /* * Collection<? extends Statement> unexpectedStatements = * RepositoryUtil.difference(queryResult, expectedResult); Collection<? * extends Statement> missingStatements = * RepositoryUtil.difference(expectedResult, queryResult); * StringBuilder message = new StringBuilder(128); * message.append("\n=======Diff: "); message.append(getName()); * message.append("========================\n"); if * (!unexpectedStatements.isEmpty()) { message.append("Unexpected * statements in result: \n"); for (Statement st : * unexpectedStatements) { message.append(st.toString()); * message.append("\n"); } message.append("============="); for (int i = * 0; i < getName().length(); i++) { message.append("="); } * message.append("========================\n"); } if * (!missingStatements.isEmpty()) { message.append("Statements missing * in result: \n"); for (Statement st : missingStatements) { * message.append(st.toString()); message.append("\n"); } * message.append("============="); for (int i = 0; i < * getName().length(); i++) { message.append("="); } * message.append("========================\n"); } */ StringBuilder message = new StringBuilder(128); message.append("\n=========================================\n"); message.append(getName()); message.append("\n"); message.append(testURI); message.append("\n=========================================\n"); message.append("Expected results: \n"); for (Statement bs : expectedResult) { message.append(bs); message.append("\n"); } message.append("=========================================\n"); message.append("Bigdata results: \n"); for (Statement bs : queryResult) { message.append(bs); message.append("\n"); } message.append("=========================================\n"); final String queryStr = readQueryString(); message.append("Query:\n"+queryStr); message.append("\n=========================================\n"); message.append("Data:\n"+readInputData(dataset)); message.append("\n=========================================\n"); logger.error(message.toString()); fail(message.toString()); } } }