Search in sources :

Example 1 with DocumentManagerAssembler

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

the class TestDocumentManagerAssembler method testCreatesDocumentManager.

public void testCreatesDocumentManager() {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager");
    Assembler a = new DocumentManagerAssembler();
    Object x = a.open(root);
    assertInstanceOf(OntDocumentManager.class, x);
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Example 2 with DocumentManagerAssembler

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

the class TestDocumentManagerAssembler method testTrapsBadPolicyPath.

private void testTrapsBadPolicyPath(String path) {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:policyPath <policy>".replaceAll("<policy>", path));
    Assembler a = new DocumentManagerAssembler();
    try {
        a.open(root);
        fail("should trap illegal policy path object " + path);
    } catch (BadObjectException e) {
        assertEquals(resource("x"), e.getRoot());
        assertEquals(rdfNode(root.getModel(), path), e.getObject());
    }
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Example 3 with DocumentManagerAssembler

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

the class TestDocumentManagerAssembler method testSetsMetadata.

public void testSetsMetadata() {
    // we set policyPath to avoid Ont default models being thrown at us
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:policyPath ''; x P a; a Q b; y R z");
    final Model expected = model("x rdf:type ja:DocumentManager; x ja:policyPath ''; x P a; a Q b");
    final List<String> history = new ArrayList<>();
    Assembler a = new DocumentManagerAssembler() {

        @Override
        protected OntDocumentManager createDocumentManager() {
            return new OntDocumentManager("") {

                @Override
                public void processMetadata(Model m) {
                    assertIsoModels(expected, m);
                    history.add("called");
                    super.processMetadata(m);
                }
            };
        }
    };
    OntDocumentManager d = (OntDocumentManager) a.open(root);
    assertEquals(listOfOne("called"), history);
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) OntDocumentManager(org.apache.jena.ontology.OntDocumentManager) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Example 4 with DocumentManagerAssembler

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

the class TestDocumentManagerAssembler method testSetsPolicyPath.

public void testSetsPolicyPath() {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:policyPath 'somePath'");
    final List<String> history = new ArrayList<>();
    Assembler a = new DocumentManagerAssembler() {

        @Override
        protected OntDocumentManager createDocumentManager() {
            return new OntDocumentManager("") {

                @Override
                public void setMetadataSearchPath(String path, boolean replace) {
                    assertEquals(false, replace);
                    history.add(path);
                    super.setMetadataSearchPath(path, replace);
                }
            };
        }
    };
    OntDocumentManager d = (OntDocumentManager) a.open(root);
    assertEquals(listOfOne("somePath"), history);
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) OntDocumentManager(org.apache.jena.ontology.OntDocumentManager) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Example 5 with DocumentManagerAssembler

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

the class TestDocumentManagerAssembler method testUsesFileManager.

public void testUsesFileManager() {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:fileManager f");
    Assembler a = new DocumentManagerAssembler();
    FileManager fm = new FileManager();
    Assembler mock = new NamedObjectAssembler(resource("f"), fm);
    Object x = a.open(mock, root);
    assertInstanceOf(OntDocumentManager.class, x);
    assertSame(fm, ((OntDocumentManager) x).getFileManager());
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) FileManager(org.apache.jena.util.FileManager)

Aggregations

DocumentManagerAssembler (org.apache.jena.assembler.assemblers.DocumentManagerAssembler)5 OntDocumentManager (org.apache.jena.ontology.OntDocumentManager)2 FileManager (org.apache.jena.util.FileManager)1