From: <mrp...@us...> - 2010-07-29 18:35:53
|
Revision: 3353 http://bigdata.svn.sourceforge.net/bigdata/?rev=3353&view=rev Author: mrpersonick Date: 2010-07-29 18:35:47 +0000 (Thu, 29 Jul 2010) Log Message: ----------- committing some new test cases Modified Paths: -------------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestDescribe.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestUnions.java Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestDescribe.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestDescribe.java 2010-07-29 18:28:47 UTC (rev 3352) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestDescribe.java 2010-07-29 18:35:47 UTC (rev 3353) @@ -116,10 +116,22 @@ { String query = - "describe ?x " + - "WHERE { " + - " ?x <"+RDF.TYPE+"> <"+person+"> . " + - "}"; +// "describe ?x " + +// "WHERE { " + +// " ?x <"+RDF.TYPE+"> <"+person+"> . " + +// "}"; + "describe <"+mike+">"; +// "construct { " + +// " <"+mike+"> ?p1 ?o . " + +// " ?s ?p2 <"+mike+"> . " + +// "} " + +// "where { " + +// " { <"+mike+"> ?p1 ?o . } " + +// " UNION " + +// " { ?s ?p2 <"+mike+"> . } " + +// "}"; + + /* construct { Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestUnions.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestUnions.java 2010-07-29 18:28:47 UTC (rev 3352) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestUnions.java 2010-07-29 18:35:47 UTC (rev 3353) @@ -26,22 +26,23 @@ package com.bigdata.rdf.sail; +import info.aduna.xml.XMLWriter; +import java.io.StringWriter; import java.util.Collection; import java.util.LinkedList; +import org.apache.log4j.Logger; import org.openrdf.model.BNode; -import org.openrdf.model.Literal; -import org.openrdf.model.Resource; import org.openrdf.model.URI; import org.openrdf.model.impl.BNodeImpl; import org.openrdf.model.impl.LiteralImpl; import org.openrdf.model.impl.URIImpl; import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.RDFS; import org.openrdf.query.BindingSet; import org.openrdf.query.QueryLanguage; import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; import org.openrdf.query.impl.BindingImpl; +import org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter; /** * Unit tests the UNION aspects of the {@link BigdataSail} implementation. @@ -51,6 +52,8 @@ */ public class TestUnions extends QuadsTestCase { + protected static final Logger log = Logger.getLogger(TestUnions.class); + /** * */ @@ -198,4 +201,96 @@ } + /** + * Tests mapping of UNIONS in SPARQL onto unions in bigdata rules. + * + * @throws Exception + */ + public void testSesameFilters() throws Exception { + + final BigdataSail sail = getSail(); + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = + (BigdataSailRepositoryConnection) repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final URI jack = new URIImpl("_:Jack"); + final URI jill = new URIImpl("_:Jill"); + final URI person = new URIImpl("_:Person"); + final URI age = new URIImpl("_:age"); + final URI integer = new URIImpl("http://www.w3.org/2001/XMLSchema#integer"); +/**/ + cxn.add( + jack, + RDF.TYPE, + person + ); + cxn.add( + jill, + RDF.TYPE, + person + ); + cxn.add( + jack, + age, + new LiteralImpl("40", integer) + ); + cxn.add( + jill, + age, + new LiteralImpl("30", integer) + ); +/**/ + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.flush();//commit(); + +/**/ + log.info("hello"); + if (log.isInfoEnabled()) { + log.info("\n" + sail.getDatabase().dumpStore()); + } + + { + + String query = + "SELECT * " + + "WHERE { " + + " { " + + " ?x <"+RDF.TYPE+"> <"+person+"> . " + + " ?x <"+age+"> ?age1 . " + + " FILTER( ?age1 > 35 ) . " + + " } " + + " UNION " + + " { " + + " ?x <"+RDF.TYPE+"> <"+person+"> . " + + " ?x <"+age+"> ?age2 . " + + " FILTER( ?age2 > 25 ) . " + + " } " + + "}"; + + final StringWriter sw = new StringWriter(); + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + tupleQuery.setIncludeInferred(true /* includeInferred */); + tupleQuery.evaluate(new SPARQLResultsXMLWriter(new XMLWriter(sw))); + + System.err.println(sw.toString()); + } + + } finally { + cxn.close(); + sail.__tearDownUnitTest(); + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-29 18:36:18
|
Revision: 3354 http://bigdata.svn.sourceforge.net/bigdata/?rev=3354&view=rev Author: mrpersonick Date: 2010-07-29 18:36:12 +0000 (Thu, 29 Jul 2010) Log Message: ----------- committing some new test cases Added Paths: ----------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/sids.rdf Added: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java (rev 0) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java 2010-07-29 18:36:12 UTC (rev 3354) @@ -0,0 +1,156 @@ +/** +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +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 Sep 16, 2009 + */ + +package com.bigdata.rdf.sail; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.Properties; +import org.apache.log4j.Logger; +import org.openrdf.model.URI; +import org.openrdf.model.impl.URIImpl; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.query.Binding; +import org.openrdf.query.BindingSet; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQuery; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.impl.BindingImpl; +import org.openrdf.rio.RDFFormat; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * @author <a href="mailto:mrp...@us...">Mike Personick</a> + * @version $Id$ + */ +public class TestSids extends ProxyBigdataSailTestCase { + + protected static final Logger log = Logger.getLogger(TestSids.class); + + @Override + public Properties getProperties() { + + Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); + props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); + + return props; + + } + + /** + * + */ + public TestSids() { + } + + /** + * @param arg0 + */ + public TestSids(String arg0) { + super(arg0); + } + + public void testSids() throws Exception { + + final BigdataSail sail = getSail(); + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = + (BigdataSailRepositoryConnection) repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + cxn.add(getClass().getResourceAsStream("sids.rdf"), "", RDFFormat.RDFXML); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.flush();//commit(); + +/**/ + if (log.isInfoEnabled()) { + log.info("\n" + sail.getDatabase().dumpStore()); + } + + { + + String query = + "PREFIX myns: <http://mynamespace.com#> " + + "SELECT distinct ?s ?p ?o " + + " { " + + " ?sid myns:creator <http://1.com> . " + + " graph ?sid { ?s ?p ?o } " + + " }"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + + while (result.hasNext()) { + BindingSet bs = result.next(); + System.err.println(bs.getBinding("s") + ", " + bs.getBinding("p") + ", " + bs.getBinding("o")); + } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", new URIImpl("http://localhost/host1")), + new BindingImpl("p", new URIImpl("http://mynamespace.com#connectedTo")), + new BindingImpl("o", new URIImpl("http://localhost/switch1")), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", new URIImpl("http://localhost/host1")), + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", new URIImpl("http://domainnamespace.com/host#Host")), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", new URIImpl("http://localhost/switch2")), + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", new URIImpl("http://domainnamespace.com/san#Switch")), + })); + +// compare(result, solution); + + } + + } finally { + cxn.close(); + sail.__tearDownUnitTest(); + } + + } + + + +} Added: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/sids.rdf =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/sids.rdf (rev 0) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/sids.rdf 2010-07-29 18:36:12 UTC (rev 3354) @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<rdf:RDF + + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + + xmlns:bigdata="http://www.bigdata.com/rdf#"> + + + +<rdf:Description rdf:about="http://localhost/host1"> + + <rdf:type bigdata:sid="S195" bigdata:statementType="Explicit" rdf:resource="http://domainnamespace.com/host#Host"/> + + <connectedTo xmlns="http://mynamespace.com#" bigdata:sid="S199" bigdata:statementType="Explicit" rdf:resource="http://localhost/switch1"/> + + <connectedTo xmlns="http://mynamespace.com#" bigdata:sid="S227" bigdata:statementType="Explicit" rdf:resource="http://localhost/switch2"/> + +</rdf:Description> + + + +<rdf:Description rdf:about="http://localhost/switch1"> + + <rdf:type bigdata:sid="S203" bigdata:statementType="Explicit" rdf:resource="http://domainnamespace.com/san#Switch"/> + +</rdf:Description> + + + +<rdf:Description rdf:nodeID="S195"> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S211" bigdata:statementType="Explicit" rdf:resource="http://1.com"/> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S239" bigdata:statementType="Explicit" rdf:resource="http://2.com"/> + +</rdf:Description> + + + +<rdf:Description rdf:nodeID="S199"> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S215" bigdata:statementType="Explicit" rdf:resource="http://1.com"/> + +</rdf:Description> + + + +<rdf:Description rdf:nodeID="S203"> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S219" bigdata:statementType="Explicit" rdf:resource="http://1.com"/> + +</rdf:Description> + + + +<rdf:Description rdf:about="http://localhost/switch2"> + + <rdf:type bigdata:sid="S231" bigdata:statementType="Explicit" rdf:resource="http://domainnamespace.com/san#Switch"/> + +</rdf:Description> + + + +<rdf:Description rdf:nodeID="S227"> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S243" bigdata:statementType="Explicit" rdf:resource="http://2.com"/> + +</rdf:Description> + + + +<rdf:Description rdf:nodeID="S231"> + + <creator xmlns="http://mynamespace.com#" bigdata:sid="S247" bigdata:statementType="Explicit" rdf:resource="http://2.com"/> + +</rdf:Description> + + + +</rdf:RDF> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-29 18:48:24
|
Revision: 3355 http://bigdata.svn.sourceforge.net/bigdata/?rev=3355&view=rev Author: mrpersonick Date: 2010-07-29 18:48:18 +0000 (Thu, 29 Jul 2010) Log Message: ----------- test case for optionals Modified Paths: -------------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestOptionals.java Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -92,6 +92,10 @@ // unit tests for custom evaluation of high-level query suite.addTestSuite(TestBigdataSailEvaluationStrategyImpl.class); + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -67,7 +67,7 @@ * Use a proxy test suite and specify the delegate. */ - final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Quads (pipline joins)"); + final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Quads (pipeline joins)"); // test pruning of variables not required for downstream processing. suite.addTestSuite(TestPruneBindingSets.class); @@ -93,6 +93,10 @@ // unit tests for custom evaluation of high-level query suite.addTestSuite(TestBigdataSailEvaluationStrategyImpl.class); + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -67,7 +67,7 @@ * Use a proxy test suite and specify the delegate. */ - final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Quads (pipline joins, no inlining)"); + final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Quads (pipeline joins, no inlining)"); // test pruning of variables not required for downstream processing. suite.addTestSuite(TestPruneBindingSets.class); @@ -93,6 +93,10 @@ // unit tests for custom evaluation of high-level query suite.addTestSuite(TestBigdataSailEvaluationStrategyImpl.class); + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -59,7 +59,7 @@ * Use a proxy test suite and specify the delegate. */ - final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with SIDS"); + final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Triples (with SIDs)"); // test pruning of variables not required for downstream processing. suite.addTestSuite(TestPruneBindingSets.class); @@ -79,6 +79,12 @@ suite.addTestSuite(TestOrderBy.class); + suite.addTestSuite(TestSids.class); + + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + return suite; } Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -59,7 +59,7 @@ * Use a proxy test suite and specify the delegate. */ - final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with SIDS (no inlining)"); + final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Triples (with SIDs, no inlining)"); // test pruning of variables not required for downstream processing. suite.addTestSuite(TestPruneBindingSets.class); @@ -79,6 +79,12 @@ suite.addTestSuite(TestOrderBy.class); + suite.addTestSuite(TestSids.class); + + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + return suite; } Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -59,7 +59,7 @@ * Use a proxy test suite and specify the delegate. */ - final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL without SIDS"); + final ProxyTestSuite suite = new ProxyTestSuite(delegate, "SAIL with Triples (no SIDs)"); // test pruning of variables not required for downstream processing. suite.addTestSuite(TestPruneBindingSets.class); @@ -75,6 +75,10 @@ suite.addTestSuite(TestBigdataSailEvaluationStrategyImpl.class); + suite.addTestSuite(TestUnions.class); + + suite.addTestSuite(TestDescribe.class); + return suite; } Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestOptionals.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestOptionals.java 2010-07-29 18:36:12 UTC (rev 3354) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestOptionals.java 2010-07-29 18:48:18 UTC (rev 3355) @@ -28,10 +28,12 @@ import java.util.Collection; import java.util.LinkedList; +import java.util.Properties; import org.openrdf.model.BNode; import org.openrdf.model.Literal; import org.openrdf.model.Resource; import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; import org.openrdf.model.impl.BNodeImpl; import org.openrdf.model.impl.LiteralImpl; import org.openrdf.model.impl.URIImpl; @@ -126,10 +128,6 @@ try { - assertEquals(0, sail.database.getNamedGraphCount()); - - assertFalse(cxn.getContextIDs().hasNext()); - final URI book1 = new URIImpl("http://www.bigdata.com/rdf#book1"); final URI book2 = new URIImpl("http://www.bigdata.com/rdf#book2"); final URI book3 = new URIImpl("http://www.bigdata.com/rdf#book3"); @@ -205,4 +203,49 @@ } + public void testOptional() throws Exception { + + Properties properties = getProperties(); + properties.put("com.bigdata.rdf.sail.isolatableIndices", "true"); + properties.put("com.bigdata.rdf.store.AbstractTripleStore.axiomsClass", "com.bigdata.rdf.axioms.NoAxioms"); + properties.put("com.bigdata.rdf.sail.truthMaintenance", "false"); + properties.put("com.bigdata.rdf.store.AbstractTripleStore.vocabularyClass", "com.bigdata.rdf.vocab.NoVocabulary"); + properties.put("com.bigdata.rdf.store.AbstractTripleStore.justify", "false"); + + final BigdataSail sail = getSail(properties); + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = + (BigdataSailRepositoryConnection) repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + + cxn.add(vf.createURI("u:1"), + vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), + vf.createURI("u:2")); + + String query = + "SELECT REDUCED ?subj ?subj_class ?subj_label " + + "WHERE { " + + " ?subj a ?subj_class . " + + " OPTIONAL { ?subj <http://www.w3.org/2000/01/rdf-schema#label> ?subj_label } " + + "}"; + + TupleQuery q = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + q.setBinding("subj", vf.createURI("u:1")); + TupleQueryResult tqr = q.evaluate(); + assertTrue(tqr.hasNext()); + System.err.println(tqr.next()); + tqr.close(); + + } finally { + cxn.close(); + sail.__tearDownUnitTest(); + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-29 19:55:37
|
Revision: 3360 http://bigdata.svn.sourceforge.net/bigdata/?rev=3360&view=rev Author: mrpersonick Date: 2010-07-29 19:55:30 +0000 (Thu, 29 Jul 2010) Log Message: ----------- removing TestSids Modified Paths: -------------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2010-07-29 19:29:18 UTC (rev 3359) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2010-07-29 19:55:30 UTC (rev 3360) @@ -79,8 +79,6 @@ suite.addTestSuite(TestOrderBy.class); - suite.addTestSuite(TestSids.class); - suite.addTestSuite(TestUnions.class); suite.addTestSuite(TestDescribe.class); Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-29 19:29:18 UTC (rev 3359) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-29 19:55:30 UTC (rev 3360) @@ -79,8 +79,6 @@ suite.addTestSuite(TestOrderBy.class); - suite.addTestSuite(TestSids.class); - suite.addTestSuite(TestUnions.class); suite.addTestSuite(TestDescribe.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-08-06 20:24:32
|
Revision: 3430 http://bigdata.svn.sourceforge.net/bigdata/?rev=3430&view=rev Author: mrpersonick Date: 2010-08-06 20:24:26 +0000 (Fri, 06 Aug 2010) Log Message: ----------- filtering out the dataset tests Modified Paths: -------------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java 2010-08-06 20:14:52 UTC (rev 3429) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoins.java 2010-08-06 20:24:26 UTC (rev 3430) @@ -108,7 +108,12 @@ try { - tckSuite.addTest(BigdataSparqlTest.suiteLTSWithPipelineJoins()); + /* + * suite() will call suiteLTSWithPipelineJoins() and then + * filter out the dataset tests, which we don't need right now + */ +// tckSuite.addTest(BigdataSparqlTest.suiteLTSWithPipelineJoins()); + tckSuite.addTest(BigdataSparqlTest.suite()); } catch (Exception ex) { Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-08-06 20:14:52 UTC (rev 3429) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-08-06 20:24:26 UTC (rev 3430) @@ -108,7 +108,12 @@ try { - tckSuite.addTest(BigdataSparqlTest.suiteLTSWithPipelineJoins()); + /* + * suite() will call suiteLTSWithPipelineJoins() and then + * filter out the dataset tests, which we don't need right now + */ +// tckSuite.addTest(BigdataSparqlTest.suiteLTSWithPipelineJoins()); + tckSuite.addTest(BigdataSparqlTest.suite()); } catch (Exception ex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2011-02-21 18:33:28
|
Revision: 4217 http://bigdata.svn.sourceforge.net/bigdata/?rev=4217&view=rev Author: mrpersonick Date: 2011-02-21 18:33:22 +0000 (Mon, 21 Feb 2011) Log Message: ----------- fixed some problems with the change sets test case and added it to the SIDs test suite Modified Paths: -------------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestChangeSets.java Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-02-21 17:48:49 UTC (rev 4216) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-02-21 18:33:22 UTC (rev 4217) @@ -83,6 +83,8 @@ suite.addTestSuite(TestDescribe.class); + suite.addTestSuite(TestChangeSets.class); + return suite; } Modified: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestChangeSets.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestChangeSets.java 2011-02-21 17:48:49 UTC (rev 4216) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/TestChangeSets.java 2011-02-21 18:33:22 UTC (rev 4217) @@ -52,6 +52,8 @@ import com.bigdata.striterator.ChunkedArrayIterator; /** + * Test change sets. This is meant to be run in triples with SIDs mode. + * * @author <a href="mailto:mrp...@us...">Mike Personick</a> * @version $Id$ */ @@ -59,14 +61,10 @@ protected static final Logger log = Logger.getLogger(TestChangeSets.class); - public Properties getTriplesNoInference() { + public Properties getNoInferenceProps() { Properties props = super.getProperties(); - // triples with sids - props.setProperty(BigdataSail.Options.QUADS, "false"); - props.setProperty(BigdataSail.Options.STATEMENT_IDENTIFIERS, "false"); - // no inference props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); @@ -78,25 +76,6 @@ } - public Properties getTriplesWithInference() { - - Properties props = super.getProperties(); - - // triples with sids - props.setProperty(BigdataSail.Options.QUADS, "false"); - props.setProperty(BigdataSail.Options.STATEMENT_IDENTIFIERS, "false"); - - // no inference - props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "true"); - props.setProperty(BigdataSail.Options.AXIOMS_CLASS, OwlAxioms.class.getName()); - props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, RDFSVocabulary.class.getName()); - props.setProperty(BigdataSail.Options.JUSTIFY, "true"); - props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); - - return props; - - } - /** * */ @@ -112,7 +91,9 @@ public void testSimpleAdd() throws Exception { - final BigdataSail sail = getSail(getTriplesNoInference()); + final BigdataSail sail = getSail(getNoInferenceProps()); + try { + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = @@ -204,6 +185,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } @@ -211,8 +195,10 @@ public void testSimpleRemove() throws Exception { - final BigdataSail sail = getSail(getTriplesNoInference()); - sail.initialize(); + final BigdataSail sail = getSail(getNoInferenceProps()); + try { + + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); @@ -288,6 +274,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } @@ -295,15 +284,10 @@ public void testSids() throws Exception { - Properties props = getTriplesNoInference(); + final BigdataSail sail = getSail(getNoInferenceProps()); + try { - if (!Boolean.valueOf(props.getProperty(BigdataSail.Options.STATEMENT_IDENTIFIERS)).booleanValue()) { - log.warn("cannot run this test without sids enabled"); - return; - } - - final BigdataSail sail = getSail(getTriplesNoInference()); - sail.initialize(); + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); @@ -402,6 +386,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } @@ -409,7 +396,9 @@ public void testTMAdd() throws Exception { - final BigdataSail sail = getSail(getTriplesWithInference()); + final BigdataSail sail = getSail(); + try { + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = @@ -499,6 +488,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } @@ -506,7 +498,9 @@ public void testTMRetract() throws Exception { - final BigdataSail sail = getSail(getTriplesWithInference()); + final BigdataSail sail = getSail(); + try { + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = @@ -606,6 +600,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } @@ -613,7 +610,9 @@ public void testTMUpdate() throws Exception { - final BigdataSail sail = getSail(getTriplesWithInference()); + final BigdataSail sail = getSail(); + try { + sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = @@ -717,6 +716,9 @@ } finally { cxn.close(); + } + + } finally { sail.__tearDownUnitTest(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2011-04-26 18:19:10
|
Revision: 4428 http://bigdata.svn.sourceforge.net/bigdata/?rev=4428&view=rev Author: thompsonbry Date: 2011-04-26 18:19:03 +0000 (Tue, 26 Apr 2011) Log Message: ----------- Added unit test for [1] contributed by gerjon. [1] https://sourceforge.net/apps/trac/bigdata/ticket/278 Added Paths: ----------- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java Added: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java =================================================================== --- trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java (rev 0) +++ trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java 2011-04-26 18:19:03 UTC (rev 4428) @@ -0,0 +1,296 @@ +/** +Copyright (C) SYSTAP, LLC 2011. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +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 + */ + +package com.bigdata.rdf.sail.contrib; + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicReference; + +import org.openrdf.OpenRDFException; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.query.MalformedQueryException; +import org.openrdf.query.QueryEvaluationException; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQuery; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.repository.RepositoryConnection; +import org.openrdf.repository.RepositoryException; +import org.openrdf.repository.sail.SailRepository; + +import com.bigdata.journal.IIndexManager; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.sail.BigdataSail; +import com.bigdata.rdf.sail.QuadsTestCase; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * Unit test template for use in submission of bugs. + * <p> + * This test case will delegate to an underlying backing store. You can specify + * this store via a JVM property as follows: + * <code>-DtestClass=com.bigdata.rdf.sail.TestBigdataSailWithQuads</code> + * <p> + * There are three possible configurations for the testClass: + * <ul> + * <li>com.bigdata.rdf.sail.TestBigdataSailWithQuads (quads mode)</li> + * <li>com.bigdata.rdf.sail.TestBigdataSailWithoutSids (triples mode)</li> + * <li>com.bigdata.rdf.sail.TestBigdataSailWithSids (SIDs mode)</li> + * </ul> + * <p> + * The default for triples and SIDs mode is for inference with truth maintenance + * to be on. If you would like to turn off inference, make sure to do so in + * {@link #getProperties()}. + * + * @author <a href="mailto:mrp...@us...">Mike Personick</a> + * @version $Id$ + */ +public class TestRollbacks extends QuadsTestCase { + public TestRollbacks() { + } + + public TestRollbacks(String arg0) { + super(arg0); + } + + /** + * Please set your database properties here, except for your journal file, + * please DO NOT SPECIFY A JOURNAL FILE. + */ + @Override + public Properties getProperties() { + Properties props = super.getProperties(); + + /* + * For example, here is a set of five properties that turns off + * inference, truth maintenance, and the free text index. + */ + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, + NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, + NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); + props.setProperty(BigdataSail.Options.ISOLATABLE_INDICES, "true"); +// props.setProperty(BigdataSail.Options.EXACT_SIZE, "true"); + + return props; + } + + + /** The thrown exception which is the first cause of failure. */ + private AtomicReference<Throwable> firstCause; + + /** + * Service used to run the individual tasks. This makes it possible to + * interrupt them as soon as one of the tasks fails. + */ + private ExecutorService executorService = null; + + @Override + protected void setUp() throws Exception { + super.setUp(); + firstCause = new AtomicReference<Throwable>(null); + executorService = Executors.newFixedThreadPool(3/*nthreads*/); + } + + @Override + protected void tearDown() throws Exception { + if (executorService != null) { + // interrupt any running tasks. + executorService.shutdownNow(); + } + // clear references so that junit does not hold onto them. + executorService = null; + firstCause = null; + super.tearDown(); + } + + public void testBug() throws Exception { + BigdataSail sail = getSail(); + try { + SailRepository repo = new SailRepository(sail); + repo.initialize(); + runConcurrentStuff(repo); + } finally { + final IIndexManager db = sail.getDatabase().getIndexManager(); + if (sail.isOpen()) + sail.shutDown(); + db.destroy(); + } + } + + private void runConcurrentStuff(final SailRepository repo) + throws Exception, + InterruptedException { + try { + final List<Callable<Void>> tasks = new LinkedList<Callable<Void>>(); + tasks.add(new DoStuff(repo, true)); + tasks.add(new DoStuff(repo, false)); + tasks.add(new DoStuff(repo, false)); + final List<Future<Void>> futures = executorService.invokeAll(tasks); + // Look for the first cause. + final Throwable t = firstCause.get(); + if (t != null) { + // Found it. + throw new RuntimeException(t); + } + // test each future. + for (Future<Void> f : futures) { + f.get(); + } + } finally { + repo.shutDown(); + } + } + + private class DoStuff implements Callable<Void> { + private SailRepository repo; + private boolean writer; + int counter = 0; + + private DoStuff(SailRepository repo, boolean writer) + throws OpenRDFException { + this.repo = repo; + this.writer = writer; + } + + public Void call() throws Exception { +// if (writer) { +// // Initial sleep on the writer. +// Thread.sleep(500); +// } + RepositoryConnection conn = null; + try { + while (firstCause.get() == null) { + /* + * Note: If connection obtained/closed within the loop then + * the query is more likely to have some data to visit + * within its tx view. + */ + conn = repo.getConnection(); + conn.setAutoCommit(false); + if (writer) + writer(conn); + else + reader(conn); + conn.close(); + } + return (Void) null; + } catch (Throwable t) { + firstCause.compareAndSet(null/* expect */, t); + throw new RuntimeException(t); + } finally { + if (conn != null && conn.isOpen()) + conn.close(); + } + } + + private void reader(final RepositoryConnection conn) + throws RepositoryException, MalformedQueryException, + QueryEvaluationException, InterruptedException { + query(conn); +// Thread.sleep(100); + query(conn); + ++counter; + + if (counter % 3 == 0) + conn.commit(); + else + conn.rollback(); + + // if (counter % 7 == 0) { + // conn.close(); + // conn = repo.getConnection(); + // conn.setAutoCommit(false); + // } + } + + private void writer(final RepositoryConnection conn) throws RepositoryException, + MalformedQueryException, QueryEvaluationException, + InterruptedException { + + final URI subj = conn.getValueFactory().createURI( + "u:s" + (counter++)); + final Value value = conn.getValueFactory().createLiteral( + "literal" + counter); + query(conn); +// Thread.sleep(200); + conn.add(subj, conn.getValueFactory().createURI("u:p"), subj); + conn.add(subj, conn.getValueFactory().createURI("u:p"), value); + conn.commit(); + + if(log.isInfoEnabled()) + log.info("Added statements: size="+conn.size()); + + // if (counter % 12 == 0) { + // conn.close(); + // conn = repo.getConnection(); + // conn.setAutoCommit(false); + // } + } + + private void query(final RepositoryConnection conn) throws RepositoryException, + MalformedQueryException, QueryEvaluationException { + final long begin = System.currentTimeMillis(); + /* + * Note: This query will do an access path scan rather than a join. + * There are different code paths involved with a join, so there + * might be problems on those code paths as well. + */ + final boolean useJoin = counter % 2 == 0; + final String query = !useJoin// + // access path scan + ? "SELECT ?b { ?a ?b ?c } LIMIT 20"// + // join + : "SELECT ?b { ?a ?b ?c . ?d ?b ?e} LIMIT 20"// + ; + final TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); + q.setBinding("b", conn.getValueFactory().createURI("u:p")); + if (useJoin) + q.setBinding("d", conn.getValueFactory().createLiteral( + "literal1")); + final TupleQueryResult tqr = q.evaluate(); + int n = 0; + try { + while (tqr.hasNext()) { + tqr.next(); + n++; + } + } finally { + tqr.close(); + } + if (log.isInfoEnabled()) + log.info("Query: writer=" + writer + ", counter=" + counter + + ", nresults=" + n + ", elapsed=" + + (System.currentTimeMillis() - begin)); + } + } + +} Property changes on: trunk/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |