@BeforeClass public static void init() throws EngineException { // Graph.setCompareIndex(true); QuerySolver.definePrefix("c", "http://www.inria.fr/acacia/comma#"); graph = createGraph(true); Load load = Load.create(graph); load.load(data + "engine/ontology/test.rdfs"); load.load(data + "engine/data/test.rdf"); try { load.loadWE(data + "engine/rule/test2.brul"); load.load(new FileInputStream(data + "engine/rule/meta.brul"), "meta.brul"); } catch (LoadException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } fengine = load.getRuleEngine(); fengine.setSpeedUp(true); QueryProcess exec = QueryProcess.create(graph); rengine = Engine.create(exec); rengine.load(data + "engine/rule/test2.brul"); rengine.load(data + "engine/rule/meta.brul"); }
/** Rule engine with QueryExec on two graphs */ @Test public void test6() { QuerySolver.definePrefix("c", "http://www.inria.fr/acacia/comma#"); Graph g1 = createGraph(true); Graph g2 = createGraph(true); Load load1 = Load.create(g1); Load load2 = Load.create(g2); load1.load(data + "engine/ontology/test.rdfs"); load2.load(data + "engine/data/test.rdf"); QueryProcess exec = QueryProcess.create(g1); exec.add(g2); RuleEngine re = RuleEngine.create(g2, exec); // re.setOptimize(true); load2.setEngine(re); try { load2.loadWE(data + "engine/rule/test2.brul"); load2.load(new FileInputStream(data + "engine/rule/meta.brul"), "meta.brul"); } catch (LoadException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Engine rengine = Engine.create(exec); rengine.load(data + "engine/rule/test2.brul"); rengine.load(data + "engine/rule/meta.brul"); String query = "prefix c: <http://www.inria.fr/acacia/comma#>" + "select * where {" + "?x c:hasGrandParent c:Pierre " + "}"; LBind bind = rengine.SPARQLProve(query); assertEquals("Result", 4, bind.size()); // System.out.println(bind); re.process(); try { Mappings map = exec.query(query); assertEquals("Result", 4, map.size()); // System.out.println(map); } catch (EngineException e) { assertEquals("Result", 4, e); } }