Search in sources :

Example 1 with AssemblerGroup

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")));
}
Also used : Mode(org.apache.jena.assembler.Mode) Resource(org.apache.jena.rdf.model.Resource) ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup) Assembler(org.apache.jena.assembler.Assembler) InfModelAssembler(org.apache.jena.assembler.assemblers.InfModelAssembler) AssemblerBase(org.apache.jena.assembler.assemblers.AssemblerBase)

Example 2 with AssemblerGroup

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));
}
Also used : ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) InfModel(org.apache.jena.rdf.model.InfModel) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup)

Example 3 with AssemblerGroup

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));
}
Also used : Resource(org.apache.jena.rdf.model.Resource) ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup)

Example 4 with AssemblerGroup

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");
}
Also used : ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup)

Example 5 with AssemblerGroup

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);
}
Also used : Resource(org.apache.jena.rdf.model.Resource) ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup)

Aggregations

AssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup)9 ExpandingAssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup)9 Resource (org.apache.jena.rdf.model.Resource)4 InfModelAssembler (org.apache.jena.assembler.assemblers.InfModelAssembler)2 InfModel (org.apache.jena.rdf.model.InfModel)2 Assembler (org.apache.jena.assembler.Assembler)1 Mode (org.apache.jena.assembler.Mode)1 AssemblerBase (org.apache.jena.assembler.assemblers.AssemblerBase)1 Model (org.apache.jena.rdf.model.Model)1