Search in sources :

Example 61 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestLangRdfJson method rdfjson_read_bnode_identity2.

@Test
public void rdfjson_read_bnode_identity2() {
    String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] , \"http://example.org/predicate2\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }";
    String s2 = "<http://example.org/subject> <http://example.org/predicate> _:id ." + "<http://example.org/subject> <http://example.org/predicate2> _:id .";
    assertEquals(2, parseCount(s));
    Model m = parseToModelRdfJson(s);
    Model m2 = parseToModelNTriples(s2);
    assertTrue(m.isIsomorphicWith(m2));
}
Also used : Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 62 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestLangRdfJson method parseToModelNTriples.

private Model parseToModelNTriples(String string) {
    StringReader r = new StringReader(string);
    Model model = ModelFactory.createDefaultModel();
    RDFDataMgr.read(model, r, null, RDFLanguages.NTRIPLES);
    return model;
}
Also used : StringReader(java.io.StringReader) Model(org.apache.jena.rdf.model.Model)

Example 63 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestLangRdfJson method rdfjson_read_objectlist_literals3.

@Test
public void rdfjson_read_objectlist_literals3() {
    String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } , { \"type\" : \"literal\" , \"value\" : \"more text\", \"datatype\" : \"http://example.org/datatype\" } ] } }";
    String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" .\n" + "<http://example.org/subject> <http://example.org/predicate> \"more text\"^^<http://example.org/datatype> .";
    assertEquals(2, parseCount(s));
    Model m = parseToModelRdfJson(s);
    Model m2 = parseToModelNTriples(s2);
    assertTrue(m.isIsomorphicWith(m2));
}
Also used : Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 64 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestLangRdfJson method rdfjson_get_jena_writer.

@Test
public void rdfjson_get_jena_writer() {
    Model m = ModelFactory.createDefaultModel();
    m.getWriter("RDF/JSON");
}
Also used : Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 65 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestLangRdfJson method rdfjson_get_jena_reader.

@Test
public void rdfjson_get_jena_reader() {
    Model m = ModelFactory.createDefaultModel();
    m.getReader("RDF/JSON");
}
Also used : Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

Model (org.apache.jena.rdf.model.Model)444 Test (org.junit.Test)177 BaseTest (org.apache.jena.atlas.junit.BaseTest)96 Resource (org.apache.jena.rdf.model.Resource)87 StringReader (java.io.StringReader)43 Dataset (org.apache.jena.query.Dataset)31 RDFReader (org.apache.jena.rdf.model.RDFReader)30 Property (org.apache.jena.rdf.model.Property)24 DatasetAccessor (org.apache.jena.query.DatasetAccessor)20 InfModel (org.apache.jena.rdf.model.InfModel)20 Node (org.apache.jena.graph.Node)19 Statement (org.apache.jena.rdf.model.Statement)18 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)15 Reader (java.io.Reader)14 JsonString (org.apache.jena.atlas.json.JsonString)14 AbstractFusekiTest (org.apache.jena.fuseki.AbstractFusekiTest)14 FusekiTest (org.apache.jena.fuseki.FusekiTest)14 Graph (org.apache.jena.graph.Graph)14 JenaException (org.apache.jena.shared.JenaException)14 Triple (org.apache.jena.graph.Triple)13