Search in sources :

Example 26 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class GraphContractTest method testFind_Node_Node_Node_MatchLanguagedLiteralCaseInsensitive.

@ContractTest
public void testFind_Node_Node_Node_MatchLanguagedLiteralCaseInsensitive() {
    Graph m = graphWith(producer.newInstance(), "a p 'chat'en");
    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 27 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class GraphContractTest method testBrokenPredicate.

@ContractTest
public void testBrokenPredicate() {
    Graph g = graphWith(producer.newInstance(), "x brokenPredicate y");
    try {
        ExtendedIterator<Triple> it = g.find(Node.ANY, node("brokenPredicate"), 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 28 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class GraphContractTest method testDependsOn.

@ContractTest
public void testDependsOn() {
    Graph g = producer.newInstance();
    Graph[] depGraphs = producer.getDependsOn(g);
    if (depGraphs != null) {
        for (Graph dg : depGraphs) {
            assertTrue(String.format("Graph %s should depend upon %s", g, dg), g.dependsOn(dg));
        }
    }
    depGraphs = producer.getNotDependsOn(g);
    if (depGraphs != null) {
        for (Graph dg : depGraphs) {
            assertFalse(String.format("Graph %s should not depend upon %s", g, dg), g.dependsOn(dg));
        }
    }
}
Also used : GraphHelper.memGraph(org.apache.jena.testing_framework.GraphHelper.memGraph) ContractTest(org.xenei.junit.contract.ContractTest)

Example 29 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class GraphContractTest method testBrokenIndexes.

@ContractTest
public void testBrokenIndexes() {
    Graph g = graphWith(producer.newInstance(), "x R y; x S z");
    try {
        ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY, Node.ANY);
        it.removeNext();
        it.removeNext();
        assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
        assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
        assertFalse(g.find(Node.ANY, Node.ANY, node("y")).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 30 with ContractTest

use of org.xenei.junit.contract.ContractTest in project jena by apache.

the class GraphContractTest method testFind_Triple_NoMatchAgainstUnlanguagesLiteral.

@ContractTest
public void testFind_Triple_NoMatchAgainstUnlanguagesLiteral() {
    Graph m = graphWith(producer.newInstance(), "a p 'chat'en; a p 'chat'");
    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(new Triple(Node.ANY, Node.ANY, chaten)).toList().size());
    assertEquals(1, m.find(new Triple(Node.ANY, Node.ANY, chatEN)).toList().size());
}
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