Search in sources :

Example 11 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testSingleExternalContent.

public void testSingleExternalContent() {
    Assembler a = new ContentAssembler();
    String source = Testing + "/schema.n3";
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:ExternalContent; x ja:externalContent file:" + source);
    Content c = (Content) a.open(root);
    assertIsoModels(FileManager.get().loadModel("file:" + source), c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 12 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testTrapsBadEncodings.

public void testTrapsBadEncodings() {
    Assembler a = new ContentAssembler();
    Resource root = resourceInModel("x rdf:type ja:Content; x ja:contentEncoding 'bogus'; x ja:literalContent 'sham'");
    try {
        a.open(root);
        fail("should trap bad encoding");
    } catch (UnknownEncodingException e) {
        assertEquals("bogus", e.getEncoding());
        assertEquals(resource("x"), e.getRoot());
    }
}
Also used : UnknownEncodingException(org.apache.jena.assembler.exceptions.UnknownEncodingException) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 13 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testIndirectContent.

public void testIndirectContent() {
    Assembler a = new ContentAssembler();
    Resource root = resourceInModel("x rdf:type ja:Content; x ja:content y" + "; y rdf:type ja:Content; y ja:content z" + "; z rdf:type ja:Content; z ja:quotedContent A; A P B");
    Content c = (Content) a.open(root);
    Model wanted = model("A P B");
    assertIsoModels(wanted, c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 14 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testMultipleExternalContent.

public void testMultipleExternalContent() {
    Assembler a = new ContentAssembler();
    String sourceA = Testing + "/schema.n3";
    String sourceB = Testing + "/schema2.n3";
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:ExternalContent" + "; x ja:externalContent file:" + sourceA + "; x ja:externalContent file:" + sourceB);
    Content c = (Content) a.open(root);
    Model wanted = FileManager.get().loadModel("file:" + sourceA).add(FileManager.get().loadModel("file:" + sourceB));
    assertIsoModels(wanted, c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 15 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testContentLoadsPrefixMappings.

public void testContentLoadsPrefixMappings() {
    Assembler a = new ContentAssembler();
    String content = "@prefix foo: <eh:/foo#>. <eh:/eggs> rdf:type rdf:Property.".replaceAll(" ", "\\\\s");
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + content + "'");
    Content c = (Content) a.open(root);
    Model m = ModelFactory.createDefaultModel();
    c.fill(m);
    assertEquals("eh:/foo#", m.getNsPrefixURI("foo"));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Aggregations

ContentAssembler (org.apache.jena.assembler.assemblers.ContentAssembler)16 UnknownEncodingException (org.apache.jena.assembler.exceptions.UnknownEncodingException)1 Model (org.apache.jena.rdf.model.Model)1 Resource (org.apache.jena.rdf.model.Resource)1