|
|
@ -8,11 +8,11 @@ use reqwest::Client; |
|
|
|
use rudf::model::data::*; |
|
|
|
use rudf::model::data::*; |
|
|
|
use rudf::rio::RioError; |
|
|
|
use rudf::rio::RioError; |
|
|
|
use rudf::rio::RioResult; |
|
|
|
use rudf::rio::RioResult; |
|
|
|
|
|
|
|
use rudf::rio::ntriples::read_ntriples; |
|
|
|
use rudf::rio::turtle::read_turtle; |
|
|
|
use rudf::rio::turtle::read_turtle; |
|
|
|
use std::collections::HashSet; |
|
|
|
use std::collections::HashSet; |
|
|
|
use std::iter::FromIterator; |
|
|
|
use std::iter::FromIterator; |
|
|
|
use url::Url; |
|
|
|
use url::Url; |
|
|
|
use rudf::rio::ntriples::read_ntriples; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct RDFClient { |
|
|
|
struct RDFClient { |
|
|
|
client: Client, |
|
|
|
client: Client, |
|
|
@ -42,10 +42,7 @@ impl RDFClient { |
|
|
|
|
|
|
|
|
|
|
|
fn load_ntriples(&self, uri: Url) -> RioResult<HashSet<Triple>> { |
|
|
|
fn load_ntriples(&self, uri: Url) -> RioResult<HashSet<Triple>> { |
|
|
|
match self.client.get(uri).send() { |
|
|
|
match self.client.get(uri).send() { |
|
|
|
Ok(response) => read_ntriples( |
|
|
|
Ok(response) => read_ntriples(response, &self.data_factory).collect(), |
|
|
|
response, |
|
|
|
|
|
|
|
&self.data_factory |
|
|
|
|
|
|
|
).collect(), |
|
|
|
|
|
|
|
Err(error) => Err(RioError::new(error)), |
|
|
|
Err(error) => Err(RioError::new(error)), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -143,7 +140,6 @@ fn turtle_w3c_testsuite() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn ntriples_w3c_testsuite() { |
|
|
|
fn ntriples_w3c_testsuite() { |
|
|
|
let client = RDFClient::default(); |
|
|
|
let client = RDFClient::default(); |
|
|
@ -158,42 +154,40 @@ fn ntriples_w3c_testsuite() { |
|
|
|
); |
|
|
|
); |
|
|
|
let rdfs_comment = data_factory |
|
|
|
let rdfs_comment = data_factory |
|
|
|
.named_node(Url::parse("http://www.w3.org/2000/01/rdf-schema#comment").unwrap()); |
|
|
|
.named_node(Url::parse("http://www.w3.org/2000/01/rdf-schema#comment").unwrap()); |
|
|
|
let rdft_test_turtle_positive_syntax = |
|
|
|
let rdft_test_turtle_positive_syntax = Term::from(data_factory.named_node( |
|
|
|
Term::from(data_factory.named_node( |
|
|
|
Url::parse("http://www.w3.org/ns/rdftest#TestNTriplesPositiveSyntax").unwrap(), |
|
|
|
Url::parse("http://www.w3.org/ns/rdftest#TestNTriplesPositiveSyntax").unwrap(), |
|
|
|
)); |
|
|
|
)); |
|
|
|
let rdft_test_turtle_negative_syntax = Term::from(data_factory.named_node( |
|
|
|
let rdft_test_turtle_negative_syntax = |
|
|
|
Url::parse("http://www.w3.org/ns/rdftest#TestNTriplesNegativeSyntax").unwrap(), |
|
|
|
Term::from(data_factory.named_node( |
|
|
|
)); |
|
|
|
Url::parse("http://www.w3.org/ns/rdftest#TestNTriplesNegativeSyntax").unwrap(), |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subjects_for_predicate_object(&manifest, &rdf_type, &rdft_test_turtle_positive_syntax) |
|
|
|
subjects_for_predicate_object(&manifest, &rdf_type, &rdft_test_turtle_positive_syntax) |
|
|
|
.for_each(|test| { |
|
|
|
.for_each(|test| { |
|
|
|
let comment = object_for_subject_predicate(&manifest, test, &rdfs_comment).unwrap(); |
|
|
|
let comment = object_for_subject_predicate(&manifest, test, &rdfs_comment).unwrap(); |
|
|
|
if let Some(Term::NamedNode(file)) = |
|
|
|
if let Some(Term::NamedNode(file)) = |
|
|
|
object_for_subject_predicate(&manifest, test, &mf_action) |
|
|
|
object_for_subject_predicate(&manifest, test, &mf_action) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if let Err(error) = client.load_ntriples(file.url().clone()) { |
|
|
|
if let Err(error) = client.load_ntriples(file.url().clone()) { |
|
|
|
assert!( |
|
|
|
assert!( |
|
|
|
false, |
|
|
|
false, |
|
|
|
"Failure on positive syntax file {} about {} with error: {}", |
|
|
|
"Failure on positive syntax file {} about {} with error: {}", |
|
|
|
file, comment, error |
|
|
|
file, comment, error |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
subjects_for_predicate_object(&manifest, &rdf_type, &rdft_test_turtle_negative_syntax) |
|
|
|
subjects_for_predicate_object(&manifest, &rdf_type, &rdft_test_turtle_negative_syntax) |
|
|
|
.for_each(|test| { |
|
|
|
.for_each(|test| { |
|
|
|
let comment = object_for_subject_predicate(&manifest, test, &rdfs_comment).unwrap(); |
|
|
|
let comment = object_for_subject_predicate(&manifest, test, &rdfs_comment).unwrap(); |
|
|
|
if let Some(Term::NamedNode(file)) = |
|
|
|
if let Some(Term::NamedNode(file)) = |
|
|
|
object_for_subject_predicate(&manifest, test, &mf_action) |
|
|
|
object_for_subject_predicate(&manifest, test, &mf_action) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert!( |
|
|
|
assert!( |
|
|
|
client.load_ntriples(file.url().clone()).is_err(), |
|
|
|
client.load_ntriples(file.url().clone()).is_err(), |
|
|
|
"Failure on negative syntax test file {} about {}", |
|
|
|
"Failure on negative syntax test file {} about {}", |
|
|
|
file, |
|
|
|
file, |
|
|
|
comment |
|
|
|
comment |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|