use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class DifferenceTest method testDifference.
@ContractTest
public void testDifference() {
Graph g1 = graphWith("x R y; p R q");
Graph g2 = graphWith("r Foo s; x R y");
Graph d = new Difference(g1, g2);
assertOmits("Difference", d, "x R y");
assertContains("Difference", "p R q", d);
assertOmits("Difference", d, "r Foo s");
if (d.size() != 1)
fail("oops: size of difference is not 1");
d.add(triple("cats eat cheese"));
assertContains("Difference.L", "cats eat cheese", g1);
assertOmits("Difference.R", g2, "cats eat cheese");
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testTransactionHandler_Abort.
@ContractTest
public void testTransactionHandler_Abort() {
Graph g = producer.newInstance();
if (g.getTransactionHandler().transactionsSupported()) {
Graph initial = graphWith(producer.newInstance(), "initial hasValue 42; also hasURI hello");
Graph extra = graphWith(producer.newInstance(), "extra hasValue 17; also hasURI world");
GraphUtil.addInto(g, initial);
g.getTransactionHandler().begin();
GraphUtil.addInto(g, extra);
g.getTransactionHandler().abort();
assertIsomorphic(initial, g);
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class IntersectionTest method testDeleteDoesNotUpdateR.
@ContractTest
public void testDeleteDoesNotUpdateR() {
Graph L = graphWith("a pings b; b pings c; c pings a");
Graph R = graphWith("c pings a; b pings c; x captures y");
Graph join = new Intersection(L, R);
GraphUtil.deleteFrom(L, R);
assertIsomorphic("R should not change", graphWith("c pings a; b pings c; x captures y"), R);
assertIsomorphic(graphWith("a pings b"), L);
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testGetStatisticsHandler.
@ContractTest
public void testGetStatisticsHandler() {
Graph g = producer.newInstance();
GraphStatisticsHandler sh = g.getStatisticsHandler();
if (sh != null) {
assertSame("getStatisticsHandler must always return the same object", sh, g.getStatisticsHandler());
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testIsIsomorphicWith_Graph.
@ContractTest
public void testIsIsomorphicWith_Graph() {
Graph graph = producer.newInstance();
Graph g2 = memGraph();
assertTrue("Empty graphs should be isomorphic", graph.isIsomorphicWith(g2));
graph = graphWith(producer.newInstance(), "S P O; S2 P2 O2; S3 P3 O3");
g2 = graphWith("S3 P3 O3; S2 P2 O2; S P O");
assertTrue("Should be isomorphic", graph.isIsomorphicWith(g2));
txnBegin(graph);
graph.add(triple("_1, P4 S4"));
txnCommit(graph);
txnBegin(g2);
g2.add(triple("_2, P4 S4"));
txnCommit(g2);
assertTrue("Should be isomorphic after adding anonymous nodes", graph.isIsomorphicWith(g2));
txnBegin(graph);
graph.add(triple("_1, P3 S4"));
txnCommit(graph);
txnBegin(g2);
g2.add(triple("_2, P4 S4"));
txnCommit(g2);
assertFalse("Should not be isomorphic", graph.isIsomorphicWith(g2));
}
Aggregations