Search in sources :

Example 96 with Graph

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

the class AbstractTestGraphMaker 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]. 
    */
public void testListThreeGraphs() {
    String x = "x", y = "y/sub", z = "z:boo";
    Graph X = gf.createGraph(x);
    Graph Y = gf.createGraph(y);
    Graph Z = gf.createGraph(z);
    Set<String> wanted = setOfStrings(x + " " + y + " " + z);
    assertEquals(wanted, iteratorToSet(gf.listGraphs()));
    X.close();
    Y.close();
    Z.close();
}
Also used : Graph(org.apache.jena.graph.Graph)

Example 97 with Graph

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

the class TestContains method testModelComContainsSPcallsContainsSPO.

public void testModelComContainsSPcallsContainsSPO() {
    final Graph g = Factory.createDefaultGraph();
    final boolean[] wasCalled = { false };
    // FIXME change to dynamic proxy
    final Model m = new ModelCom(g) {

        @Override
        public boolean contains(final Resource s, final Property p, final RDFNode o) {
            wasCalled[0] = true;
            return super.contains(s, p, o);
        }
    };
    Assert.assertFalse(m.contains(ModelHelper.resource("r"), ModelHelper.property("p")));
    Assert.assertTrue("contains(S,P) should call contains(S,P,O)", wasCalled[0]);
}
Also used : Graph(org.apache.jena.graph.Graph) ModelCom(org.apache.jena.rdf.model.impl.ModelCom)

Example 98 with Graph

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

the class TestModelPrefixMapping method doOnlyFreshPrefixes.

/**
	 * Test that existing prefixes are not over-ridden by the default ones.
	 */
private void doOnlyFreshPrefixes() {
    final String newURI = "abc:def/";
    final Graph g = Factory.createDefaultGraph();
    final PrefixMapping pm = g.getPrefixMapping();
    pm.setNsPrefix(TestModelPrefixMapping.alphaPrefix, newURI);
    final Model m = ModelFactory.createModelForGraph(g);
    Assert.assertEquals(newURI, m.getNsPrefixURI(TestModelPrefixMapping.alphaPrefix));
    Assert.assertEquals(TestModelPrefixMapping.betaURI, m.getNsPrefixURI(TestModelPrefixMapping.betaPrefix));
}
Also used : AbstractTestPrefixMapping(org.apache.jena.shared.AbstractTestPrefixMapping) PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) Model(org.apache.jena.rdf.model.Model)

Example 99 with Graph

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

the class SecuredPrefixMappingTest method setup.

@Before
public void setup() {
    final Graph g = GraphFactory.createDefaultGraph();
    final SecuredGraph sg = Factory.getInstance(securityEvaluator, "http://example.com/testGraph", g);
    this.securedMapping = sg.getPrefixMapping();
}
Also used : SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph) Graph(org.apache.jena.graph.Graph) SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph) Before(org.junit.Before)

Example 100 with Graph

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

the class SecuredGraphListenerTest method getGraph.

@Override
public Graph getGraph() {
    final Graph graph = org.apache.jena.permissions.Factory.getInstance(eval, getName(), Factory.createDefaultGraph());
    graph.getEventManager().register(new CheckChanges("simple tracking", graph));
    return graph;
}
Also used : Graph(org.apache.jena.graph.Graph)

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