use of org.apache.jena.assembler.assemblers.AssemblerGroup in project jena by apache.
the class TestAssemblerGroup method testPassesSelfIn.
public void testPassesSelfIn() {
final AssemblerGroup group = AssemblerGroup.create();
final Object result = new Object();
Assembler fake = new AssemblerBase() {
@Override
public Object open(Assembler a, Resource root, Mode irrelevant) {
assertSame("nested call should pass in assembler group:", group, a);
return result;
}
};
group.implementWith(JA.Object, fake);
assertSame(result, group.open(resourceInModel("x rdf:type ja:Object")));
}
use of org.apache.jena.assembler.assemblers.AssemblerGroup in project jena by apache.
the class TestAssemblerGroup method testAddingImplAddsSubclass.
public void testAddingImplAddsSubclass() {
final Model[] fullModel = new Model[1];
AssemblerGroup g = new AssemblerGroup.ExpandingAssemblerGroup() {
@Override
public void loadClasses(Model full) {
fullModel[0] = full;
}
};
Resource root = resourceInModel("root rdf:type typeA");
Resource typeA = resource("typeA"), typeB = resource("typeB");
g.implementWith(typeA, mockAssembler);
g.implementWith(typeB, mockAssembler);
g.open(root);
assertTrue(fullModel[0].contains(typeA, RDFS.subClassOf, JA.Object));
assertTrue(fullModel[0].contains(typeB, RDFS.subClassOf, JA.Object));
}
use of org.apache.jena.assembler.assemblers.AssemblerGroup in project jena by apache.
the class TestAssemblerGroup method testImpliedType.
public void testImpliedType() {
AssemblerGroup a = AssemblerGroup.create();
Resource root = resourceInModel("x ja:reasoner y");
Object expected = new Object();
a.implementWith(JA.InfModel, new NamedObjectAssembler(resource("x"), expected));
assertSame(expected, a.open(root));
}
use of org.apache.jena.assembler.assemblers.AssemblerGroup in project jena by apache.
the class TestAssemblerGroup method testSingletonAssemblerGroup.
public void testSingletonAssemblerGroup() {
AssemblerGroup a = AssemblerGroup.create();
assertSame(a, a.implementWith(JA.InfModel, Assembler.infModel));
a.openModel(resourceInModel("x rdf:type ja:InfModel"));
checkFailsType(a, "js:DefaultModel");
}
use of org.apache.jena.assembler.assemblers.AssemblerGroup in project jena by apache.
the class TestAssemblerGroup method testLoadsClasses.
public void testLoadsClasses() {
AssemblerGroup a = AssemblerGroup.create();
a.implementWith(resource("T"), new MockAssembler());
Resource root = resourceInModel("x rdf:type T; _c ja:loadClass '" + TestAssemblerGroup.class.getName() + "$Trivial'");
// In case already loaded.
loaded = false;
assertFalse("something has pre-loaded Trivial, so we can't test if it gets loaded", loaded);
assertEquals("mockmockmock", a.open(root));
assertTrue("the assembler group did not obey the ja:loadClass directive", loaded);
}
Aggregations