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);
}
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());
}
}
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);
}
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);
}
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());
}
Aggregations