use of org.apache.jena.graph.Triple in project jena by apache.
the class TestParserFactory method turtle_01.
@Test
public void turtle_01() {
// Verify the excected outoput works.
{
String s = "<x> <p> <q> .";
CatchParserOutput sink = parseCapture(s, Lang.TTL);
assertEquals(1, sink.startCalled);
assertEquals(1, sink.finishCalled);
assertEquals(1, sink.triples.size());
assertEquals(0, sink.quads.size());
Triple t = SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)");
assertEquals(t, last(sink.triples));
}
// Old style, deprecated.
Tokenizer tokenizer = TokenizerFactory.makeTokenizerString("<x> <p> <q> .");
CatchParserOutput sink = new CatchParserOutput();
ParserProfile maker = makeParserProfile(IRIResolver.create("http://base/"), null, true);
LangRIOT parser = RiotParsers.createParserTurtle(tokenizer, sink, maker);
parser.parse();
assertEquals(1, sink.startCalled);
assertEquals(1, sink.finishCalled);
assertEquals(1, sink.triples.size());
assertEquals(0, sink.quads.size());
assertEquals(SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)"), last(sink.triples));
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class TestLangTrig method trig_11.
@Test
public void trig_11() {
DatasetGraph dsg = parse("@prefix ex: <http://example/> .", "{ ex:s ex:p 123 }");
assertEquals(1, dsg.getDefaultGraph().size());
Triple t = dsg.getDefaultGraph().find(null, null, null).next();
Triple t2 = SSE.parseTriple("(<http://example/s> <http://example/p> 123)");
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class TestLangTrig method trig_10.
// Need to check we get resolved URIs.
//{ parse("{ <x> <p> <q> }") ; }
@Test
public //{ parse("{ <x> <p> <q> }") ; }
void trig_10() {
DatasetGraph dsg = parse("{ <x> <p> <q> }");
assertEquals(1, dsg.getDefaultGraph().size());
Triple t = dsg.getDefaultGraph().find(null, null, null).next();
Triple t2 = SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)");
assertEquals(t2, t);
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class TestGraphsDataBag method delete_1.
@Test(expected = DeleteDeniedException.class)
public void delete_1() {
Triple t = SSE.parseTriple("(<x> <p> 'ZZZ')");
distinct.add(t);
distinct.delete(t);
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class TestLPBRuleEngine method testTabledGoalsLeak.
@Test
public void testTabledGoalsLeak() throws Exception {
Graph data = Factory.createGraphMem();
data.add(new Triple(a, ty, C1));
List<Rule> rules = Rule.parseRules("[r1: (?x p ?t) <- (?x rdf:type C1), makeInstance(?x, p, C2, ?t)]" + "[r2: (?t rdf:type C2) <- (?x rdf:type C1), makeInstance(?x, p, C2, ?t)]");
FBRuleInfGraph infgraph = (FBRuleInfGraph) createReasoner(rules).bind(data);
LPBRuleEngine engine = getEngineForGraph(infgraph);
assertEquals(0, engine.activeInterpreters.size());
assertEquals(0, engine.tabledGoals.size());
ExtendedIterator<Triple> it = infgraph.find(a, ty, C1);
it.close();
// how many were cached
assertEquals(1, engine.tabledGoals.size());
// and no leaks of activeInterpreters
assertEquals(0, engine.activeInterpreters.size());
// Now ask again:
it = infgraph.find(a, ty, C1);
it.close();
// if it was a cache hit, no change here:
assertEquals(1, engine.tabledGoals.size());
assertEquals(0, engine.activeInterpreters.size());
//the cached generator should not have any consumingCP left
for (Generator generator : engine.tabledGoals.asMap().values()) {
assertEquals(0, generator.consumingCPs.size());
}
}
Aggregations