Search in sources :

Example 51 with Model

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

the class TestDatasetWithLuceneTextIndexWithLangField method before.

@Before
public void before() {
    Reader reader = new StringReader(SPEC);
    Model specModel = ModelFactory.createDefaultModel();
    specModel.read(reader, "", "TURTLE");
    TextAssembler.init();
    Resource root = specModel.getResource(SPEC_ROOT_URI);
    dataset = (Dataset) Assembler.general.open(root);
}
Also used : StringReader(java.io.StringReader) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Reader(java.io.Reader) StringReader(java.io.StringReader) Before(org.junit.Before)

Example 52 with Model

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

the class StageAltMain method makeData.

private static Model makeData() {
    Model model = ModelFactory.createDefaultModel();
    Resource r = model.createResource(NS + "r");
    Property p1 = model.createProperty(NS + "p1");
    Property p2 = model.createProperty(NS + "p2");
    model.add(r, p1, "xyz");
    model.add(r, p2, "abc");
    return model;
}
Also used : Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Example 53 with Model

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

the class LocationMapper method toModel.

public Model toModel() {
    Model m = ModelFactory.createDefaultModel();
    m.setNsPrefix("lmap", "http://jena.hpl.hp.com/2004/08/location-mapping#");
    toModel(m);
    return m;
}
Also used : Model(org.apache.jena.rdf.model.Model)

Example 54 with Model

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

the class TestLangRdfJson method rdfjson_read_objectlist_uris.

@Test
public void rdfjson_read_objectlist_uris() {
    String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } , { \"type\" : \"uri\" , \"value\" : \"http://example.org/object2\" } ] } }";
    String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n" + "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object2> .";
    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 55 with Model

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

the class TestLangTurtle method optionalDotInBase.

@Test
public void optionalDotInBase() {
    Model model = ModelFactory.createDefaultModel();
    StringReader reader = new StringReader("@base <http://example/> <x> <p> <o> .");
    RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE);
    assertEquals(1, model.size());
    Resource r = model.createResource("http://example/x");
    Property p = model.createProperty("http://example/p");
    assertTrue(model.contains(r, p));
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property) 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