Search in sources :

Example 61 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestIsoMatcher method testGraph$.

private void testGraph$(String s1, String s2, boolean iso) {
    s1 = "(graph " + s1 + ")";
    s2 = "(graph " + s2 + ")";
    Graph g1 = SSE.parseGraph(s1);
    Graph g2 = SSE.parseGraph(s2);
    boolean b = IsoMatcher.isomorphic(g1, g2);
    if (b != iso) {
        System.out.println("====");
        SSE.write(g1);
        System.out.println("----");
        SSE.write(g2);
        System.out.println("Expected: " + iso + " ; got: " + b);
    }
    assertEquals(iso, b);
    // Check with the other code.
    assertEquals(b, g1.isIsomorphicWith(g2));
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph)

Example 62 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class AbstractTestGraph2 method graph_01.

@Test
public void graph_01() {
    Graph g = emptyGraph();
    assertEquals(0, g.size());
    returnGraph(g);
}
Also used : Graph(org.apache.jena.graph.Graph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 63 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class AbstractTestGraph2 method graph_add_02.

@Test
public void graph_add_02() {
    Graph g = emptyGraph();
    Triple t = triple(s1, p1, o1);
    g.add(t);
    g.add(t);
    assertEquals(1, g.size());
    assertTrue(g.contains(t));
    assertTrue(g.contains(s1, p1, o1));
    returnGraph(g);
}
Also used : Triple(org.apache.jena.graph.Triple) Graph(org.apache.jena.graph.Graph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 64 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class AbstractTestGraph2 method remove_03.

@Test
public void remove_03() {
    Graph g = emptyGraph();
    Triple t1 = triple(s1, p1, o1);
    g.add(t1);
    g.remove(s1, any, any);
    assertEquals(0, g.size());
    returnGraph(g);
}
Also used : Triple(org.apache.jena.graph.Triple) Graph(org.apache.jena.graph.Graph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 65 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class AbstractTestGraph2 method graph_add_04.

@Test
public void graph_add_04() {
    Graph g = emptyGraph();
    // Literals
    Triple t1 = triple(s1, p1, lit1);
    Triple t2 = triple(s1, p1, lit2);
    g.add(t1);
    g.add(t2);
    assertEquals(2, g.size());
    assertTrue(g.contains(t1));
    assertTrue(g.contains(t2));
    assertTrue(g.contains(s1, p1, lit1));
    assertTrue(g.contains(s1, p1, lit2));
    Node o = NodeFactoryExtra.parseNode("<ex:lex>");
    assertFalse(g.contains(s1, p1, o));
    returnGraph(g);
}
Also used : Triple(org.apache.jena.graph.Triple) Graph(org.apache.jena.graph.Graph) Node(org.apache.jena.graph.Node) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

Graph (org.apache.jena.graph.Graph)247 Test (org.junit.Test)90 BaseTest (org.apache.jena.atlas.junit.BaseTest)56 Triple (org.apache.jena.graph.Triple)56 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)54 Node (org.apache.jena.graph.Node)46 AbstractTestGraph (org.apache.jena.graph.test.AbstractTestGraph)16 InfGraph (org.apache.jena.reasoner.InfGraph)16 ContractTest (org.xenei.junit.contract.ContractTest)16 Model (org.apache.jena.rdf.model.Model)14 MultiUnion (org.apache.jena.graph.compose.MultiUnion)9 Delta (org.apache.jena.graph.compose.Delta)8 BuilderGraph (org.apache.jena.sparql.sse.builders.BuilderGraph)8 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 PrefixMapping (org.apache.jena.shared.PrefixMapping)7 GraphUnionRead (org.apache.jena.sparql.graph.GraphUnionRead)7 IOException (java.io.IOException)6 Dataset (org.apache.jena.query.Dataset)6 Rule (org.apache.jena.reasoner.rulesys.Rule)6 ConfigTest (org.apache.jena.tdb.ConfigTest)6