use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestLangTurtle method blankNodes2.
@Test
public void blankNodes2() {
// Duplicate.
String s = "_:a <http://example/p> 'foo' . _:a <http://example/p> 'foo' .";
StringReader r = new StringReader(s);
Model m = ModelFactory.createDefaultModel();
RDFDataMgr.read(m, r, null, RDFLanguages.TURTLE);
assertEquals(1, m.size());
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestLangTurtle method blankNodes1.
@Test
public void blankNodes1() {
String s = "_:a <http://example/p> 'foo' . ";
StringReader r = new StringReader(s);
Model m = ModelFactory.createDefaultModel();
RDFDataMgr.read(m, r, null, RDFLanguages.TURTLE);
assertEquals(1, m.size());
String x = m.listStatements().next().getSubject().getId().getLabelString();
assertNotEquals(x, "a");
// reset - reread - new bNode.
r = new StringReader(s);
RDFDataMgr.read(m, r, null, RDFLanguages.TURTLE);
assertEquals(2, m.size());
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestLangTurtle method updatePrefixMapping2.
@Test
public void updatePrefixMapping2() {
// Test that prefixes are resolved
Model model = ModelFactory.createDefaultModel();
StringReader reader = new StringReader("BASE <http://example/> PREFIX x: <abc>");
RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE);
assertEquals(1, model.getNsPrefixMap().size());
assertEquals("http://example/abc", model.getNsPrefixURI("x"));
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestLangRdfJson method rdfjson_read_simple_plainliteral_object.
@Test
public void rdfjson_read_simple_plainliteral_object() {
String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } ] } }";
String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" .";
assertEquals(1, parseCount(s));
Model m = parseToModelRdfJson(s);
Model m2 = parseToModelNTriples(s2);
assertTrue(m.isIsomorphicWith(m2));
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestLangRdfJson method rdfjson_read_simple_typedliteral_object.
@Test
public void rdfjson_read_simple_typedliteral_object() {
String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\", \"datatype\" : \"http://example.org/datatype\" } ] } }";
String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\"^^<http://example.org/datatype> .";
assertEquals(1, parseCount(s));
Model m = parseToModelRdfJson(s);
Model m2 = parseToModelNTriples(s2);
assertTrue(m.isIsomorphicWith(m2));
}
Aggregations