use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testSingletonStatisticsWithSingleTriple.
@ContractTest
public void testSingletonStatisticsWithSingleTriple() {
Graph g = graphWith(producer.newInstance(), "a P b");
GraphStatisticsHandler h = g.getStatisticsHandler();
if (h != null) {
assertEquals(1L, h.getStatistic(node("a"), Node.ANY, Node.ANY));
assertEquals(0L, h.getStatistic(node("x"), Node.ANY, Node.ANY));
//
assertEquals(1L, h.getStatistic(Node.ANY, node("P"), Node.ANY));
assertEquals(0L, h.getStatistic(Node.ANY, node("Q"), Node.ANY));
//
assertEquals(1L, h.getStatistic(Node.ANY, Node.ANY, node("b")));
assertEquals(0L, h.getStatistic(Node.ANY, Node.ANY, node("y")));
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testQuadRemove.
@ContractTest
public void testQuadRemove() {
Graph g = producer.newInstance();
assertEquals(0, g.size());
Triple s = triple("x rdf:subject s");
Triple p = triple("x rdf:predicate p");
Triple o = triple("x rdf:object o");
Triple t = triple("x rdf:type rdf:Statement");
txnBegin(g);
g.add(s);
g.add(p);
g.add(o);
g.add(t);
txnCommit(g);
assertEquals(4, g.size());
txnBegin(g);
g.delete(s);
g.delete(p);
g.delete(o);
g.delete(t);
txnCommit(g);
assertEquals(0, g.size());
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testGetTransactionHandler.
@ContractTest
public void testGetTransactionHandler() {
Graph g = producer.newInstance();
assertNotNull("Must return a Transaction handler", g.getTransactionHandler());
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testFind_Node_Node_Node_NoMatchAgainstUnlanguagesLiteral.
@ContractTest
public void testFind_Node_Node_Node_NoMatchAgainstUnlanguagesLiteral() {
Graph m = graphWith(producer.newInstance(), "a p 'chat'en; a p 'chat'");
if (m.getCapabilities().handlesLiteralTyping()) {
Node chaten = node("'chat'en"), chatEN = node("'chat'EN");
assertDiffer(chaten, chatEN);
assertTrue(chaten.sameValueAs(chatEN));
assertEquals(chaten.getIndexingValue(), chatEN.getIndexingValue());
assertEquals(1, m.find(Node.ANY, Node.ANY, chaten).toList().size());
assertEquals(1, m.find(Node.ANY, Node.ANY, chatEN).toList().size());
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class IntersectionTest method testIntersection.
@ContractTest
public void testIntersection() {
Graph g1 = graphWith("x R y; p R q");
Graph g2 = graphWith("r Foo s; x R y");
Intersection i = new Intersection(g1, g2);
assertContains("Intersection", "x R y", i);
assertOmits("Intersection", i, "p R q");
assertOmits("Intersection", i, "r Foo s");
if (i.size() != 1)
fail("oops: size of intersection is not 1");
i.add(triple("cats eat cheese"));
assertContains("Intersection.L", "cats eat cheese", g1);
assertContains("Intersection.R", "cats eat cheese", g2);
}
Aggregations