Search in sources :

Example 6 with ContractTest

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();
}
Also used : Graph(org.apache.jena.graph.Graph) ContractTest(org.xenei.junit.contract.ContractTest)

Example 7 with ContractTest

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")));
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform) ContractTest(org.xenei.junit.contract.ContractTest)

Example 8 with ContractTest

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")));
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform) ContractTest(org.xenei.junit.contract.ContractTest)

Example 9 with ContractTest

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
    }
}
Also used : GraphHelper.memGraph(org.apache.jena.testing_framework.GraphHelper.memGraph) ContractTest(org.xenei.junit.contract.ContractTest)

Example 10 with ContractTest

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
    }
}
Also used : GraphHelper.memGraph(org.apache.jena.testing_framework.GraphHelper.memGraph) ContractTest(org.xenei.junit.contract.ContractTest)

Aggregations

ContractTest (org.xenei.junit.contract.ContractTest)102 GraphHelper.memGraph (org.apache.jena.testing_framework.GraphHelper.memGraph)51 Graph (org.apache.jena.graph.Graph)16 Var (org.apache.jena.sparql.core.Var)13 Query (org.apache.jena.query.Query)9 E_Random (org.apache.jena.sparql.expr.E_Random)9 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)6 DeleteDeniedException (org.apache.jena.shared.DeleteDeniedException)6 VarExprList (org.apache.jena.sparql.core.VarExprList)6 MalformedURLException (java.net.MalformedURLException)5 URISyntaxException (java.net.URISyntaxException)5 ClosedException (org.apache.jena.shared.ClosedException)5 Expr (org.apache.jena.sparql.expr.Expr)5 Triple (org.apache.jena.graph.Triple)4 PrefixMapping (org.apache.jena.shared.PrefixMapping)3 TriplePath (org.apache.jena.sparql.core.TriplePath)3 Node (org.apache.jena.graph.Node)2 TransactionHandler (org.apache.jena.graph.TransactionHandler)2 Intersection (org.apache.jena.graph.compose.Intersection)2 GraphWithPerform (org.apache.jena.graph.impl.GraphWithPerform)2