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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
NAME
Test::RDF - Test RDF data for content, validity and equality, etc.
VERSION
Version 0.26
SYNOPSIS
use Test::RDF;
is_valid_rdf($rdf_string, $syntax, 'RDF string is valid according to selected syntax');
is_rdf($rdf_string, $syntax1, $expected_rdf_string, $syntax2, 'The two strings have the same triples');
isomorph_graphs($model, $expected_model, 'The two models have the same triples');
are_subgraphs($model1, $model2, 'Model 1 is a subgraph of model 2' );
has_uri($uri_string, $model, 'Has correct URI');
hasnt_uri($uri_string, $model, "Hasn't correct URI");
has_subject($uri_string, $model, 'Subject URI is found');
has_predicate($uri_string, $model, 'Predicate URI is found');
has_object_uri($uri_string, $model, 'Object URI is found');
has_literal($string, $language, $datatype, $model, 'Literal is found');
pattern_target($model);
pattern_ok($pattern, '$pattern found in $model');
EXPORT
is_valid_rdf
Use to check if the input RDF string is valid in the chosen syntax
is_rdf
Use to check if the input RDF strings are isomorphic (i.e. the same).
isomorph_graphs
Use to check if the input RDF::Trine::Models have isomorphic graphs.
are_subgraphs
Use to check if the first RDF::Trine::Models is a subgraph of the
second.
has_subject
Check if the string URI passed as first argument is a subject in any of
the statements given in the model given as second argument.
has_predicate
Check if the string URI passed as first argument is a predicate in any
of the statements given in the model given as second argument.
has_object_uri
Check if the string URI passed as first argument is a object in any of
the statements given in the model given as second argument.
has_literal
Check if the string passed as first argument, with corresponding
optional language and datatype as second and third respectively, is a
literal in any of the statements given in the model given as fourth
argument.
language and datatype may not occur in the same statement, so the test
fails if they are both set. If none are used, use "undef", like e.g.
has_literal('A test', undef, undef, $model, 'Simple literal');
A test for a typed literal may be done like
has_literal('42', undef, 'http://www.w3.org/2001/XMLSchema#integer', $model, 'Just an integer');
and a language literal like
has_literal('This is a Another test', 'en', undef, $model, 'Language literal');
has_uri
Check if the string URI passed as first argument is present in any of
the statements given in the model given as second argument.
hasnt_uri
Check if the string URI passed as first argument is not present in any
of the statements given in the model given as second argument.
pattern_target
Tests that the object passed as its parameter is an RDF::Trine::Model or
RDF::Trine::Store. That is, tests that it is a valid thing to match
basic graph patterns against.
Additionally, this test establishes the target for future "pattern_ok"
tests.
pattern_ok
Tests that the pattern passed matches against the target established by
"pattern_target". The pattern may be passed as an RDF::Trine::Pattern,
or a list of RDF::Trine::Statement objects.
use Test::RDF;
use RDF::Trine qw[iri literal blank variable statement];
use My::Module;
my $foaf = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');
pattern_target(My::Module->get_model); # check isa RDF::Trine::Model
pattern_ok(
statement(
variable('who'),
$foaf->name,
literal('Kjetil Kjernsmo')
),
statement(
variable('who'),
$foaf->page,
iri('http://search.cpan.org/~kjetilk/')
),
"Data contains Kjetil's details."
);
Note: "pattern_target" must have been tested before any "pattern_ok"
tests.
NOTE
Graph isomorphism is a complex problem, so do not attempt to run the
isomorphism tests on large datasets. For more information see
<http://en.wikipedia.org/wiki/Graph_isomorphism_problem>.
AUTHOR
Kjetil Kjernsmo, "<kjetilk at cpan.org>"
BUGS
Please report any bugs using <github>
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Test::RDF
You may find the Perl and RDF community <website> useful.
You can also look for information at:
* AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Test-RDF>
* CPAN Ratings
<http://cpanratings.perl.org/d/Test-RDF>
* Search CPAN
<http://search.cpan.org/dist/Test-RDF/>
* MetaCPAN
<https://metacpan.org/module/Test::RDF>
ACKNOWLEDGEMENTS
Michael Hendricks wrote the first Test::RDF. The present module is a
complete rewrite from scratch using Gregory Todd William's
RDF::Trine::Graph to do the heavy lifting.
Toby Inkster has submitted the pattern_* functions.
LICENSE AND COPYRIGHT
Copyright 2010 ABC Startsiden AS and 2010-2012 Kjetil Kjernsmo.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
|