Package com.hp.hpl.jena.sparql.engine.http

Examples of com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP


    protected QueryExecution createQueryExecution(Query q) throws SQLException {
        if (this.remoteConn.getQueryEndpoint() == null)
            throw new SQLException("This statement is backed by a write-only connection, read operations are not supported");

        // Create basic execution
        QueryEngineHTTP exec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(this.remoteConn.getQueryEndpoint(), q);

        // Apply authentication settings
        if (this.authenticator != null) {
            exec.setAuthenticator(this.authenticator);
        }

        // Apply default and named graphs if appropriate
        if (this.remoteConn.getDefaultGraphURIs() != null) {
            exec.setDefaultGraphURIs(this.remoteConn.getDefaultGraphURIs());
        }
        if (this.remoteConn.getNamedGraphURIs() != null) {
            exec.setNamedGraphURIs(this.remoteConn.getNamedGraphURIs());
        }

        // Set result types
        if (this.remoteConn.getSelectResultsType() != null) {
            exec.setSelectContentType(this.remoteConn.getSelectResultsType());
        }
        if (this.remoteConn.getModelResultsType() != null) {
            exec.setModelContentType(this.remoteConn.getModelResultsType());
        }

        // Return execution
        return exec;
    }
View Full Code Here


    protected QueryExecution createQueryExecution(Query q) throws SQLException {
        if (this.remoteConn.getQueryEndpoint() == null)
            throw new SQLException("This statement is backed by a write-only connection, read operations are not supported");

        // Create basic execution
        QueryEngineHTTP exec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(this.remoteConn.getQueryEndpoint(), q);

        // Apply authentication settings
        if (this.authenticator != null) {
            exec.setAuthenticator(authenticator);
        }

        // Apply default and named graphs if appropriate
        if (this.remoteConn.getDefaultGraphURIs() != null) {
            exec.setDefaultGraphURIs(this.remoteConn.getDefaultGraphURIs());
        }
        if (this.remoteConn.getNamedGraphURIs() != null) {
            exec.setNamedGraphURIs(this.remoteConn.getNamedGraphURIs());
        }

        // Set result types
        if (this.remoteConn.getSelectResultsType() != null) {
            exec.setSelectContentType(this.remoteConn.getSelectResultsType());
        }
        if (this.remoteConn.getModelResultsType() != null) {
            exec.setModelContentType(this.remoteConn.getModelResultsType());
        }
       
        // Return execution
        return exec;
    }
View Full Code Here

    }

    @Test public void query_02()
    {
        Query query = QueryFactory.create("SELECT * { ?s ?p ?o }") ;
        QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(serviceQuery, query) ;
        engine.setSelectContentType(WebContent.contentTypeResultsJSON) ;
        ResultSet rs = engine.execSelect() ;
        int x = ResultSetFormatter.consume(rs) ;
        assertTrue( x != 0 ) ;
    }
View Full Code Here

        realmFile.delete();
    }

    @Test(expected = QueryExceptionHTTP.class)
    public void query_with_auth_01() {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        // No auth credentials should result in an error
        qe.execAsk();
    }
View Full Code Here

        qe.execAsk();
    }

    @Test(expected = QueryExceptionHTTP.class)
    public void query_with_auth_02() {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        // Auth credentials for valid user with bad password
        qe.setBasicAuthentication("allowed", "incorrect".toCharArray());
        qe.execAsk();
    }
View Full Code Here

        qe.execAsk();
    }

    @Test
    public void query_with_auth_03() {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        // Auth credentials for valid user with correct password
        qe.setBasicAuthentication("allowed", "password".toCharArray());
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here

        Assert.assertTrue(qe.execAsk());
    }

    @Test(expected = QueryExceptionHTTP.class)
    public void query_with_auth_04() {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        // Auth credentials for valid user with correct password BUT not in
        // correct role
        qe.setBasicAuthentication("forbidden", "password".toCharArray());
        qe.execAsk();
    }
View Full Code Here

    }

    @Test
    public void query_with_auth_05() {
        // Uses auth and enables compression
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        qe.setAllowDeflate(true);
        qe.setAllowGZip(true);

        // Auth credentials for valid user with correct password
        qe.setBasicAuthentication("allowed", "password".toCharArray());
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here

    }

    @Test(expected = QueryExceptionHTTP.class)
    public void query_with_auth_06() {
        // Uses auth and enables compression
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");
        qe.setAllowDeflate(true);
        qe.setAllowGZip(true);

        // Auth credentials for valid user with bad password
        qe.setBasicAuthentication("allowed", "incorrect".toCharArray());
        qe.execAsk();
    }
View Full Code Here

        qe.execAsk();
    }

    @Test(expected = QueryExceptionHTTP.class)
    public void query_with_auth_07() throws URISyntaxException {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password but scoped to
        // wrong URI
        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI("http://example"), "allowed",
                "password".toCharArray());
        qe.setAuthenticator(authenticator);
        qe.execAsk();
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.