use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphMakerContractTest method testListThreeGraphs.
/**
* Test that a maker with three graphs inserted lists those three grapsh; we
* don't mind what order they appear in. We also use funny names to ensure
* that the spelling that goes in is the one that comes out [should really
* be in a separate test].
*/
@ContractTest
public void testListThreeGraphs() {
String x = "x", y = "y/sub", z = "z:boo";
Graph X = graphMaker.createGraph(x);
Graph Y = graphMaker.createGraph(y);
Graph Z = graphMaker.createGraph(z);
Set<String> wanted = TestUtils.setOfStrings(x + " " + y + " " + z);
assertEquals(wanted, GraphHelper.iteratorToSet(graphMaker.listGraphs()));
X.close();
Y.close();
Z.close();
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphWithPerformContractTest method testPerformAdd_Triple.
@ContractTest
public void testPerformAdd_Triple() {
GraphWithPerform g = (GraphWithPerform) graphWith(producer.newInstance(), "S P O; S2 P2 O2");
g.getEventManager().register(GL);
txnBegin(g);
g.performAdd(triple("S3 P3 O3"));
txnCommit(g);
GL.assertEmpty();
assertTrue(g.contains(triple("S3 P3 O3")));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphWithPerformContractTest method testPerformDelete_Triple.
@ContractTest
public void testPerformDelete_Triple() {
GraphWithPerform g = (GraphWithPerform) graphWith(producer.newInstance(), "S P O; S2 P2 O2");
g.getEventManager().register(GL);
txnBegin(g);
g.performDelete(triple("S2 P2 O2"));
txnCommit(g);
GL.assertEmpty();
assertFalse(g.contains(triple("S2 P2 O2")));
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testBrokenSubject.
@ContractTest
public void testBrokenSubject() {
Graph g = graphWith(producer.newInstance(), "x brokenSubject y");
try {
ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY, Node.ANY);
it.removeNext();
assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
} catch (UnsupportedOperationException e) {
// No Iterator.remove
}
}
use of org.xenei.junit.contract.ContractTest in project jena by apache.
the class GraphContractTest method testBrokenObject.
@ContractTest
public void testBrokenObject() {
Graph g = graphWith(producer.newInstance(), "x brokenObject y");
try {
ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY, node("y"));
it.removeNext();
assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
} catch (UnsupportedOperationException e) {
// No Iterator.remove
}
}
Aggregations