@Test
public void testTabledGoalsCacheHits() 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);
	while (it.hasNext()) {
		it.next();
		// FIXME: Why do I need to consume all from the iterator
		// to avoid leaking activeInterpreters? Calling .close()
		// below should have been enough.
	}
	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);
	while (it.hasNext()) {
		it.next();
	}
	it.close();
	// if it was a cache hit, no change here:
	assertEquals(1, engine.tabledGoals.size());
	assertEquals(0, engine.activeInterpreters.size());
}