use of org.apache.jena.sparql.engine.http.QueryEngineHTTP in project jena by apache.
the class TestService method query_service_context_application_01.
@Test
public void query_service_context_application_01() {
// This test requires no service context to be set
@SuppressWarnings("unchecked") Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
if (serviceContextMap != null) {
serviceContextMap.remove(SERVICE);
}
Query q = QueryFactory.create("ASK { }");
QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
Assert.assertNotNull(engine);
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(-1, engine.getTimeout2());
Assert.assertTrue(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
}
use of org.apache.jena.sparql.engine.http.QueryEngineHTTP in project jena by apache.
the class TestAuth method query_with_auth_04.
@Test(expected = QueryExceptionHTTP.class)
public void query_with_auth_04() {
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
// Auth credentials for valid user with correct password BUT not in
// correct role
qe.setClient(withBasicAuth(ANY, "forbidden", "password"));
qe.execAsk();
}
use of org.apache.jena.sparql.engine.http.QueryEngineHTTP in project jena by apache.
the class TestAuth method query_with_auth_06.
@Test(expected = QueryExceptionHTTP.class)
public void query_with_auth_06() {
// Uses auth and enables compression
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
qe.setAllowCompression(true);
// Auth credentials for valid user with bad password
qe.setClient(withBasicAuth(ANY, "allowed", "incorrect"));
qe.execAsk();
}
use of org.apache.jena.sparql.engine.http.QueryEngineHTTP in project jena by apache.
the class TestAuth method query_with_auth_03.
@Test
public void query_with_auth_03() {
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
// Auth credentials for valid user with correct password
qe.setClient(withBasicAuth(ANY, "allowed", "password"));
Assert.assertTrue(qe.execAsk());
}
use of org.apache.jena.sparql.engine.http.QueryEngineHTTP in project jena by apache.
the class TestAuth method query_with_auth_09.
@Test
public void query_with_auth_09() throws URISyntaxException {
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
// Auth credentials for valid user with correct password
qe.setClient(withBasicAuth(new AuthScope("localhost", authPort), "allowed", "password"));
Assert.assertTrue(qe.execAsk());
}
Aggregations