File: sparql11-federation.t

package info (click to toggle)
librdf-query-perl 2.919-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,580 kB
  • sloc: perl: 30,628; javascript: 131; sh: 13; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,483 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use lib qw(. t);
BEGIN { require "models.pl"; }

my @files	= map { "data/$_" } qw(foaf.xrdf);
my @models	= test_models( @files );

my $tests	= 2;
plan tests => $tests;

use RDF::Query;

################################################################################
# Log::Log4perl::init( \q[
# 	log4perl.category.rdf.query.costmodel          = TRACE, Screen
# 	
# 	log4perl.appender.Screen         = Log::Log4perl::Appender::Screen
# 	log4perl.appender.Screen.stderr  = 0
# 	log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
# ] );
################################################################################

SKIP: {
	print "# Remote SERVICE invocations\n";
	my $why	= "No network. Set RDFQUERY_NETWORK_TESTS to run these tests.";
	skip $why, 2 unless ($ENV{RDFQUERY_NETWORK_TESTS});
	
	{
		my $query	= RDF::Query->new( <<"END", { lang => 'sparql11' } ) or warn RDF::Query->error;
			PREFIX foaf: <http://xmlns.com/foaf/0.1/>
			SELECT DISTINCT *
			WHERE {
				SERVICE <http://myrdf.us/sparql11> {
					?p a foaf:Person ; foaf:name "Gregory Todd Williams" .
					FILTER(ISIRI(?p))
				}
			}
			LIMIT 1
END
		my $model	= RDF::Trine::Model->new();
		my $iter	= $query->execute( $model );
		my $count	= 0;
		while (my $row = $iter->next) {
			$count++;
			is( $row->{p}->uri_value, 'http://kasei.us/about/foaf.xrdf#greg', 'expected URI value from remote SERVICE' );
		}
		is( $count, 1 );
	}
}