Search in sources :

Example 96 with ContractTest

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

Example 97 with ContractTest

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

Example 98 with ContractTest

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

Example 99 with ContractTest

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

Example 100 with ContractTest

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