Search in sources :

Example 21 with Context

use of org.apache.jena.sparql.util.Context in project jena by apache.

the class TestStreamManager method context.

private static Context context(StreamManager streamMgr) {
    Context context = new Context();
    context.put(SysRIOT.sysStreamManager, streamMgr);
    return context;
}
Also used : Context(org.apache.jena.sparql.util.Context)

Example 22 with Context

use of org.apache.jena.sparql.util.Context in project jena by apache.

the class TDB method wireIntoExecution.

private static void wireIntoExecution() {
    // Globally change the stage generator to intercept BGP on TDB
    Context cxt = ARQ.getContext();
    StageGenerator orig = StageBuilder.chooseStageGenerator(cxt);
    // Wire in the TDB stage generator which will make TDB work whether
    // or not the TDB executor is used. This means that datasets of mixed
    // graph types inside a general purpose dataset work.
    StageGenerator stageGenerator = new StageGeneratorDirectTDB(orig);
    StageBuilder.setGenerator(ARQ.getContext(), stageGenerator);
}
Also used : Context(org.apache.jena.sparql.util.Context) StageGenerator(org.apache.jena.sparql.engine.main.StageGenerator) StageGeneratorDirectTDB(org.apache.jena.tdb.solver.StageGeneratorDirectTDB)

Example 23 with Context

use of org.apache.jena.sparql.util.Context in project jena by apache.

the class ARQ method defaultSettings.

/* Side effects */
private static Context defaultSettings() {
    // This must be exeutable before initialization 
    SystemARQ.StrictDateTimeFO = false;
    SystemARQ.ValueExtensions = true;
    SystemARQ.EnableRomanNumerals = false;
    Context context = new Context();
    context.unset(optimization);
    //context.set(hideNonDistiguishedVariables, true) ;
    context.set(strictSPARQL, false);
    context.set(constantBNodeLabels, true);
    context.set(enablePropertyFunctions, true);
    context.set(regexImpl, javaRegex);
    return context;
}
Also used : Context(org.apache.jena.sparql.util.Context)

Example 24 with Context

use of org.apache.jena.sparql.util.Context in project jena by apache.

the class TestService method query_service_context_application_02.

@SuppressWarnings("unchecked")
@Test
public void query_service_context_application_02() {
    // This test requires us to set some authentication credentials for the
    // service
    Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
    if (serviceContextMap == null) {
        ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>());
        serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
    }
    if (serviceContextMap.get(SERVICE) == null) {
        serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
    }
    Context serviceContext = serviceContextMap.get(SERVICE);
    try {
        HttpClient testClient = HttpClients.custom().build();
        serviceContext.put(Service.queryClient, testClient);
        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.assertEquals(testClient, engine.getClient());
    } finally {
        serviceContext.remove(Service.queryClient);
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) QueryEngineHTTP(org.apache.jena.sparql.engine.http.QueryEngineHTTP) Query(org.apache.jena.query.Query) HttpClient(org.apache.http.client.HttpClient) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 25 with Context

use of org.apache.jena.sparql.util.Context in project jena by apache.

the class TestService method update_service_context_application_02.

@SuppressWarnings("unchecked")
@Test
public void update_service_context_application_02() {
    // This test requires no service context to be set
    Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
    if (serviceContextMap == null) {
        ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>());
        serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
    }
    if (serviceContextMap.get(SERVICE) == null) {
        serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
    }
    Context serviceContext = serviceContextMap.get(SERVICE);
    try {
        HttpClient testClient = HttpClients.custom().build();
        serviceContext.put(Service.queryClient, testClient);
        UpdateRequest updates = UpdateFactory.create("CREATE GRAPH <http://example>");
        UpdateProcessRemoteBase engine = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, SERVICE);
        Assert.assertNotNull(engine);
        // Check that client settings were changed
        Assert.assertEquals(testClient, engine.getClient());
    } finally {
        serviceContext.remove(Service.queryClient);
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) UpdateRequest(org.apache.jena.update.UpdateRequest) HttpClient(org.apache.http.client.HttpClient) UpdateProcessRemoteBase(org.apache.jena.sparql.modify.UpdateProcessRemoteBase) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Context (org.apache.jena.sparql.util.Context)52 Test (org.junit.Test)36 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)15 Map (java.util.Map)11 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)11 HashMap (java.util.HashMap)10 QueryIterSort (org.apache.jena.sparql.engine.iterator.QueryIterSort)9 HttpClient (org.apache.http.client.HttpClient)7 QueryEngineHTTP (org.apache.jena.sparql.engine.http.QueryEngineHTTP)7 Query (org.apache.jena.query.Query)5 QueryCancelledException (org.apache.jena.query.QueryCancelledException)4 SocketException (java.net.SocketException)3 ConnectTimeoutException (org.apache.http.conn.ConnectTimeoutException)3 HttpContext (org.apache.http.protocol.HttpContext)3 JsonObject (org.apache.jena.atlas.json.JsonObject)3 JsonString (org.apache.jena.atlas.json.JsonString)3 Node (org.apache.jena.graph.Node)3 Model (org.apache.jena.rdf.model.Model)3 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)3