use of org.apache.jena.sparql.core.BasicPattern 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()));
}
}
}
use of org.apache.jena.sparql.core.BasicPattern 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()));
}
}
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class FmtTemplate method format.
@Override
public void format(Template template) {
out.print("{");
out.incIndent(INDENT);
out.pad();
List<Quad> quads = template.getQuads();
for (Quad quad : quads) {
BasicPattern bgp = new BasicPattern();
bgp.add(quad.asTriple());
out.newline();
if (!Quad.defaultGraphNodeGenerated.equals(quad.getGraph())) {
out.print("GRAPH");
out.print(" ");
out.print(slotToString(quad.getGraph()));
out.print(" ");
out.newline();
out.incIndent(INDENT);
out.pad();
out.print("{");
out.incIndent(INDENT);
out.pad();
}
formatTriples(bgp);
if (!Quad.defaultGraphNodeGenerated.equals(quad.getGraph())) {
out.decIndent(INDENT);
out.print("}");
out.decIndent(INDENT);
}
}
out.newline();
out.decIndent(INDENT);
out.print("}");
out.newline();
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TestReorder method reorderIndexes1.
@Test
public void reorderIndexes1() {
ReorderProc proc = new ReorderProcIndexes(new int[] { 0, 1 });
BasicPattern bgp = bgp("(bgp (:x :p ?v) (:x :q ?w))");
BasicPattern bgp2 = proc.reorder(bgp);
assertEquals(bgp, bgp2);
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TestReorder method stats_dft_01.
@Test
public void stats_dft_01() {
ReorderTransformation transform = ReorderLib.fixed();
BasicPattern bgp = bgp("(bgp)");
BasicPattern bgp2 = transform.reorder(bgp);
assertEquals(bgp2, bgp);
}
Aggregations