Search in sources :

Example 1 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestService method testStringTimeout2.

@Test
public void testStringTimeout2() {
    BasicPattern basicPattern = new BasicPattern();
    basicPattern.add(Triple.ANY);
    Node serviceNode = NodeFactory.createURI(SERVICE);
    OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false);
    Context context = new Context();
    ARQ.setNormalMode(context);
    context.set(Service.queryTimeout, "10,10000");
    try {
        Service.exec(opService, context);
        Assert.fail("Expected QueryExceptionHTTP");
    } catch (QueryExceptionHTTP expected) {
        Throwable thrown = expected.getCause();
        if (thrown instanceof SocketException || thrown instanceof ConnectTimeoutException) {
        // expected
        } else {
            Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
        }
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SocketException(java.net.SocketException) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) OpService(org.apache.jena.sparql.algebra.op.OpService) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) ConnectTimeoutException(org.apache.http.conn.ConnectTimeoutException) Test(org.junit.Test)

Example 2 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestService method testNumericTimeout.

@Test
public void testNumericTimeout() {
    BasicPattern basicPattern = new BasicPattern();
    basicPattern.add(Triple.ANY);
    Node serviceNode = NodeFactory.createURI(SERVICE);
    OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false);
    Context context = new Context();
    ARQ.setNormalMode(context);
    context.set(Service.queryTimeout, 10);
    try {
        Service.exec(opService, context);
        Assert.fail("Expected QueryExceptionHTTP");
    } catch (QueryExceptionHTTP expected) {
        Throwable thrown = expected.getCause();
        if (thrown instanceof SocketException || thrown instanceof ConnectTimeoutException) {
        // expected
        } else {
            Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
        }
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SocketException(java.net.SocketException) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) OpService(org.apache.jena.sparql.algebra.op.OpService) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) ConnectTimeoutException(org.apache.http.conn.ConnectTimeoutException) Test(org.junit.Test)

Example 3 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestService method testStringTimeout.

@Test
public void testStringTimeout() {
    BasicPattern basicPattern = new BasicPattern();
    basicPattern.add(Triple.ANY);
    Node serviceNode = NodeFactory.createURI(SERVICE);
    OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false);
    Context context = new Context();
    ARQ.setNormalMode(context);
    context.set(Service.queryTimeout, "10");
    try {
        Service.exec(opService, context);
        Assert.fail("Expected QueryExceptionHTTP");
    } catch (QueryExceptionHTTP expected) {
        Throwable thrown = expected.getCause();
        if (thrown instanceof SocketException || thrown instanceof ConnectTimeoutException) {
        // expected
        } else {
            Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
        }
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SocketException(java.net.SocketException) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) OpService(org.apache.jena.sparql.algebra.op.OpService) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) ConnectTimeoutException(org.apache.http.conn.ConnectTimeoutException) Test(org.junit.Test)

Example 4 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestBlankNodeBinary method bNodeSPARQL_Query_2.

@Test
public void bNodeSPARQL_Query_2() {
    String qs = "SELECT * { ?s ?p <_:BCD>}";
    Query query = QueryFactory.create(qs);
    Op op = Algebra.compile(query);
    BasicPattern bp = ((OpBGP) op).getPattern();
    Triple t = bp.get(0);
    assertEquals("BCD", t.getObject().getBlankNodeLabel());
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern) Test(org.junit.Test)

Example 5 with OpBGP

use of org.apache.jena.sparql.algebra.op.OpBGP in project jena by apache.

the class TestServiceSetup method testStringTimeout.

@Test
public void testStringTimeout() {
    BasicPattern basicPattern = new BasicPattern();
    basicPattern.add(Triple.ANY);
    Node serviceNode = NodeFactory.createURI(SERVICE);
    OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false);
    Context context = new Context();
    ARQ.setNormalMode(context);
    context.set(Service.httpQueryTimeout, "10");
    try {
        Service.exec(opService, context);
        Assert.fail("Expected QueryExceptionHTTP");
    } catch (QueryExceptionHTTP expected) {
        Throwable thrown = expected.getCause();
        if (thrown instanceof SocketException || thrown instanceof HttpConnectTimeoutException || thrown instanceof UnknownHostException) {
        // expected
        } else {
            Assert.fail(String.format("Expected SocketException or HttpConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage()));
        }
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SocketException(java.net.SocketException) UnknownHostException(java.net.UnknownHostException) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) OpService(org.apache.jena.sparql.algebra.op.OpService) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) HttpConnectTimeoutException(java.net.http.HttpConnectTimeoutException) Test(org.junit.Test)

Aggregations

OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)21 BasicPattern (org.apache.jena.sparql.core.BasicPattern)19 Op (org.apache.jena.sparql.algebra.Op)11 Node (org.apache.jena.graph.Node)10 Triple (org.apache.jena.graph.Triple)9 Test (org.junit.Test)9 SocketException (java.net.SocketException)5 OpService (org.apache.jena.sparql.algebra.op.OpService)5 QueryExceptionHTTP (org.apache.jena.sparql.engine.http.QueryExceptionHTTP)5 Context (org.apache.jena.sparql.util.Context)5 Var (org.apache.jena.sparql.core.Var)4 ArrayList (java.util.ArrayList)3 ConnectTimeoutException (org.apache.http.conn.ConnectTimeoutException)3 Query (org.apache.jena.query.Query)3 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)3 Binding (org.apache.jena.sparql.engine.binding.Binding)3 Expr (org.apache.jena.sparql.expr.Expr)3 ExprVar (org.apache.jena.sparql.expr.ExprVar)3 UnknownHostException (java.net.UnknownHostException)2 HttpConnectTimeoutException (java.net.http.HttpConnectTimeoutException)2