Search in sources :

Example 16 with ContractTest

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

Example 17 with ContractTest

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

Example 18 with ContractTest

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

Example 19 with ContractTest

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

Example 20 with ContractTest

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));
}
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