Search in sources :

Example 6 with RDFLink

use of org.apache.jena.rdflink.RDFLink in project jena by apache.

the class TestService method service_query_bad_no_dataset.

@Test(expected = QueryExceptionHTTP.class)
public void service_query_bad_no_dataset() {
    DatasetGraph dsg = env.dsg();
    dsg.executeWrite(() -> dsg.add(SSE.parseQuad("(_ :s :p :o)")));
    // Not a dataset of the server
    String queryString = "SELECT * { SERVICE <" + env.serverPath("JUNK") + "> { ?s ?p ?o }} ";
    // Connect to local, unused, permanently empty dataset
    try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
        try (QueryExec qExec = link.query(queryString)) {
            // Where it should go wrong.
            RowSet rs = qExec.select();
            // Should go on execution.
            rs.hasNext();
            fail("Should not get here");
        }
    }
}
Also used : QueryExec(org.apache.jena.sparql.exec.QueryExec) RowSet(org.apache.jena.sparql.exec.RowSet) RDFLink(org.apache.jena.rdflink.RDFLink) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) EnvTest(org.apache.jena.test.conn.EnvTest) Test(org.junit.Test)

Example 7 with RDFLink

use of org.apache.jena.rdflink.RDFLink in project jena by apache.

the class TestService method service_query_extra_params.

@Test
public void service_query_extra_params() {
    String queryString = "ASK { SERVICE <" + SERVICE + "?format=json> { BIND(now() AS ?now) } }";
    try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
        boolean b = link.queryAsk(queryString);
        assertTrue(b);
    }
}
Also used : RDFLink(org.apache.jena.rdflink.RDFLink) EnvTest(org.apache.jena.test.conn.EnvTest) Test(org.junit.Test)

Example 8 with RDFLink

use of org.apache.jena.rdflink.RDFLink in project jena by apache.

the class TestService method service_query_silent_nosite.

@Test
public void service_query_silent_nosite() {
    logOnlyErrors(QueryIterService.class, () -> {
        DatasetGraph dsg = env.dsg();
        String queryString = "SELECT * { SERVICE SILENT <http://nosuchsite/> { VALUES ?X { 1 2 } }} ";
        try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
            try (QueryExec qExec = link.query(queryString)) {
                RowSet rs = qExec.select();
                assertTrue(rs.hasNext());
                Binding binding = rs.next();
                assertFalse(rs.hasNext());
                assertTrue(binding.isEmpty());
            }
        }
    });
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryExec(org.apache.jena.sparql.exec.QueryExec) RowSet(org.apache.jena.sparql.exec.RowSet) RDFLink(org.apache.jena.rdflink.RDFLink) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) EnvTest(org.apache.jena.test.conn.EnvTest) Test(org.junit.Test)

Example 9 with RDFLink

use of org.apache.jena.rdflink.RDFLink in project jena by apache.

the class TestAuthRemote method auth_link_good_auth_1.

@Test
public void auth_link_good_auth_1() {
    try (RDFLink link = RDFLinkHTTP.newBuilder().destination(env.datasetURL()).httpClient(env.httpClientAuthGood()).build()) {
        link.queryAsk("ASK{}");
        link.update("INSERT DATA { <x:s> <x:p> <x:o> }");
        Graph graph = link.get();
        assertNotNull(graph);
        DatasetGraph dsg = link.getDataset();
        assertNotNull(dsg);
    }
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) RDFLink(org.apache.jena.rdflink.RDFLink) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) EnvTest(org.apache.jena.test.conn.EnvTest) Test(org.junit.Test)

Example 10 with RDFLink

use of org.apache.jena.rdflink.RDFLink in project jena by apache.

the class TestService method service_query_silent_no_service.

@Test
public void service_query_silent_no_service() {
    logOnlyErrors(QueryIterService.class, () -> {
        DatasetGraph dsg = env.dsg();
        String queryString = "SELECT * { SERVICE SILENT <" + SERVICE + "JUNK> { VALUES ?X { 1 2 } }} ";
        try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
            try (QueryExec qExec = link.query(queryString)) {
                RowSet rs = qExec.select();
                assertTrue(rs.hasNext());
                Binding binding = rs.next();
                assertFalse(rs.hasNext());
                assertTrue(binding.isEmpty());
            }
        }
    });
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryExec(org.apache.jena.sparql.exec.QueryExec) RowSet(org.apache.jena.sparql.exec.RowSet) RDFLink(org.apache.jena.rdflink.RDFLink) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) EnvTest(org.apache.jena.test.conn.EnvTest) Test(org.junit.Test)

Aggregations

RDFLink (org.apache.jena.rdflink.RDFLink)14 Test (org.junit.Test)13 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)12 EnvTest (org.apache.jena.test.conn.EnvTest)12 QueryExec (org.apache.jena.sparql.exec.QueryExec)8 RowSet (org.apache.jena.sparql.exec.RowSet)7 HttpRequestModifier (org.apache.jena.http.sys.HttpRequestModifier)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Graph (org.apache.jena.graph.Graph)2 RegistryRequestModifier (org.apache.jena.http.sys.RegistryRequestModifier)2 RDFLinkHTTP (org.apache.jena.rdflink.RDFLinkHTTP)2 DatasetGraphFactory (org.apache.jena.sparql.core.DatasetGraphFactory)2 Binding (org.apache.jena.sparql.engine.binding.Binding)2 GSP (org.apache.jena.sparql.exec.http.GSP)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 FusekiServer (org.apache.jena.fuseki.main.FusekiServer)1 FusekiLogging (org.apache.jena.fuseki.system.FusekiLogging)1 HttpTest.expect401 (org.apache.jena.fuseki.test.HttpTest.expect401)1 Triple (org.apache.jena.graph.Triple)1 ARQ (org.apache.jena.query.ARQ)1