@@ -8,7 +8,7 @@ use Test::More;# tests => 37;
8
8
use Test::RDF;
9
9
use RDF::Trine qw[ iri literal blank variable statement] ;
10
10
use Log::Any::Adapter;
11
- use RDF::Trine::Namespace qw( rdf rdfs foaf ) ;
11
+ use URI::NamespaceMap ;
12
12
use Module::Load::Conditional qw[ check_install] ;
13
13
use URI::Escape;
14
14
@@ -23,11 +23,8 @@ my $file = $Bin . '/data/fragments.ttl';
23
23
use_ok(' RDF::LinkedData' );
24
24
use_ok(' RDF::Generator::Void' );
25
25
26
-
27
- my $void = RDF::Trine::Namespace-> new(' http://rdfs.org/ns/void#' );
28
- my $xsd = RDF::Trine::Namespace-> new(' http://www.w3.org/2001/XMLSchema#' );
29
- my $hydra = RDF::Trine::Namespace-> new(' http://www.w3.org/ns/hydra/core#' );
30
- my $dcterms = RDF::Trine::Namespace-> new(' http://purl.org/dc/terms/' );
26
+ my $ns = URI::NamespaceMap-> new([' rdf' , ' rdfs' , ' foaf' , ' void' , ' dct' , ' xsd' ]);
27
+ $ns -> add_mapping(' hydra' => ' http://www.w3.org/ns/hydra/core#' );
31
28
32
29
my $parser = RDF::Trine::Parser-> new( ' turtle' );
33
30
my $rxparser = RDF::Trine::Parser-> new( ' rdfxml' );
@@ -65,26 +62,26 @@ my $void_subject = iri($base_uri . '/#dataset-0');
65
62
pattern_target($retmodel );
66
63
pattern_ok(
67
64
statement(iri($base_uri . ' /foo' ),
68
- $ rdfs-> label,
65
+ iri( $ns -> rdfs-> label) ,
69
66
literal(" This is a test" , ' en' )),
70
67
statement(iri($base_uri . ' /foo' ),
71
- $ foaf-> page,
68
+ iri( $ns -> foaf-> page) ,
72
69
iri(' http://en.wikipedia.org/wiki/Foo' ))
73
70
, ' Both triples present' ,
74
71
);
75
72
76
73
pattern_ok(
77
74
statement(iri($base_uri . ' /fragments?subject=' . uri_escape_utf8(' http://localhost/foo' )),
78
- $ void-> triples,
79
- literal(" 2" , undef , $ xsd-> integer)),
75
+ iri( $ns -> void-> triples) ,
76
+ literal(" 2" , undef , iri( $ns -> xsd-> integer) )),
80
77
statement(iri($base_uri . ' /fragments?subject=' . uri_escape_utf8(' http://localhost/foo' )),
81
- $ hydra-> totalItems,
82
- literal(" 2" , undef , $ xsd-> integer)),
78
+ iri( $ns -> hydra-> totalItems) ,
79
+ literal(" 2" , undef , iri( $ns -> xsd-> integer) )),
83
80
, ' Triple count is correct' ,
84
81
);
85
82
86
83
pattern_ok( statement(iri($base_uri . ' /fragments?subject=' . uri_escape_utf8(' http://localhost/foo' )),
87
- $dcterms -> source,
84
+ iri( $ns -> dct -> source) ,
88
85
$void_subject ),
89
86
, ' Void Subject in dct:source'
90
87
);
@@ -93,43 +90,43 @@ my $void_subject = iri($base_uri . '/#dataset-0');
93
90
94
91
pattern_ok(
95
92
statement($void_subject ,
96
- $ rdf-> type,
97
- $ hydra-> Collection),
93
+ iri( $ns -> rdf-> type) ,
94
+ iri( $ns -> hydra-> Collection) ),
98
95
statement($void_subject ,
99
- $ hydra-> search,
96
+ iri( $ns -> hydra-> search) ,
100
97
blank(' template' )),
101
98
statement(blank(' template' ),
102
- $ hydra-> template,
99
+ iri( $ns -> hydra-> template) ,
103
100
literal($base_uri . ' /fragments{?subject,predicate,object}' )),
104
101
statement(blank(' template' ),
105
- $ hydra-> mapping,
102
+ iri( $ns -> hydra-> mapping) ,
106
103
blank(' subject' )),
107
104
statement(blank(' template' ),
108
- $ hydra-> mapping,
105
+ iri( $ns -> hydra-> mapping) ,
109
106
blank(' predicate' )),
110
107
statement(blank(' template' ),
111
- $ hydra-> mapping,
108
+ iri( $ns -> hydra-> mapping) ,
112
109
blank(' predicate' )),
113
110
statement(blank(' template' ),
114
- $ hydra-> mapping,
111
+ iri( $ns -> hydra-> mapping) ,
115
112
blank(' object' )),
116
113
statement(blank(' subject' ),
117
- $ hydra-> property,
118
- $ rdf-> subject),
114
+ iri( $ns -> hydra-> property) ,
115
+ iri( $ns -> rdf-> subject) ),
119
116
statement(blank(' subject' ),
120
- $ hydra-> variable,
117
+ iri( $ns -> hydra-> variable) ,
121
118
literal(' subject' )),
122
119
statement(blank(' predicate' ),
123
- $ hydra-> property,
124
- $ rdf-> predicate),
120
+ iri( $ns -> hydra-> property) ,
121
+ iri( $ns -> rdf-> predicate) ),
125
122
statement(blank(' predicate' ),
126
- $ hydra-> variable,
123
+ iri( $ns -> hydra-> variable) ,
127
124
literal(' predicate' )),
128
125
statement(blank(' object' ),
129
- $ hydra-> property,
130
- $ rdf-> object),
126
+ iri( $ns -> hydra-> property) ,
127
+ iri( $ns -> rdf-> object) ),
131
128
statement(blank(' object' ),
132
- $ hydra-> variable,
129
+ iri( $ns -> hydra-> variable) ,
133
130
literal(' object' )),
134
131
" Control statements OK" );
135
132
}
@@ -140,16 +137,16 @@ my $void_subject = iri($base_uri . '/#dataset-0');
140
137
is($response -> status, 200, " Returns 200" );
141
138
my $retmodel = return_model($response -> content, $parser );
142
139
has_literal(' Testing with longer URI.' , ' en' , undef , $retmodel , " Longer test phrase is in content" );
143
- has_literal(" 1" , undef , $xsd -> integer, $retmodel , ' Triple count is correct' );
140
+ has_literal(" 1" , undef , $ns -> xsd-> integer-> as_string , $retmodel , ' Triple count is correct' );
144
141
hasnt_literal(' This is a test' , ' en' , undef , $retmodel , " Test phrase isn't in content" );
145
142
}
146
143
{
147
144
my $response = $ld -> response($base_uri . ' /fragments?object=' . uri_escape_utf8(' "42"^^http://www.w3.org/2001/XMLSchema#integer' ));
148
145
isa_ok($response , ' Plack::Response' );
149
146
is($response -> status, 200, " Returns 200" );
150
147
my $retmodel = return_model($response -> content, $parser );
151
- has_literal(' 42' , undef , $xsd -> integer, $retmodel , " The Answer is in the content" );
152
- has_literal(" 1" , undef , $xsd -> integer, $retmodel , ' Triple count is correct' );
148
+ has_literal(' 42' , undef , $ns -> xsd-> integer-> as_string , $retmodel , " The Answer is in the content" );
149
+ has_literal(" 1" , undef , $ns -> xsd-> integer-> as_string , $retmodel , ' Triple count is correct' );
153
150
hasnt_literal(' This is a test' , ' en' , undef , $retmodel , " Test phrase isn't in content" );
154
151
}
155
152
{
@@ -158,7 +155,7 @@ my $void_subject = iri($base_uri . '/#dataset-0');
158
155
is($response -> status, 200, " Returns 200" );
159
156
my $retmodel = return_model($response -> content, $parser );
160
157
hasnt_literal(' Testing with longer URI.' , ' en' , undef , $retmodel , " Longer test phrase is in content" );
161
- has_literal(" 0" , undef , $xsd -> integer, $retmodel , ' Triple count is correct' );
158
+ has_literal(" 0" , undef , $ns -> xsd-> integer-> as_string , $retmodel , ' Triple count is correct' );
162
159
}
163
160
{
164
161
my $response = $ld -> response($base_uri . ' /fragments?predicate=' . uri_escape_utf8(' http://www.w3.org/2000/01/rdf-schema#label' ) . ' &subject=' );
@@ -167,7 +164,7 @@ my $void_subject = iri($base_uri . '/#dataset-0');
167
164
my $retmodel = return_model($response -> content, $parser );
168
165
has_subject($base_uri . ' /foo' , $retmodel , ' Subject 1 is correct' );
169
166
has_subject($base_uri . ' /bar/baz/bing' , $retmodel , ' Subject 2 is correct' );
170
- has_literal(" 2" , undef , $xsd -> integer, $retmodel , ' Triple count is correct' );
167
+ has_literal(" 2" , undef , $ns -> xsd-> integer-> as_string , $retmodel , ' Triple count is correct' );
171
168
has_literal(' This is a test' , ' en' , undef , $retmodel , " Test phrase is in content" );
172
169
}
173
170
{
@@ -202,59 +199,59 @@ my $void_subject = iri($base_uri . '/#dataset-0');
202
199
is($response -> status, 200, " Returns 200" );
203
200
my $retmodel = return_model($response -> content, $parser );
204
201
has_subject($void_subject -> uri_value, $retmodel , " Subject URI in content" );
205
- has_predicate($hydra -> search-> uri_value , $retmodel , ' Hydra search predicate' );
202
+ has_predicate($ns -> hydra-> search-> as_string , $retmodel , ' Hydra search predicate' );
206
203
pattern_target($retmodel );
207
204
pattern_ok(
208
205
statement(
209
206
$void_subject ,
210
- $ void-> triples,
211
- literal(4, undef , $ xsd-> integer)
207
+ iri( $ns -> void-> triples) ,
208
+ literal(4, undef , iri( $ns -> xsd-> integer) )
212
209
),
213
210
statement(
214
211
$void_subject ,
215
- $ rdf-> type,
216
- $ void-> Dataset
212
+ iri( $ns -> rdf-> type) ,
213
+ iri( $ns -> void-> Dataset)
217
214
),
218
215
' VoID-specific statements' );
219
216
pattern_ok(
220
217
statement($void_subject ,
221
- $ rdf-> type,
222
- $ hydra-> Collection),
218
+ iri( $ns -> rdf-> type) ,
219
+ iri( $ns -> hydra-> Collection) ),
223
220
statement($void_subject ,
224
- $ hydra-> search,
221
+ iri( $ns -> hydra-> search) ,
225
222
blank(' template' )),
226
223
statement(blank(' template' ),
227
- $ hydra-> template,
224
+ iri( $ns -> hydra-> template) ,
228
225
literal($base_uri . ' /fragments{?subject,predicate,object}' )),
229
226
statement(blank(' template' ),
230
- $ hydra-> mapping,
227
+ iri( $ns -> hydra-> mapping) ,
231
228
blank(' subject' )),
232
229
statement(blank(' template' ),
233
- $ hydra-> mapping,
230
+ iri( $ns -> hydra-> mapping) ,
234
231
blank(' predicate' )),
235
232
statement(blank(' template' ),
236
- $ hydra-> mapping,
233
+ iri( $ns -> hydra-> mapping) ,
237
234
blank(' predicate' )),
238
235
statement(blank(' template' ),
239
- $ hydra-> mapping,
236
+ iri( $ns -> hydra-> mapping) ,
240
237
blank(' object' )),
241
238
statement(blank(' subject' ),
242
- $ hydra-> property,
243
- $ rdf-> subject),
239
+ iri( $ns -> hydra-> property) ,
240
+ iri( $ns -> rdf-> subject) ),
244
241
statement(blank(' subject' ),
245
- $ hydra-> variable,
242
+ iri( $ns -> hydra-> variable) ,
246
243
literal(' subject' )),
247
244
statement(blank(' predicate' ),
248
- $ hydra-> property,
249
- $ rdf-> predicate),
245
+ iri( $ns -> hydra-> property) ,
246
+ iri( $ns -> rdf-> predicate) ),
250
247
statement(blank(' predicate' ),
251
- $ hydra-> variable,
248
+ iri( $ns -> hydra-> variable) ,
252
249
literal(' predicate' )),
253
250
statement(blank(' object' ),
254
- $ hydra-> property,
255
- $ rdf-> object),
251
+ iri( $ns -> hydra-> property) ,
252
+ iri( $ns -> rdf-> object) ),
256
253
statement(blank(' object' ),
257
- $ hydra-> variable,
254
+ iri( $ns -> hydra-> variable) ,
258
255
literal(' object' )),
259
256
" Control statements OK" );
260
257
}
@@ -278,7 +275,7 @@ my $void_subject = iri($base_uri . '/#dataset-0');
278
275
isa_ok($response , ' Plack::Response' );
279
276
is($response -> status, 200, " Returns 200 with all parameters empty" );
280
277
my $retmodel = return_model($response -> content, $parser );
281
- has_literal(" 4" , undef , $xsd -> integer, $retmodel , ' Triple count is correct got all 4 triples' );
278
+ has_literal(" 4" , undef , $ns -> xsd-> integer-> as_string , $retmodel , ' Triple count is correct got all 4 triples' );
282
279
}
283
280
}
284
281
0 commit comments