#!/usr/bin/env ruby $LOAD_PATH.unshift('../../lib/') # dev't code, lives locally require 'basicrdf' require 'squish' require 'RDF4R/pastiche' include RDF4R::Pastiche::SWAP require 'test/unit' # http://rdfweb.org/2003/02/a-z/intro.html # Test smushing behaviour. # # We use our own private scratch db for this. # # createdb --quiet foafaz; psql -q foafaz < ../../../db/initdb-pg.sql # # # to DELETE and re-populate this from the foaf test data: # ./ayftest.rb --destroydb -n DBI:Pg:foafaz -s http://rdfweb.org/2003/02/a-z/az-scutterplan.rdf # # author: Dan Brickley # version: $Revision: 1.4 $ class TC_AZSmushRDF < Test::Unit::TestCase attr_accessor :stored, :sql, :foaf, :dc def setup begin @sql=SimpleSQLGraph.new('dbi_driver'=>'DBI:Pg:foafaz', 'dbi_user'=>'danbri') rescue Exception raise "Failed to connect to az database. Skip these tests. #{$!}" end @stored = Formula.new sql sql.verbosity=50 # sql.defrag @foaf = Namespace("http://xmlns.com/foaf/0.1/") @dc = Namespace("http://purl.org/dc/elements/1.1/") end def test_aa aa_mbox='mailto:alice.albright@foaf.example.com' a=stored.statementsMatching('pred'=>foaf+'mbox', 'obj'=>aa_mbox) assert a!=nil,"query on aa_mbox shouldn't return nil." assert a.size==1,"should get just one result. actual:#{a.size}" end def test_bb bb_mbox="mailto:bb@foaf.example.org" a=stored.statementsMatching('pred'=>foaf+'mbox', 'obj'=>bb_mbox) assert a!=nil, "query on bb_mbox shouldn't return nil." assert a.size==1, "should get just one result. actual:#{a.size}" sql.defrag # flatten nodes bb_homepage = 'http://www.example.org/foaf/people/betrand/' a=stored.statementsMatching 'pred'=>foaf+'homepage', 'obj'=>bb_homepage assert a!=nil, "query on bb_homepage shouldn't return nil." who=a.subjects assert who.size==1, "bb_homepage should get just one person. actual:#{who.size}" # this is a bit subtle. we'll only get one row back from API, # however the backend for stored has this assertion 3 or so times. end end