use of org.apache.jena.fuseki.main.FusekiServer in project jena by apache.
the class TestRDFConnectionFusekiBinary method rdfconnection_fuseki_1.
@Test
public void rdfconnection_fuseki_1() {
// Tests all run, in order, on one connection.
Triple triple = SSE.parseTriple("(:s :p <_:b3456>)");
// Goes in as URI! (pre this PR)
Model model = ModelFactory.createDefaultModel();
model.getGraph().add(triple);
int PORT = WebLib.choosePort();
FusekiServer server = createFusekiServer(PORT).build().start();
try {
String dsURL = "http://localhost:" + PORT + "/ds";
assertTrue(HttpLib.isFuseki(dsURL));
RDFConnectionRemoteBuilder builder = RDFConnectionFuseki.create().destination(dsURL);
try (RDFConnectionFuseki conn = (RDFConnectionFuseki) builder.build()) {
assertTrue(HttpLib.isFuseki(dsURL));
// GSP
conn.put(model);
checkModel(conn, "b3456");
// Query forms.
conn.querySelect("SELECT * {?s ?p ?o}", x -> {
Node obj = x.get("o").asNode();
assertTrue(obj.isBlank());
assertEquals("b3456", obj.getBlankNodeLabel());
});
try (QueryExecution qExec = conn.query("ASK {?s ?p <_:b3456>}")) {
boolean bool = qExec.execAsk();
assertTrue(bool);
}
try (QueryExecution qExec = conn.query("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER (sameTerm(?o, <_:b3456>)) }")) {
Model model2 = qExec.execConstruct();
checkModel(model2, "b3456");
}
try (QueryExecution qExec = conn.query("DESCRIBE ?s WHERE { ?s ?p <_:b3456>}")) {
Model model2 = qExec.execConstruct();
checkModel(model2, "b3456");
}
// Update
conn.update("CLEAR DEFAULT");
conn.update("INSERT DATA { <x:s> <x:p> <_:b789> }");
checkModel(conn, "b789");
conn.update("CLEAR DEFAULT");
conn.update("INSERT DATA { <x:s> <x:p> <_:6789> }");
checkModel(conn, "6789");
}
} finally {
server.stop();
}
}
use of org.apache.jena.fuseki.main.FusekiServer in project jena by apache.
the class TestFusekiRDFS method fuseki_rdfs_1.
// Test building a Fuseki server with an RDFS dataset.
@Test
public void fuseki_rdfs_1() {
Graph schema = SSE.parseGraph("(graph (:p rdfs:range :T))");
DatasetGraph dsg0 = DatasetGraphFactory.createTxnMem();
DatasetGraph dsg = RDFSFactory.datasetRDFS(dsg0, schema);
dsg.add(SSE.parseQuad("(_ :s :p :o)"));
FusekiServer server = FusekiServer.create().port(0).add("/ds", dsg).build();
server.start();
int port = server.getHttpPort();
String URL = "http://localhost:" + port + "/ds";
try (RDFConnection conn = RDFConnection.connect(URL)) {
conn.queryResultSet("PREFIX :<http://example/> SELECT ?t { :o a ?t }", rs -> {
assertTrue(rs.hasNext());
String type = rs.next().getResource("t").getURI();
assertFalse(rs.hasNext());
assertEquals(type, "http://example/T");
});
}
}
use of org.apache.jena.fuseki.main.FusekiServer in project jena by apache.
the class TestGeoAssembler method test.
private void test(String filename, String dbName) {
FusekiServer server = FusekiServer.create().port(0).parseConfigFile("file:" + DIR + filename).build();
try {
server.start();
int port = server.getPort();
String URL = "http://localhost:" + port + "/" + dbName;
String queryStr = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + "\n" + "SELECT *\n" + "WHERE{\n" + // "{ <http://example.org/Geometry#PolygonH> ?P ?O } UNION \n"
" { <http://example.org/Geometry#PolygonH> geo:sfContains ?obj }\n" + // + " <http://example.org/Geometry#PolygonH> ?P ?obj .\n"
"} ORDER by ?obj";
RowSet rs = QueryExec.service(URL).query(queryStr).select();
long x = RowSetOps.count(rs);
assertEquals(8, x);
} finally {
server.stop();
}
}
use of org.apache.jena.fuseki.main.FusekiServer in project jena by apache.
the class EnvTest method startServer.
private static FusekiServer startServer(String dsName, DatasetGraph dsg, StringHolderServlet holder, boolean verbose, String user, String password) {
if (user != null && password == null)
throw new IllegalArgumentException("User, not null, but password null");
if (user != null) {
}
String data = "/data";
FusekiServer.Builder builder = FusekiServer.create().port(0).verbose(verbose).enablePing(true).auth(AuthScheme.BASIC).addServlet(data, holder).add(dsName, dsg);
if (user != null) {
UserStore userStore = JettyLib.makeUserStore(user, password);
SecurityHandler sh = JettyLib.makeSecurityHandler("TripleStore", userStore, AuthScheme.BASIC);
builder.securityHandler(sh).serverAuthPolicy(Auth.policyAllowSpecific(user));
}
FusekiServer server = builder.build();
server.start();
return server;
}
use of org.apache.jena.fuseki.main.FusekiServer in project jena by apache.
the class ExModelStore01 method main.
public static void main(String... args) {
try {
// Setup a server.
FusekiLogging.setLogging();
FusekiServer server = ExamplesServer.startServer(dsName, dsg, false);
String dataURL = "http://localhost:" + server.getPort() + "/" + dsName;
RDFParser.fromString(rdfString).lang(Lang.TTL).parse(someData);
exampleModelStore(dataURL);
} catch (Throwable th) {
th.printStackTrace();
} finally {
// The server is in the background so explicitly exit the process
System.exit(0);
}
}
Aggregations