File: 01basic.t

package info (click to toggle)
librdf-query-client-perl 0.114-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 192 kB
  • sloc: perl: 316; sh: 6; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,541 bytes parent folder | download | duplicates (3)
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
use LWP::UserAgent;
use Test::RequiresInternet 'sparql.org' => 80;
use Test::More tests => 5;

BEGIN { use_ok('RDF::Query::Client') };

SKIP:
{
	my $response = LWP::UserAgent
		-> new
		-> get('http://sparql.org/books/sparql?query=SELECT+*+{$s+$p+$o}');
	
	unless ($response->is_success)
	{
		diag $response->as_string;
		skip "need network access and ability to connect to sparql.org", 4;
	}
	
	my $sparql_ask
		= "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n"
		. "ASK WHERE { ?book dc:title ?title . }" ;
	
	my $sparql_select
		= "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n"
		. "SELECT * WHERE { ?book dc:title ?title . }" ;
	
	my $sparql_construct
		= "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n"
		. "CONSTRUCT { ?book <http://purl.org/dc/terms/title> ?title . }\n"
		. "WHERE { ?book dc:title ?title . }" ;
		
	my $q_ask       = new RDF::Query::Client($sparql_ask);
	my $q_select    = new RDF::Query::Client($sparql_select);
	my $q_construct = new RDF::Query::Client($sparql_construct);
	
	my $r_ask       = $q_ask->execute('http://sparql.org/books/sparql');
	my $r_select    = $q_select->execute('http://sparql.org/books/sparql');
	my $r_construct = $q_construct->execute('http://sparql.org/books/sparql');
	
	ok($r_ask->is_boolean, "ASK results in a boolean");
	ok($r_select->is_bindings, "SELECT results in bindings");
	ok($r_construct->is_graph, "CONSTRUCT results in a graph");
	
	ok($r_ask->get_boolean, "ASK results as expected");
	
	diag("You can safely ignore warnings from DBD about tables being locked.\n");
}