From: <dm...@us...> - 2010-10-19 11:16:09
|
Revision: 3817 http://bigdata.svn.sourceforge.net/bigdata/?rev=3817&view=rev Author: dmacgbr Date: 2010-10-19 11:16:00 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Add a few more tests in the area of default and named graph matching Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 08:50:30 UTC (rev 3816) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 11:16:00 UTC (rev 3817) @@ -87,7 +87,7 @@ super(arg0); } - public void testDefaultGraph () + public void testImplementationDefinedDefaultGraph () throws Exception { BigdataSail sail = getTheSail () ; @@ -111,6 +111,100 @@ run ( sail, cxn, kb, graphs, qs, expected ) ; } + public void testExplicitDefaultGraph () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?p ?o from <%sg1> from <%sg2> where { <%ss> ?p ?o .}", ns, ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "p", new URIImpl ( String.format ( "%sp", ns ) ) ) + , new BindingImpl ( "o", new URIImpl ( String.format ( "%so", ns ) ) ) + ) + ) ; + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testNamedGraphNoGraphKeyword1 () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from named <%sg2> where { ?s ?p ?o .}", ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testNamedGraphNoGraphKeyword2 () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from named <%sg1> from named <%sg2> where { ?s ?p ?o .}", ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testExplicitDefaultAndNamedGraphNoGraphKeyword () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from <%sg1> from named <%sg2> where { ?s ?p ?o .}", ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + private BigdataSail getTheSail () throws SailException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |