Permalink
Browse files

Test basic graph pattern matches

The doap.nt file was copied from rdf-spec, which is in the public
domain.
  • Loading branch information...
emk committed Feb 14, 2011
1 parent 1eb0c69 commit 41b0d20bdfd4225fa763c525210687deaa343d9a
Showing with 106 additions and 1 deletion.
  1. +73 −0 etc/doap.nt
  2. +33 −1 spec/agraph_spec.rb
View
@@ -0,0 +1,73 @@
+<http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+<http://ar.to/#self> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bendiken/foaf> .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <http://ar.to/> .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <http://rubygems.org/gems/rdf> .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto.bendiken@gmail.com> .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" .
+<http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
+<http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+<http://bhuga.net/#ben> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bhuga/foaf> .
+<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <http://bhuga.net/> .
+<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
+<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
+<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
+<http://kellogg-assoc.com/#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/homepage> <http://kellogg-assoc.com/> .
+<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@kellogg-assoc.com> .
+<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
+<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
+<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/bendiken/rdf/issues> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://kellogg-assoc.com/#me> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://bhuga.net/#ben> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://kellogg-assoc.com/#me> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid4 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid5 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid6 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid7 .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://bhuga.net/#ben> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://kellogg-assoc.com/#me> .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
+<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#vendor> <http://datagraph.org/> .
+<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
+<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
+_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "274bd18402fc773ffc0606996aa1fb90b603aa29" .
+_:genid1 <http://xmlns.com/foaf/0.1/name> "C\u0103lin Ardelean" .
+_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f412d743150d7b27b8468d56e69ca147917ea6fc" .
+_:genid2 <http://xmlns.com/foaf/0.1/name> "Joey Geiger" .
+_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
+_:genid3 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
+_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid4 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
+_:genid4 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
+_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid5 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
+_:genid5 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
+_:genid6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid6 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "2b4247b6fd5bb4a1383378f325784318680d5ff9" .
+_:genid6 <http://xmlns.com/foaf/0.1/name> "Keita Urashima" .
+_:genid7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+_:genid7 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
+_:genid7 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
View
@@ -11,6 +11,12 @@
require 'rdf'
require 'rdf/agraph'
+RSpec::Matchers.define :include_solution do |hash|
+ match do |solutions|
+ solutions.any? {|s| s.to_hash == hash }
+ end
+end
+
describe RDF::AllegroGraph::Repository do
before :each do
options = {
@@ -25,6 +31,32 @@
@repository.clear
end
- # @see lib/rdf/spec/repository.rb
it_should_behave_like RDF_Repository
+
+ context "with example data" do
+ before :each do
+ path = File.join(File.dirname(__FILE__), '..', 'etc', 'doap.nt')
+ @repository.load(path)
+ end
+
+ describe ".query" do
+ it "match a Basic Graph Patterns" do
+ query = RDF::Query.new do |q|
+ q.pattern [:person, RDF.type, RDF::FOAF.Person]
+ q.pattern [:person, RDF::FOAF.name, :name]
+ q.pattern [:person, RDF::FOAF.mbox, :email]
+ end
+ s = @repository.query(query)
+ s.should include_solution(:person => "http://ar.to/#self",
+ :name => "Arto Bendiken",
+ :email => "mailto:arto.bendiken@gmail.com")
+ s.should include_solution(:person => "http://bhuga.net/#ben",
+ :name => "Ben Lavender",
+ :email => "mailto:blavender@gmail.com")
+ s.should include_solution(:person => "http://kellogg-assoc.com/#me",
+ :name => "Gregg Kellogg",
+ :email => "mailto:gregg@kellogg-assoc.com")
+ end
+ end
+ end
end

0 comments on commit 41b0d20

Please sign in to comment.