Search in sources :

Example 6 with ContentAssembler

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

the class TestContentAssembler method testUsesSuppliedFileManager.

public void testUsesSuppliedFileManager() {
    final boolean[] used = { false };
    FileManager fm = new FileManager() {

        @Override
        public Model loadModel(String filenameOrURI) {
            used[0] = true;
            return FileManager.get().loadModel(filenameOrURI);
        }
    };
    Assembler a = new ContentAssembler(fm);
    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("")));
    assertTrue("the supplied file manager must have been used", used[0]);
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 7 with ContentAssembler

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

the class TestContentAssembler method testMultipleContentQuotation.

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

Example 8 with ContentAssembler

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

the class TestContentAssembler method testStringContent.

protected void testStringContent(String expected, String n3) {
    Assembler a = new ContentAssembler();
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + n3.replaceAll(" ", "\\\\s") + "'");
    Content c = (Content) a.open(root);
    Model m = ModelFactory.createDefaultModel();
    c.fill(m);
    assertIsoModels(model(expected), m);
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 9 with ContentAssembler

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

the class TestContentAssembler method testMixedContent.

public void testMixedContent() {
    Assembler a = new ContentAssembler();
    String source = Testing + "/schema.n3";
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:LiteralContent; x rdf:type ja:ExternalContent" + "; x ja:literalContent '<eh:/eggs>\\srdf:type\\srdf:Property.'" + "; x ja:externalContent file:" + source);
    Content c = (Content) a.open(root);
    Model wanted = FileManager.get().loadModel("file:" + source).add(model("eggs rdf:type rdf:Property"));
    assertIsoModels(wanted, c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 10 with ContentAssembler

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

the class TestContentAssembler method testContentAssemblerUsesFileManagerProperty.

public void testContentAssemblerUsesFileManagerProperty() {
    Model expected = model("a P b");
    String fileName = "file:spoo";
    FixedFileManager fm = new FixedFileManager(expected, fileName);
    NamedObjectAssembler noa = new NamedObjectAssembler(resource("F"), fm);
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:ExternalContent; x ja:externalContent <F>; x ja:fileManager F".replaceAll("<F>", fileName));
    Assembler a = new ContentAssembler();
    Content c = (Content) a.open(noa, root);
    assertTrue(fm.wasUsed());
    assertIsoModels(expected, c.fill(model()));
}
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